32 #include "DGtal/base/Common.h"
33 #include "DGtal/geometry/volumes/distance/SeparableMetricAdapter.h"
34 #include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
35 #include "DGtal/geometry/volumes/distance/InexactPredicateLpSeparableMetric.h"
36 #include "DGtal/geometry/volumes/distance/VoronoiMap.h"
37 #include "DGtal/io/boards/Board2D.h"
38 #include "DGtal/helpers/StdDefs.h"
42 using namespace DGtal;
68 AdaptedDistance myMetric(l2);
72 trace.
info() <<
"Two point distance= "<<myMetric(a,b)<<std::endl;
84 unsigned int nbok = 0;
89 Z2i::Point a( 0,0), b(5, 0), bb(5,-10), bbb(5,5),c(10,0), d(3,3);
95 AdaptedDistance metric(l2);
104 trace.
info() <<
"distance between a and bb = "<< metric(a,bb)<< std::endl;
110 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
111 <<
"closest(a,d,c) returns d" << std::endl;
113 bool hidden =metric.hiddenBy(a,b,c,starting,endpoint,0);
114 nbok += (!hidden) ? 1 : 0;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
117 <<
"(a,b,c) returns false" << std::endl;
119 hidden =metric.hiddenBy(a,bb,c,starting,endpoint,0);
120 nbok += (hidden) ? 1 : 0;
122 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
123 <<
"(a,bb,c) returns true" << std::endl;
125 hidden =metric.hiddenBy(a,bbb,c,starting,endpoint,0);
126 nbok += (!hidden) ? 1 : 0;
128 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
129 <<
"(a,bbb,c) returns false" << std::endl;
139 AdaptedDistance3 metric3(l3);
148 hidden =metric3.hiddenBy(a,b,c,starting,endpoint,0);
149 nbok += (!hidden) ? 1 : 0;
151 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
152 <<
"(a,b,c) returns false" << std::endl;
154 hidden =metric3.hiddenBy(a,bb,c,starting,endpoint,0);
155 nbok += (hidden) ? 1 : 0;
157 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
158 <<
"(a,bb,c) returns true" << std::endl;
160 hidden =metric3.hiddenBy(a,bbb,c,starting,endpoint,0);
161 nbok += (!hidden) ? 1 : 0;
163 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
164 <<
"(a,bbb,c) returns false" << std::endl;
171 template <
typename Metric>
175 Adapted adapted(aMetric);
177 unsigned int nbok = 0;
203 VoroExact voroExact(
domain, mySet,aMetric);
204 VoroAdapted voroAdapted(
domain, mySet, adapted);
207 trace.
info()<<
"Exporting o SVG"<<std::endl;
210 itend = voroExact.domain().end();
214 unsigned char c = (p[1]*13 + p[0] * 7) % 256;
218 string out = filename +
"-exact.svg";
223 itend = voroAdapted.domain().end();
227 unsigned char c = (p[1]*13 + p[0] * 7) % 256;
231 out = filename +
"-adapted.svg";
237 itend = voroExact.domain().end();
240 if (voroExact(*it) != voroAdapted(*it))
243 nbok +=
true ? 1 : 0;
245 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
246 <<
"Voronoi diagram is valid !" << std::endl;
255 int main(
int argc,
char** argv )
259 for (
int i = 0; i < argc; ++i )
269 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Structure representing an RGB triple with alpha component.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
void insertNew(const Point &p)
ConstIterator end() const
ConstIterator begin() const
Size erase(const Point &p)
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Aim: implements separable l_p metrics with exact predicates.
Iterator for HyperRectDomain.
const ConstIterator & end() const
const ConstIterator & begin() const
Aim: implements separable l_p metrics with approximated predicates.
Aim: Adapts any model of CMetric to construct a separable metric (model of CSeparableMetric).
void beginBlock(const std::string &keyword="")
Aim: Implementation of the linear in time Voronoi map construction.
void clear(const DGtal::Color &color=DGtal::Color::None)
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DigitalPlane::Point Vector
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
bool testSeparableMetricAdapter()
bool testVoronoiMap(const Metric &aMetric, string filename)
int main(int argc, char **argv)