32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
36 #include "DGtal/geometry/volumes/distance/CPowerSeparableMetric.h"
37 #include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
38 #include "DGtal/geometry/volumes/distance/ExactPredicateLpPowerSeparableMetric.h"
39 #include "DGtal/geometry/volumes/distance/InexactPredicateLpSeparableMetric.h"
43 using namespace DGtal;
50 unsigned int nbok = 0;
55 Z2i::Point a( 0,0), b(5, 0), bb(5,-10), bbb(5,5),c(10,0), d(3,3);
66 trace.
info() <<
"distance between a and bb = "<< metric(a,bb)<< std::endl;
72 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
73 <<
"closest(a,d,c) returns d" << std::endl;
75 bool hidden =metric.
hiddenBy(a,b,c,starting,endpoint,0);
76 nbok += (!hidden) ? 1 : 0;
78 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
79 <<
"(a,b,c) returns false" << std::endl;
81 hidden =metric.
hiddenBy(a,bb,c,starting,endpoint,0);
82 nbok += (hidden) ? 1 : 0;
84 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
85 <<
"(a,bb,c) returns true" << std::endl;
87 hidden =metric.
hiddenBy(a,bbb,c,starting,endpoint,0);
88 nbok += (!hidden) ? 1 : 0;
90 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
91 <<
"(a,bbb,c) returns false" << std::endl;
107 hidden =metric3.
hiddenBy(a,b,c,starting,endpoint,0);
108 nbok += (!hidden) ? 1 : 0;
110 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
111 <<
"(a,b,c) returns false" << std::endl;
113 hidden =metric3.
hiddenBy(a,bb,c,starting,endpoint,0);
114 nbok += (hidden) ? 1 : 0;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
117 <<
"(a,bb,c) returns true" << std::endl;
119 hidden =metric3.
hiddenBy(a,bbb,c,starting,endpoint,0);
120 nbok += (!hidden) ? 1 : 0;
122 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
123 <<
"(a,bbb,c) returns false" << std::endl;
130 template <
typename Value>
133 unsigned int nbok = 0;
136 trace.
beginBlock (
"Testing inexact predicate separable metrics l_2.1 ..." );
138 Z2i::Point a( 0,0), b(5, 0), bb(5,-10), bbb(5,5),c(10,0);
150 bool hidden =metric.
hiddenBy(a,b,c,starting,endpoint,0);
151 nbok += (!hidden) ? 1 : 0;
153 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
154 <<
"(a,b,c) returns false" << std::endl;
156 hidden =metric.
hiddenBy(a,bb,c,starting,endpoint,0);
157 nbok += (hidden) ? 1 : 0;
159 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
160 <<
"(a,bb,c) returns true" << std::endl;
162 hidden =metric.
hiddenBy(a,bbb,c,starting,endpoint,0);
163 nbok += (!hidden) ? 1 : 0;
165 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
166 <<
"(a,bbb,c) returns false" << std::endl;
170 trace.
beginBlock (
"Testing inexact predicate separable metrics l_3.1 ..." );
182 hidden =metric3.
hiddenBy(a,b,c,starting,endpoint,0);
183 nbok += (!hidden) ? 1 : 0;
185 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
186 <<
"(a,b,c) returns false" << std::endl;
188 hidden =metric3.
hiddenBy(a,bb,c,starting,endpoint,0);
189 nbok += (hidden) ? 1 : 0;
191 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
192 <<
"(a,bb,c) returns true" << std::endl;
194 hidden =metric3.
hiddenBy(a,bbb,c,starting,endpoint,0);
195 nbok += (!hidden) ? 1 : 0;
197 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
198 <<
"(a,bbb,c) returns false" << std::endl;
208 unsigned int nbok = 0;
213 Z2i::Point a( 0,0), bbis(4, 1), b(5,0), bb(5,-10), bbb(5,5),c(10,0);
228 nbok += (closer) ? 1 : 0;
230 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
231 <<
"a is closer" << std::endl;
234 nbok += (!closer) ? 1 : 0;
236 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
237 <<
"c is closer with w_a=10 w_c=35" << std::endl;
242 bool hidden =metric.hiddenByPower(a,0,b,0,c,0,starting,endpoint,0);
243 nbok += (!hidden) ? 1 : 0;
245 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
246 <<
"(a,b,c) returns false" << std::endl;
248 hidden =metric.hiddenByPower(a,0,bb,0,c,0,starting,endpoint,0);
249 nbok += (hidden) ? 1 : 0;
251 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
252 <<
"(a,bb,c) returns true" << std::endl;
254 hidden =metric.hiddenByPower(a,0,bbb,0,c,0,starting,endpoint,0);
255 nbok += (!hidden) ? 1 : 0;
257 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
258 <<
"(a,bbb,c) returns false" << std::endl;
260 hidden =metric.hiddenByPower(a,0,d,0,c,0,starting,endpoint,0);
261 nbok += (hidden) ? 1 : 0;
263 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
264 <<
"(a,d,c) returns true" << std::endl;
269 hidden =metric.hiddenByPower(a,0,d,30,c,0,starting,endpoint,0);
270 nbok += (hidden) ? 1 : 0;
272 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
273 <<
"(a,0,d,30,c,0) returns true" << std::endl;
275 hidden =metric.hiddenByPower(a,10,d,10,c,10,starting,endpoint,0);
276 nbok += (hidden) ? 1 : 0;
278 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
279 <<
"(a,10,d,10,c,10) returns true" << std::endl;
289 unsigned int nbok = 0;
312 trace.
info() <<
"Abscissa ="<<res<<std::endl;
314 nbok += (res == 8) ? 1 : 0;
316 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " <<
"last strict in A==(0,8)" << std::endl;
334 trace.
info() <<
"Abscissa ="<<res2<<std::endl;
336 nbok += (res2 == 7) ? 1 : 0;
338 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " <<
"last strict in AA==(0,7) (VoroVertex)" << std::endl;
360 trace.
info() <<
"Abscissa ="<<res4<<std::endl;
362 nbok += (res4 >= 15) ? 1 : 0;
364 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " <<
"should be >= upper bound (15)" << std::endl;
375 unsigned int nbok = 0;
380 Z2i::Point a(5,7),b(5,8),bb(6,8),bbb(7,8),c(5,9), bbbb(105,8);
383 bool hidden =metric.
hiddenBy(a,b,c,starting,endpoint,1);
384 nbok += (!hidden) ? 1 : 0;
386 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
387 <<
"(a,b,c) returns false" << std::endl;
393 hidden =metric.
hiddenBy(a,bb,c,starting,endpoint,1);
394 nbok += (!hidden) ? 1 : 0;
396 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
397 <<
"(a,bb,c) returns false" << std::endl;
405 hidden =metric.
hiddenBy(a,bbb,c,starting,endpoint,1);
406 nbok += (hidden) ? 1 : 0;
408 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
409 <<
"(a,bbb,c) returns true" << std::endl;
415 hidden =metric.
hiddenBy(a,bbbb,c,starting,endpoint,1);
416 nbok += (hidden) ? 1 : 0;
418 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
419 <<
"(a,bbbb,c) returns true" << std::endl;
428 unsigned int nbok = 0;
434 Z2i::Point a(8,5),b(8,8),bb(9,8),bbb(10,8),c(8,11);
437 bool hidden =metric.
hiddenBy(a,b,c,starting,endpoint,1);
438 nbok += (!hidden) ? 1 : 0;
440 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
441 <<
"(a,b,c) returns false" << std::endl;
446 hidden =metric.
hiddenBy(a,bb,c,starting,endpoint,1);
447 nbok += (!hidden) ? 1 : 0;
449 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
450 <<
"(a,bb,c) returns false" << std::endl;
457 hidden =metric.
hiddenBy(a,bbb,c,starting,endpoint,1);
458 nbok += (hidden) ? 1 : 0;
460 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
461 <<
"(a,bbb,c) returns true" << std::endl;
482 int main(
int argc,
char** argv )
486 for (
int i = 0; i < argc; ++i )
491 && testInexactMetrics<double>()
492 && testInexactMetrics<float>()
498 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: implements weighted separable l_p metrics with exact predicates.
Aim: implements separable l_p metrics with exact predicates.
Closest closest(const Point &origin, const Point &first, const Point &second) const
Abscissa binarySearchHidden(const Abscissa &udim, const Abscissa &vdim, const RawValue &nu, const RawValue &nv, const Abscissa &lower, const Abscissa &upper) const
Point::Coordinate Abscissa
Type for points.
bool hiddenBy(const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
TRawValue RawValue
Type for internal distance values.
Aim: implements separable l_p metrics with approximated predicates.
bool hiddenBy(const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: defines the concept of separable metrics.
Aim: defines the concept of separable metrics.
int main(int argc, char **argv)
bool testInexactMetrics()
bool testSpecialCasesL2()
bool testSpecialCasesLp()