34#include "DGtal/base/Common.h"
35#include "ConfigTest.h"
36#include "DGtal/helpers/StdDefs.h"
37#include "DGtal/geometry/volumes/distance/ChamferNorm2D.h"
38#include "DGtal/geometry/volumes/distance/CMetricSpace.h"
39#include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
61 unsigned int nbok = 0;
88 trace.
info() <<
"Direction "<<d<<std::endl;
90 <<
" -- " << *(aMask.
getCone(d)+1) <<std::endl;
91 nbok += ( lthan(d, *(aMask.
getCone(d)+1))) ? 1 : 0;
93 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
94 <<
"(d < cone+1) returns true" << std::endl;
95 nbok += (lqthan(*(aMask.
getCone(d)),d)) ? 1 : 0;
97 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
98 <<
"(cone <= d) returns true" << std::endl;
102 trace.
info() <<
"Direction "<<d3<<std::endl;
104 <<
" -- " << *(aMask.
getCone(d3)+1) <<std::endl;
107 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
108 <<
"(d < cone+1) returns true" << std::endl;
111 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
112 <<
"(cone <= d) returns true" << std::endl;
117 trace.
info() <<
"Direction "<<d2<<std::endl;
119 <<
" -- " << *(aMask.
getCone(d2)+1) <<std::endl;
122 nbok += ( lthan(d2, *(aMask.
getCone(d2)+1))) ? 1 : 0;
124 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
125 <<
"(d2 < cone+1) returns true" << std::endl;
127 nbok += (lqthan(*(aMask.
getCone(d2)),d2) ) ? 1 : 0;
129 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
130 <<
"(cone <= d2) returns true" << std::endl;
134 Point p(1,1), q(102,101);
135 trace.
info()<<
"Distance between "<<p<<
" and "<< q <<
" = "<< aMask(p,q)<<std::endl;
136 trace.
info()<<
"Distance between "<<q<<
" and "<< p <<
" = "<< aMask(q,p)<<std::endl;
137 nbok += ( aMask(p,q) == aMask(q,p)) ? 1 : 0;
139 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
140 <<
"d(p,q)==d(q,p)" << std::endl;
145 trace.
info() <<
"Direction "<<d4<<std::endl;
147 <<
" -- " << *(aMask.
getCone(d4)+1) <<std::endl;
150 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
151 <<
"Last cone 1" << std::endl;
155 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
156 <<
"Last cone 2" << std::endl;
160 trace.
info() <<
"Direction "<<d5<<std::endl;
162 <<
" -- " << *(aMask.
getCone(d5)+1) <<std::endl;
165 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
166 <<
"Last cone 1" << std::endl;
170 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
171 <<
"Last cone 2" << std::endl;
173 trace.
info() <<
" upper="<<*std::upper_bound(aMask.
begin(), aMask.
end(), d4, lthan)<<std::endl;
181 unsigned int nbok = 0;
202 trace.
info() <<
"Distance "<<p<<
" = "<< mask34(orig,p)<<std::endl;;
206 trace.
info() <<
"Distance "<<q<<
" = "<< mask34(orig,q)<<std::endl;;
216 unsigned int nbok = 0;
220 Point P(0,0),Q(7,3),Qb(7,-3), Q2(2, -10), Q3(2,10);
221 Point Lmin(10,-10), Lmax(10,10);
224 trace.
info() <<
"Intersection "<<P<<
" "<<Q<<
" = "
225 << mask.getLowerRayIntersection(P,Q,Lmin,Lmax, 1)<<std::endl;
226 nbok += ( mask.getLowerRayIntersection(P,Q,Lmin,Lmax, 1) == 4) ? 1 : 0;
228 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
229 <<
"inter==4" << std::endl;
231 trace.
info() <<
"Intersection "<<P<<
" "<<Qb<<
" = "
232 << mask.getLowerRayIntersection(P,Qb,Lmin,Lmax, 1)<<std::endl;
233 nbok += ( mask.getLowerRayIntersection(P,Qb,Lmin,Lmax, 1) == -5) ? 1 : 0;
235 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
236 <<
"inter==-5" << std::endl;
238 trace.
info() <<
"Intersection "<<P<<
" "<<Q2<<
" = "
239 << mask.getLowerRayIntersection(P,Q2,Lmin,Lmax, 1)<<std::endl;
240 nbok += ( mask.getLowerRayIntersection(P,Q2,Lmin,Lmax, 1) <= Lmin[1]) ? 1 : 0;
242 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
243 <<
"inter==Lmin" << std::endl;
245 trace.
info() <<
"Intersection "<<P<<
" "<<Q3<<
" = "
246 << mask.getLowerRayIntersection(P,Q3,Lmin,Lmax, 1)<<std::endl;
247 nbok += ( mask.getLowerRayIntersection(P,Q3,Lmin,Lmax, 1) >= Lmax[1]) ? 1 : 0;
249 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
250 <<
"inter==Lmax" << std::endl;
254 Point PP(0,0),QQ(3,7),QQb(-3,7), QQ2(-10, 2), QQ3(10, 2);
255 Point LLmin(-10,10), LLmax(10,10);
257 trace.
info() <<
"Intersection "<<PP<<
" "<<QQ<<
" = "
258 << mask.getLowerRayIntersection(PP,QQ,LLmin,LLmax, 0)<<std::endl;
259 nbok += ( mask.getLowerRayIntersection(PP,QQ,LLmin,LLmax, 0) == 4) ? 1 : 0;
261 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
262 <<
"inter==4" << std::endl;
264 trace.
info() <<
"Intersection "<<PP<<
" "<<QQb<<
" = "
265 << mask.getLowerRayIntersection(PP,QQb,LLmin,LLmax, 0)<<std::endl;
266 nbok += ( mask.getLowerRayIntersection(PP,QQb,LLmin,LLmax, 0) == -5) ? 1 : 0;
268 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
269 <<
"inter==-5" << std::endl;
271 trace.
info() <<
"Intersection "<<PP<<
" "<<QQ2<<
" = "
272 << mask.getLowerRayIntersection(PP,QQ2,LLmin,LLmax, 0)<<std::endl;
273 nbok += ( mask.getLowerRayIntersection(PP,QQ2,LLmin,LLmax, 0) <= LLmin[0]) ? 1 : 0;
275 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
276 <<
"inter==Lmin" << std::endl;
278 trace.
info() <<
"Intersection "<<PP<<
" "<<QQ3<<
" = "
279 << mask.getLowerRayIntersection(PP,QQ3,LLmin,LLmax, 0)<<std::endl;
280 nbok += ( mask.getLowerRayIntersection(PP,QQ3,LLmin,LLmax, 0) >= LLmax[0]) ? 1 : 0;
282 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
283 <<
"inter==Lmax" << std::endl;
291 unsigned int nbok = 0;
297 Metric::Directions dirs5711;
298 Metric::Directions normals5711;
318 Metric mask5711(dirs5711,normals5711);
322 Point Q(1,-2), QQ(1,2);
325 Metric::ConstIterator itBeg = mask5711.begin();
326 Metric::ConstIterator itEnd = mask5711.end();
328 Point midPoint, nextMidPoint;
330 Metric::ConstIterator cone = mask5711.shrinkPSubMask(itBeg, itEnd, P, Q, Lmin, Lmax, 1, midPoint, nextMidPoint);
331 trace.
info() <<
"Shrink returns the cone "<< *cone<<
" " <<*(cone+1)<<std::endl;
332 trace.
info() <<
"MidPoint "<< midPoint<<
" " <<nextMidPoint<<std::endl<<std::endl;
333 nbok += ( midPoint ==
Point(10,0)) ? 1 : 0;
335 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
336 <<
"midPoint = (10,0)" << std::endl;
337 nbok += ( nextMidPoint ==
Point(10,5)) ? 1 : 0;
339 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
340 <<
"nextMidPoint = (10,5)" << std::endl;
345 Metric::ConstIterator cone2 = mask5711.shrinkPSubMask(itBeg, itEnd, P, QQ, Lmin, Lmax, 1, midPoint, nextMidPoint);
346 trace.
info() <<
"Shrink returns the cone2 "<< *cone2<<
" " <<*(cone2+1)<<std::endl;
347 trace.
info() <<
"MidPoint "<< midPoint<<
" " <<nextMidPoint<<std::endl<<std::endl;
348 nbok += ( midPoint ==
Point(10,-5)) ? 1 : 0;
350 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
351 <<
"midPoint = (10,0)" << std::endl;
352 nbok += ( nextMidPoint ==
Point(10,0)) ? 1 : 0;
354 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
355 <<
"nextMidPoint = (10,5)" << std::endl;
362 Metric::ConstIterator cone3 = mask5711.shrinkP(itBeg, itEnd, P, QQQ, LLmin, LLmax, 1, midPoint, nextMidPoint);
363 trace.
info() <<
"Shrink returns the cone3 "<< *cone3<<
" " <<*(cone3+1)<<std::endl;
364 trace.
info() <<
"MidPoint "<< midPoint<<
" " <<nextMidPoint<<std::endl<<std::endl;
365 nbok += ( midPoint ==
Point(-10,0)) ? 1 : 0;
367 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
368 <<
"midPoint = (-10,0)" << std::endl;
369 nbok += ( nextMidPoint ==
Point(-10,5)) ? 1 : 0;
371 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
372 <<
"nextMidPoint = (-10,5)" << std::endl;
380 Metric::ConstIterator cone4 = mask5711.shrinkP(itBeg, itEnd, P, Qhori, LLLmin, LLLmax, 0, midPoint, nextMidPoint);
381 trace.
info() <<
"Shrink returns the cone3 "<< *cone4<<
" " <<*(cone4+1)<<std::endl;
382 trace.
info() <<
"MidPoint "<< midPoint<<
" " <<nextMidPoint<<std::endl<<std::endl;
383 nbok += ( *cone4 == *cone) ? 1 : 0;
385 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
386 <<
"horiz==vert" << std::endl;
387 nbok += ( midPoint ==
Point(0,10)) ? 1 : 0;
389 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
390 <<
"midPoint = (0,10)" << std::endl;
391 nbok += ( nextMidPoint ==
Point(5,10)) ? 1 : 0;
393 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
394 <<
"nextMidPoint = (5,10)" << std::endl;
396 Point LLLLmin(0,-10);
397 Point LLLLmax(10,-10);
399 Metric::ConstIterator cone5 = mask5711.shrinkP(itBeg, itEnd, P, QQhori, LLLLmin, LLLLmax, 0, midPoint, nextMidPoint);
400 trace.
info() <<
"Shrink returns the cone3 "<< *cone4<<
" " <<*(cone4+1)<<std::endl;
401 trace.
info() <<
"MidPoint "<< midPoint<<
" " <<nextMidPoint<<std::endl;
402 nbok += ( *cone5 == *cone) ? 1 : 0;
404 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
405 <<
"horiz==vert" << std::endl;
406 nbok += ( midPoint ==
Point(0,-10)) ? 1 : 0;
408 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
409 <<
"midPoint = (0,-10)" << std::endl;
410 nbok += ( nextMidPoint ==
Point(5,-10)) ? 1 : 0;
412 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
413 <<
"nextMidPoint = (5,-10)" << std::endl;
421 unsigned int nbok = 0;
427 Metric::Directions dirs5711;
428 Metric::Directions normals5711;
448 Metric mask5711(dirs5711,normals5711);
453 Point Q(1,-2), QQ(1,2);
456 Point midPointP,nextMidPointP;
457 Point midPointQ,nextMidPointQ;
459 Metric::ConstIterator itBeg = mask5711.
begin();
460 Metric::ConstIterator itEnd = mask5711.end();
462 Metric::ConstIterator cone = mask5711.shrinkP(itBeg, itEnd, P, Q, Lmin, Lmax, 1, midPointP, nextMidPointP);
463 trace.
info() <<
" P - Shrink returns the cone "<< *cone<<
" " <<*(cone+1)<<std::endl;
464 trace.
info() <<
" P - MidPoint "<< midPointP<<
" " <<nextMidPointP<<std::endl<<std::endl;
466 Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, Q, P, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
467 trace.
info() <<
" Q - Shrink returns the cone "<< *cone2<<
" " <<*(cone2+1)<<std::endl;
468 trace.
info() <<
" Q - MidPoint "<< midPointQ<<
" " <<nextMidPointQ<<std::endl<<std::endl;
469 trace.
info() <<
"Checking Voro cell" <<std::endl;
471 double dpmidp = mask5711(P,midPointP);
472 double dqmidp = mask5711(Q,midPointP);
473 trace.
info() << ((dpmidp < dqmidp) ?
"MidP closer to P" :
"Mid closer to Q") << std::endl;
474 double dpnextmidp = mask5711(P,nextMidPointP);
475 double dqnextmidp = mask5711(Q,nextMidPointP);
476 trace.
info() << ((dpnextmidp < dqnextmidp) ?
"NextMidP closer to P" :
"Mid closer to Q") << std::endl;
477 nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
479 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
480 <<
" Shrink P contains the Voronoi Edge" << std::endl;
482 double dpmidq = mask5711(P,midPointQ);
483 double dqmidq = mask5711(Q,midPointQ);
484 trace.
info() << ((dpmidq < dqmidq) ?
"MidQ closer to P" :
"Mid closer to Q") << std::endl;
485 double dpnextmidq = mask5711(P,nextMidPointQ);
486 double dqnextmidq = mask5711(Q,nextMidPointQ);
487 trace.
info() << ((dpnextmidq < dqnextmidq) ?
"NextMidP closer to P" :
"Mid closer to Q") << std::endl;
488 nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
490 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
491 <<
" Shrink Q contains the Voronoi Edge" << std::endl;
494 Metric::Abscissa vorocell;
495 Metric::Vector normalP = mask5711.getNormalFromCone(cone);
496 Metric::Vector normalQ = mask5711.getNormalFromCone(cone2);
497 vorocell =
static_cast<Metric::Abscissa
>(floor((
double) (P[1]*normalP[1] - Q[1]*normalQ[1] - (Lmin[0] - P[0])*normalP[0] + (Lmin[0] - Q[0])*normalQ[0]) /(normalP[1] - normalQ[1]) ));
498 Point voro(Lmin[0], vorocell);
500 trace.
emphase() <<
" Lower Voronoi Cell Point "<< voro <<
" absc = "<<vorocell<<std::endl;
501 nbok += ( (voro >= midPointP) && (voro<nextMidPointP)) ? 1 : 0;
503 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
504 <<
" Voro cell in the cone of P" << std::endl;
505 nbok += ( (voro >= midPointQ) && (voro<nextMidPointQ)) ? 1 : 0;
507 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
508 <<
" Voro cell in the cone of Q" << std::endl;
511 nbok += ( (vorocell == mask5711.getLowerVoronoiEdgeAbscissa(P, Q, Lmin, Lmax, 1))) ? 1 : 0;
513 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
514 <<
" Voro cell == getLowerVoronoiEdgeAbscissa " << std::endl;
523 Metric::ConstIterator coneQQ = mask5711.shrinkP(itBeg, itEnd, P, QQ, Lmin, Lmax, 1, midPointP, nextMidPointP);
524 trace.
info() <<
" P - Shrink returns the cone "<< *coneQQ<<
" " <<*(coneQQ+1)<<std::endl;
525 trace.
info() <<
" P - MidPoint "<< midPointP<<
" " <<nextMidPointP<<std::endl;
526 trace.
info() <<
" P - cone distance to P("<< mask5711(midPointP,P)<<
","
527 << mask5711(nextMidPointP,P)<<
")" <<std::endl;
528 trace.
info() <<
" P - cone distance to QQ("<< mask5711(midPointP,QQ)<<
","
529 << mask5711(nextMidPointP,QQ)<<
")" <<std::endl<<std::endl;
531 Metric::ConstIterator coneQQ2 = mask5711.shrinkP(itBeg, itEnd, QQ, P, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
532 trace.
info() <<
" QQ - Shrink returns the cone "<< *coneQQ2<<
" " <<*(coneQQ2+1)<<std::endl;
533 trace.
info() <<
" QQ - MidPoint "<< midPointQ<<
" " <<nextMidPointQ<<std::endl;
534 trace.
info() <<
" QQ - cone distance to QQ("<< mask5711(midPointQ,QQ)<<
","
535 << mask5711(nextMidPointQ,QQ)<<
")" <<std::endl;
536 trace.
info() <<
" QQ - cone distance to P("<< mask5711(midPointQ,P)<<
","
537 << mask5711(nextMidPointQ,P)<<
")" <<std::endl;
538 trace.
info() <<
"Checking Voro cell" <<std::endl<<std::endl;
540 dpmidp = mask5711(P,midPointP);
541 dqmidp = mask5711(QQ,midPointP);
542 trace.
info() << ((dpmidp < dqmidp) ?
"MidP closer to P" :
"MidP closer to QQ") << std::endl;
543 dpnextmidp = mask5711(P,nextMidPointP);
544 dqnextmidp = mask5711(QQ,nextMidPointP);
545 trace.
info() << ((dpnextmidp < dqnextmidp) ?
"NextMidP closer to P" :
"NextMidP closer to QQ") << std::endl;
546 nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
548 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
549 <<
" Shrink P contains the Voronoi Edge" << std::endl;
550 trace.
info()<<
"Distances : ConeP<->P("<<dpmidp<<
","<<dpnextmidp<<
") ConeP<->Q("<<dqmidp<<
","<<dqnextmidp<<
")"<<std::endl;
553 dpmidq = mask5711(P,midPointQ);
554 dqmidq = mask5711(QQ,midPointQ);
555 trace.
info() << ((dpmidq < dqmidq) ?
"MidQ closer to P" :
"MidQ closer to QQ") << std::endl;
556 dpnextmidq = mask5711(P,nextMidPointQ);
557 dqnextmidq = mask5711(QQ,nextMidPointQ);
558 trace.
info() << ((dpnextmidq < dqnextmidq) ?
"NextMidQ closer to P" :
"NextMidQ closer to QQ") << std::endl;
559 nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
561 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
562 <<
" Shrink QQ contains the Voronoi Edge" << std::endl;
563 trace.
info()<<
"Distances : ConeQ<->P("<<dpmidq<<
","<<dpnextmidq<<
") ConeQ<->QQ("<<dqmidq<<
","<<dqnextmidq<<
")"<<std::endl;
574 unsigned int nbok = 0;
580 Metric::Directions dirs5711;
581 Metric::Directions normals5711;
601 Metric mask5711(dirs5711,normals5711);
606 Point Q(-2,1), QQ(2,1);
609 Point midPointP,nextMidPointP;
610 Point midPointQ,nextMidPointQ;
612 Metric::ConstIterator itBeg = mask5711.
begin();
613 Metric::ConstIterator itEnd = mask5711.end();
615 Metric::ConstIterator cone = mask5711.shrinkP(itBeg, itEnd, P, Q, Lmin, Lmax, 0, midPointP, nextMidPointP);
616 trace.
info() <<
" P - Shrink returns the cone "<< *cone<<
" " <<*(cone+1)<<std::endl;
617 trace.
info() <<
" P - MidPoint "<< midPointP<<
" " <<nextMidPointP<<std::endl<<std::endl;
619 Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, Q, P, Lmin, Lmax, 0, midPointQ, nextMidPointQ);
620 trace.
info() <<
" Q - Shrink returns the cone "<< *cone2<<
" " <<*(cone2+1)<<std::endl;
621 trace.
info() <<
" Q - MidPoint "<< midPointQ<<
" " <<nextMidPointQ<<std::endl<<std::endl;
622 trace.
info() <<
"Checking Voro cell" <<std::endl;
625 double dpmidp = mask5711(P,midPointP);
626 double dqmidp = mask5711(Q,midPointP);
627 trace.
info() << ((dpmidp < dqmidp) ?
"MidP closer to P" :
"Mid closer to Q") << std::endl;
628 double dpnextmidp = mask5711(P,nextMidPointP);
629 double dqnextmidp = mask5711(Q,nextMidPointP);
630 trace.
info() << ((dpnextmidp < dqnextmidp) ?
"NextMidP closer to P" :
"Mid closer to Q") << std::endl;
631 nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
633 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
634 <<
" Shrink P contains the Voronoi Edge" << std::endl;
637 double dpmidq = mask5711(P,midPointQ);
638 double dqmidq = mask5711(Q,midPointQ);
639 trace.
info() << ((dpmidq < dqmidq) ?
"MidQ closer to P" :
"Mid closer to Q") << std::endl;
640 double dpnextmidq = mask5711(P,nextMidPointQ);
641 double dqnextmidq = mask5711(Q,nextMidPointQ);
642 trace.
info() << ((dpnextmidq < dqnextmidq) ?
"NextMidP closer to P" :
"Mid closer to Q") << std::endl;
643 nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
645 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
646 <<
" Shrink Q contains the Voronoi Edge" << std::endl;
651 Metric::ConstIterator coneQQ = mask5711.shrinkP(itBeg, itEnd, P, QQ, Lmin, Lmax, 0, midPointP, nextMidPointP);
652 trace.
info() <<
" P - Shrink returns the cone "<< *coneQQ<<
" " <<*(coneQQ+1)<<std::endl;
653 trace.
info() <<
" P - MidPoint "<< midPointP<<
" " <<nextMidPointP<<std::endl;
654 trace.
info() <<
" P - cone distance to P("<< mask5711(midPointP,P)<<
","
655 << mask5711(nextMidPointP,P)<<
")" <<std::endl;
656 trace.
info() <<
" P - cone distance to QQ("<< mask5711(midPointP,QQ)<<
","
657 << mask5711(nextMidPointP,QQ)<<
")" <<std::endl<<std::endl;
659 Metric::ConstIterator coneQQ2 = mask5711.shrinkP(itBeg, itEnd, QQ, P, Lmin, Lmax, 0, midPointQ, nextMidPointQ);
660 trace.
info() <<
" QQ - Shrink returns the cone "<< *coneQQ2<<
" " <<*(coneQQ2+1)<<std::endl;
661 trace.
info() <<
" QQ - MidPoint "<< midPointQ<<
" " <<nextMidPointQ<<std::endl;
662 trace.
info() <<
" QQ - cone distance to QQ("<< mask5711(midPointQ,QQ)<<
","
663 << mask5711(nextMidPointQ,QQ)<<
")" <<std::endl;
664 trace.
info() <<
" QQ - cone distance to P("<< mask5711(midPointQ,P)<<
","
665 << mask5711(nextMidPointQ,P)<<
")" <<std::endl;
666 trace.
info() <<
"Checking Voro cell" <<std::endl<<std::endl;
668 dpmidp = mask5711(P,midPointP);
669 dqmidp = mask5711(QQ,midPointP);
670 trace.
info() << ((dpmidp < dqmidp) ?
"MidP closer to P" :
"MidP closer to QQ") << std::endl;
671 dpnextmidp = mask5711(P,nextMidPointP);
672 dqnextmidp = mask5711(QQ,nextMidPointP);
673 trace.
info() << ((dpnextmidp < dqnextmidp) ?
"NextMidP closer to P" :
"NextMidP closer to QQ") << std::endl;
674 nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
676 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
677 <<
" Shrink P contains the Voronoi Edge" << std::endl;
678 trace.
info()<<
"Distances : ConeP<->P("<<dpmidp<<
","<<dpnextmidp<<
") ConeP<->Q("<<dqmidp<<
","<<dqnextmidp<<
")"<<std::endl;
681 dpmidq = mask5711(P,midPointQ);
682 dqmidq = mask5711(QQ,midPointQ);
683 trace.
info() << ((dpmidq < dqmidq) ?
"MidQ closer to P" :
"MidQ closer to QQ") << std::endl;
684 dpnextmidq = mask5711(P,nextMidPointQ);
685 dqnextmidq = mask5711(QQ,nextMidPointQ);
686 trace.
info() << ((dpnextmidq < dqnextmidq) ?
"NextMidQ closer to P" :
"NextMidQ closer to QQ") << std::endl;
687 nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
689 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
690 <<
" Shrink QQ contains the Voronoi Edge" << std::endl;
691 trace.
info()<<
"Distances : ConeQ<->P("<<dpmidq<<
","<<dpnextmidq<<
") ConeQ<->QQ("<<dqmidq<<
","<<dqnextmidq<<
")"<<std::endl;
703 unsigned int nbok = 0;
709 Metric::Directions dirs5711;
710 Metric::Directions normals5711;
730 Metric mask5711(dirs5711,normals5711);
754 nbok += ( mask5711.hiddenBy(U,V, W, Lmin, Lmax, 1) == false ) ? 1 : 0;
756 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
757 <<
" H(U,V,W) is false" << std::endl;
759 nbok += ( mask5711.hiddenBy(U,VV, W, Lmin, Lmax, 1) == true ) ? 1 : 0;
761 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
762 <<
" H(U,VV,W) is true" << std::endl;
764 nbok += ( mask5711.hiddenBy(Usym,Vsym, Wsym, Lmin, Lmax, 1) == false ) ? 1 : 0;
766 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
767 <<
" H(Usym,Vsym,Wsym) is false" << std::endl;
769 nbok += ( mask5711.hiddenBy(Usym,VVsym, Wsym, Lmin, Lmax, 1) == true ) ? 1 : 0;
771 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
772 <<
" H(Usym,VVsym,Wsym) is true" << std::endl;
774 nbok += ( mask5711.hiddenBy(UH,VH, WH, LminH, LmaxH, 0) == false ) ? 1 : 0;
776 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
777 <<
" H(UH,VH,WH) is false" << std::endl;
779 nbok += ( mask5711.hiddenBy(UH,VVH, WH, LminH, LmaxH, 0) == true ) ? 1 : 0;
781 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
782 <<
" H(UH,VVH,WH) is true" << std::endl;
792 unsigned int nbok = 0;
797 Metric::Directions dirs5711;
798 Metric::Directions normals5711;
818 Metric mask5711(dirs5711,normals5711);
828 Point midPointP,nextMidPointP;
829 Point midPointQ,nextMidPointQ;
831 Metric::ConstIterator itBeg = mask5711.
begin();
832 Metric::ConstIterator itEnd = mask5711.end();
834 Metric::ConstIterator cone = mask5711.shrinkP(itBeg, itEnd, P, Q, Lmin, Lmax, 1, midPointP, nextMidPointP);
835 trace.
info() <<
" P - Shrink returns the cone "<< *cone<<
" " <<*(cone+1)<<std::endl;
836 trace.
info() <<
" P - MidPoint "<< midPointP<<
" " <<nextMidPointP<<std::endl<<std::endl;
839 Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, Q, P, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
840 Metric::ConstIterator cone3 = mask5711.shrinkP(itBeg, itEnd, Q, Pup, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
841 trace.
info() <<
" Q - P Shrink returns the cone "<< *cone2<<
" " <<*(cone2+1)<<std::endl;
842 trace.
info() <<
" Q - Pup Shrink returns the cone "<< *cone3<<
" " <<*(cone3+1)<<std::endl;
843 trace.
info() <<
" Q - MidPoint "<< midPointQ<<
" " <<nextMidPointQ<<std::endl<<std::endl;
844 nbok += ( cone2 == itBeg ) ? 1 : 0;
846 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
847 <<
" P's cone returns itBegin" << std::endl;
855 Metric::Abscissa pos = mask5711.getLowerVoronoiEdgeAbscissa(PP, QQ, Lmin, Lmax, 1);
856 trace.
warning() <<
" Abscissa of voro call (PP,QQ) = "<< pos <<std::endl;
857 nbok += ( pos < 5 ) ? 1 : 0;
859 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
860 <<
" PP-QQ cell is lesser than 5" << std::endl;
863 Metric::Abscissa pos2 = mask5711.getLowerVoronoiEdgeAbscissa(PP, QQup, Lmin, Lmax, 1);
864 trace.
warning() <<
" Abscissa of voro call (PP,QQup) = "<< pos2 <<std::endl;
865 nbok += ( pos2 > 5 ) ? 1 : 0;
867 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
868 <<
" PP-QQ cell is greater than 5" << std::endl;
871 Metric::ConstIterator conebis = mask5711.shrinkP(itBeg, itEnd, P, Pb, Lmin, Lmax, 1, midPointP, nextMidPointP);
872 Metric::Abscissa posbis = mask5711.getLowerVoronoiEdgeAbscissa(P, Pb, Lmin, Lmax, 1);
873 trace.
info() <<
" Pbis - Shrink returns the cone "<< *conebis<<
" " <<*(conebis+1)<<std::endl;
874 trace.
info() <<
" Pbis - Shrink returns the cone "<< *conebis<<
" " <<*(conebis+1)<<std::endl;
875 trace.
info() <<
" Pbis - Pos "<< posbis<<std::endl;
884 unsigned int nbok = 0;
889 Metric::Directions dirs5711;
890 Metric::Directions normals5711;
910 Metric mask5711(dirs5711,normals5711);
919 Point midPointP,nextMidPointP;
920 Point midPointQ,nextMidPointQ;
922 Metric::ConstIterator itBeg = mask5711.
begin();
923 Metric::ConstIterator itEnd = mask5711.end();
926 Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, V, W, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
927 Metric::ConstIterator cone3 = mask5711.shrinkP(itBeg, itEnd, W, V, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
929 trace.
info() <<
" V - W Shrink returns the cone "<< *cone2<<
" " <<*(cone2+1)<<std::endl;
930 trace.
info() <<
" W - V Shrink returns the cone "<< *cone3<<
" " <<*(cone3+1)<<std::endl;
931 trace.
info() <<
" Q - MidPoint "<< midPointQ<<
" " <<nextMidPointQ<<std::endl<<std::endl;
933 Metric::Abscissa pos = mask5711.getLowerVoronoiEdgeAbscissa(V, W, Lmin, Lmax, 1);
934 trace.
info() <<
" Pos = "<<pos<<std::endl;
938 nbok += ( mask5711.hiddenBy(U,V, W, Lmin, Lmax, 1) == false ) ? 1 : 0;
940 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
941 <<
" H(U,V,W) is false" << std::endl;
954int main(
int argc,
char** argv )
958 for (
int i = 0; i < argc; ++i )
969 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << std::endl;
void beginBlock(const std::string &keyword="")
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Vector getNormalFromCone(ConstIterator aCone) const
Vector canonicalRay(const Vector &aRay) const
ConstIterator getCone(const Vector &aDirection, ConstIterator aBegin, ConstIterator aEnd) const
std::vector< Vector > Directions
Container for set of directions.
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: defines the concept of metric spaces.
Aim: defines the concept of separable metrics.
bool testDoubleOnSegment()
bool testDoubleShrinkHorizontal()
bool checkCMetricConcept()