DGtal  0.9.3
Functions
testChamferDT.cpp File Reference
#include <iostream>
#include <set>
#include <algorithm>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/volumes/distance/ChamferNorm2D.h"
#include "DGtal/geometry/volumes/distance/CMetricSpace.h"
#include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
Include dependency graph for testChamferDT.cpp:

Go to the source code of this file.

Functions

bool checkCMetricConcept ()
 
bool testChamferSimple ()
 
bool testBasicMasks ()
 
bool testIntersection ()
 
bool testShrink ()
 
bool testDoubleShrink ()
 
bool testDoubleShrinkHorizontal ()
 
bool testHiddenBy ()
 
bool testDoubleOnSegment ()
 
bool testSpecialCase ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2013/12/16

Functions for testing class ChamferDT.

This file is part of the DGtal library.

Definition in file testChamferDT.cpp.

Function Documentation

◆ checkCMetricConcept()

bool checkCMetricConcept ( )

Definition at line 52 of file testChamferDT.cpp.

Referenced by main().

53 {
56  return true;
57 }
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
Aim: defines the concept of separable metrics.
Aim: defines the concept of metric spaces.
Definition: CMetricSpace.h:124

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 955 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), checkCMetricConcept(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testBasicMasks(), testChamferSimple(), testDoubleOnSegment(), testDoubleShrink(), testDoubleShrinkHorizontal(), testHiddenBy(), testIntersection(), testShrink(), testSpecialCase(), and DGtal::trace.

956 {
957  trace.beginBlock ( "Testing class ChamferDT" );
958  trace.info() << "Args:";
959  for ( int i = 0; i < argc; ++i )
960  trace.info() << " " << argv[ i ];
961  trace.info() << endl;
962 
964  && testShrink()
965  && testDoubleShrink()
967  && testHiddenBy()
969  && testSpecialCase(); // && ... other tests
970  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
971  trace.endBlock();
972  return res ? 0 : 1;
973 }
void beginBlock(const std::string &keyword="")
bool testShrink()
bool testDoubleShrinkHorizontal()
Trace trace
Definition: Common.h:137
double endBlock()
bool testDoubleOnSegment()
bool testDoubleShrink()
std::ostream & emphase()
bool testIntersection()
std::ostream & info()
bool testBasicMasks()
bool checkCMetricConcept()
bool testSpecialCase()
bool testChamferSimple()
bool testHiddenBy()

◆ testBasicMasks()

bool testBasicMasks ( )

Definition at line 180 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::experimental::ChamferNorm2D< TSpace >::getCone(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

181 {
182  unsigned int nbok = 0;
183  unsigned int nb = 0;
184  trace.beginBlock ( "Testing basic chamfer masks...");
185 
188 
189  //3-4 mask
190  dirs34.push_back(Z2i::Vector(0,-1));
191  dirs34.push_back(Z2i::Vector(1,-1));
192  dirs34.push_back(Z2i::Vector(1,0));
193  dirs34.push_back(Z2i::Vector(1,1));
194  normals34.push_back(Z2i::Vector(1,-3));
195  normals34.push_back(Z2i::Vector(3,-1));
196  normals34.push_back(Z2i::Vector(3,1));
197  normals34.push_back(Z2i::Vector(1,3));
198 
199  experimental::ChamferNorm2D<Space> mask34(dirs34,normals34);
200 
201  Point orig(0,0);
202  Point p(3,0);
203  trace.info() <<"Distance "<<p<<" = "<< mask34(orig,p)<<std::endl;;
204  trace.info() <<"Cone "<< *(mask34.getCone(p))<< " "<< *(mask34.getCone(p)+1)<< std::endl;
205 
206  Point q(3,1);
207  trace.info() <<"Distance "<<q<<" = "<< mask34(orig,q)<<std::endl;;
208  trace.info() <<"Cone "<< *(mask34.getCone(q))<< " "<< *(mask34.getCone(q)+1)<< std::endl;
209 
210 
211  trace.endBlock();
212  return nbok == nb;
213 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
std::vector< Vector > Directions
Container for set of directions.
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()

◆ testChamferSimple()

bool testChamferSimple ( )

Definition at line 60 of file testChamferDT.cpp.

References DGtal::experimental::ChamferNorm2D< TSpace >::begin(), DGtal::Trace::beginBlock(), DGtal::experimental::ChamferNorm2D< TSpace >::canonicalRay(), DGtal::experimental::ChamferNorm2D< TSpace >::end(), DGtal::Trace::endBlock(), DGtal::experimental::ChamferNorm2D< TSpace >::getCone(), DGtal::experimental::ChamferNorm2D< TSpace >::getNormalFromCone(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

61 {
62  unsigned int nbok = 0;
63  unsigned int nb = 0;
64  trace.beginBlock ( "Testing simple chamfer mask localization...");
65 
68 
71 
72  //3-4 mask
73  dirs34.push_back(Z2i::Vector(0,-1));
74  dirs34.push_back(Z2i::Vector(1,-1));
75  dirs34.push_back(Z2i::Vector(1,0));
76  dirs34.push_back(Z2i::Vector(1,1));
77  normals34.push_back(Z2i::Vector(1,-3));
78  normals34.push_back(Z2i::Vector(3,-1));
79  normals34.push_back(Z2i::Vector(3,1));
80  normals34.push_back(Z2i::Vector(1,3));
81 
82  experimental::ChamferNorm2D<Space> aMask(dirs34,normals34);
83 
84 
85 
86 
87  //Testing cone discovery
88  Vector d(101,100);
89  trace.info() << "Direction "<<d<<std::endl;
90  trace.info() << " -> cone "<< *aMask.getCone(d)
91  << " -- " << *(aMask.getCone(d)+1) <<std::endl;
92  nbok += ( lthan(d, *(aMask.getCone(d)+1))) ? 1 : 0;
93  nb++;
94  trace.info() << "(" << nbok << "/" << nb << ") "
95  << "(d < cone+1) returns true" << std::endl;
96  nbok += (lqthan(*(aMask.getCone(d)),d)) ? 1 : 0;
97  nb++;
98  trace.info() << "(" << nbok << "/" << nb << ") "
99  << "(cone <= d) returns true" << std::endl;
100 
101  //testing canonical
102  Vector d3(-101,100);
103  trace.info() << "Direction "<<d3<<std::endl;
104  trace.info() << " -> cone "<< *aMask.getCone(d3)
105  << " -- " << *(aMask.getCone(d3)+1) <<std::endl;
106  nbok += ( lthan(aMask.canonicalRay(d3), *(aMask.getCone(d3)+1))) ? 1 : 0;
107  nb++;
108  trace.info() << "(" << nbok << "/" << nb << ") "
109  << "(d < cone+1) returns true" << std::endl;
110  nbok += (lqthan(*(aMask.getCone(d3)),aMask.canonicalRay(d3))) ? 1 : 0;
111  nb++;
112  trace.info() << "(" << nbok << "/" << nb << ") "
113  << "(cone <= d) returns true" << std::endl;
114 
115 
116  //aligned
117  Vector d2(8,8);
118  trace.info() << "Direction "<<d2<<std::endl;
119  trace.info() << " -> cone "<< *aMask.getCone(d2)
120  << " -- " << *(aMask.getCone(d2)+1) <<std::endl;
121  if ((aMask.getCone(d2)+1) != aMask.end())
122  {
123  nbok += ( lthan(d2, *(aMask.getCone(d2)+1))) ? 1 : 0;
124  nb++;
125  trace.info() << "(" << nbok << "/" << nb << ") "
126  << "(d2 < cone+1) returns true" << std::endl;
127  }
128  nbok += (lqthan(*(aMask.getCone(d2)),d2) ) ? 1 : 0;
129  nb++;
130  trace.info() << "(" << nbok << "/" << nb << ") "
131  << "(cone <= d2) returns true" << std::endl;
132 
133 
134  //Distance test
135  Point p(1,1), q(102,101);
136  trace.info()<< "Distance between "<<p<<" and "<< q << " = "<< aMask(p,q)<<std::endl;
137  trace.info()<< "Distance between "<<q<<" and "<< p << " = "<< aMask(q,p)<<std::endl;
138  nbok += ( aMask(p,q) == aMask(q,p)) ? 1 : 0;
139  nb++;
140  trace.info() << "(" << nbok << "/" << nb << ") "
141  << "d(p,q)==d(q,p)" << std::endl;
142 
143 
144  //Testing Last cone:
145  Vector d4(1,10);
146  trace.info() << "Direction "<<d4<<std::endl;
147  trace.info() << " -> cone "<< *aMask.getCone(d4)
148  << " -- " << *(aMask.getCone(d4)+1) <<std::endl;
149  nbok += ( *aMask.getCone(d4) == Point(1,1)) ? 1 : 0;
150  nb++;
151  trace.info() << "(" << nbok << "/" << nb << ") "
152  << "Last cone 1" << std::endl;
153  trace.info() << " -> normal "<< aMask.getNormalFromCone(aMask.getCone(d4)) <<std::endl;;
154  nbok += (aMask.getNormalFromCone(aMask.getCone(d4)) == Point(1,3)) ? 1 : 0;
155  nb++;
156  trace.info() << "(" << nbok << "/" << nb << ") "
157  << "Last cone 2" << std::endl;
158 
159  //Testing Last cone:
160  Vector d5(0,10);
161  trace.info() << "Direction "<<d5<<std::endl;
162  trace.info() << " -> cone "<< *aMask.getCone(d5)
163  << " -- " << *(aMask.getCone(d5)+1) <<std::endl;
164  nbok += ( *aMask.getCone(d5) == Point(1,1)) ? 1 : 0;
165  nb++;
166  trace.info() << "(" << nbok << "/" << nb << ") "
167  << "Last cone 1" << std::endl;
168  trace.info() << " -> normal "<< aMask.getNormalFromCone(aMask.getCone(d5)) <<std::endl;;
169  nbok += (aMask.getNormalFromCone(aMask.getCone(d5)) == Point(1,3)) ? 1 : 0;
170  nb++;
171  trace.info() << "(" << nbok << "/" << nb << ") "
172  << "Last cone 2" << std::endl;
173 
174  trace.info() << " upper="<<*std::upper_bound(aMask.begin(), aMask.end(), d4, lthan)<<std::endl;
175 
176  trace.endBlock();
177  return nbok == nb;
178 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
std::vector< Vector > Directions
Container for set of directions.
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
FreemanChain< int >::Vector Vector

◆ testDoubleOnSegment()

bool testDoubleOnSegment ( )

Definition at line 791 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::trace, and DGtal::Trace::warning().

Referenced by main().

792 {
793  unsigned int nbok = 0;
794  unsigned int nb = 0;
795 
796  //5-7-11 metic
798  Metric::Directions dirs5711;
799  Metric::Directions normals5711;
800  //5-7-11 mask
801  dirs5711.push_back(Z2i::Vector(0,-1));
802  dirs5711.push_back(Z2i::Vector(1,-2));
803  dirs5711.push_back(Z2i::Vector(1,-1));
804  dirs5711.push_back(Z2i::Vector(2,-1));
805  dirs5711.push_back(Z2i::Vector(1,0));
806  dirs5711.push_back(Z2i::Vector(2,1));
807  dirs5711.push_back(Z2i::Vector(1,1));
808  dirs5711.push_back(Z2i::Vector(1,2));
809 
810  normals5711.push_back(Z2i::Vector(1,-5));
811  normals5711.push_back(Z2i::Vector(3,-4));
812  normals5711.push_back(Z2i::Vector(4,-3));
813  normals5711.push_back(Z2i::Vector(5,-1));
814  normals5711.push_back(Z2i::Vector(5,1));
815  normals5711.push_back(Z2i::Vector(4,3));
816  normals5711.push_back(Z2i::Vector(3,4));
817  normals5711.push_back(Z2i::Vector(1,5));
818 
819  Metric mask5711(dirs5711,normals5711);
820 
821  trace.beginBlock ( "Testing when Q or P belongs to the segment...");
822  //Setting:
823  Point P(0,0);
824  Point Pb(0,-1);
825  Point Pup(0,10);
826  Point Q(10,5);
827  Point Lmin(10,-10);
828  Point Lmax(10,10);
829  Point midPointP,nextMidPointP;
830  Point midPointQ,nextMidPointQ;
831 
832  Metric::ConstIterator itBeg = mask5711.begin();
833  Metric::ConstIterator itEnd = mask5711.end();
834 
835  Metric::ConstIterator cone = mask5711.shrinkP(itBeg, itEnd, P, Q, Lmin, Lmax, 1, midPointP, nextMidPointP);
836  trace.info() <<" P - Shrink returns the cone "<< *cone<<" " <<*(cone+1)<<std::endl;
837  trace.info() <<" P - MidPoint "<< midPointP<<" " <<nextMidPointP<<std::endl<<std::endl;
838 
839 
840  Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, Q, P, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
841  Metric::ConstIterator cone3 = mask5711.shrinkP(itBeg, itEnd, Q, Pup, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
842  trace.info() <<" Q - P Shrink returns the cone "<< *cone2<<" " <<*(cone2+1)<<std::endl;
843  trace.info() <<" Q - Pup Shrink returns the cone "<< *cone3<<" " <<*(cone3+1)<<std::endl;
844  trace.info() <<" Q - MidPoint "<< midPointQ<<" " <<nextMidPointQ<<std::endl<<std::endl;
845  nbok += ( cone2 == itBeg ) ? 1 : 0;
846  nb++;
847  trace.info() << "(" << nbok << "/" << nb << ") "
848  << " P's cone returns itBegin" << std::endl;
849 
850  trace.endBlock();
851 
852  Point PP(10,5);
853  Point QQ(3,4);
854  Point QQup(3,8);
855 
856  Metric::Abscissa pos = mask5711.getLowerVoronoiEdgeAbscissa(PP, QQ, Lmin, Lmax, 1);
857  trace.warning() <<" Abscissa of voro call (PP,QQ) = "<< pos <<std::endl;
858  nbok += ( pos < 5 ) ? 1 : 0;
859  nb++;
860  trace.info() << "(" << nbok << "/" << nb << ") "
861  << " PP-QQ cell is lesser than 5" << std::endl;
862 
863 
864  Metric::Abscissa pos2 = mask5711.getLowerVoronoiEdgeAbscissa(PP, QQup, Lmin, Lmax, 1);
865  trace.warning() <<" Abscissa of voro call (PP,QQup) = "<< pos2 <<std::endl;
866  nbok += ( pos2 > 5 ) ? 1 : 0;
867  nb++;
868  trace.info() << "(" << nbok << "/" << nb << ") "
869  << " PP-QQ cell is greater than 5" << std::endl;
870 
871 
872  Metric::ConstIterator conebis = mask5711.shrinkP(itBeg, itEnd, P, Pb, Lmin, Lmax, 1, midPointP, nextMidPointP);
873  Metric::Abscissa posbis = mask5711.getLowerVoronoiEdgeAbscissa(P, Pb, Lmin, Lmax, 1);
874  trace.info() <<" Pbis - Shrink returns the cone "<< *conebis<<" " <<*(conebis+1)<<std::endl;
875  trace.info() <<" Pbis - Shrink returns the cone "<< *conebis<<" " <<*(conebis+1)<<std::endl;
876  trace.info() <<" Pbis - Pos "<< posbis<<std::endl;
877 
878 
879  return nbok == nb;
880 }
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & warning()
std::ostream & info()

◆ testDoubleShrink()

bool testDoubleShrink ( )

Definition at line 420 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

421 {
422  unsigned int nbok = 0;
423  unsigned int nb = 0;
424  trace.beginBlock ( "Testing Double Shrinking...");
425 
426  //5-7-11 metic
428  Metric::Directions dirs5711;
429  Metric::Directions normals5711;
430  //5-7-11 mask
431  dirs5711.push_back(Z2i::Vector(0,-1));
432  dirs5711.push_back(Z2i::Vector(1,-2));
433  dirs5711.push_back(Z2i::Vector(1,-1));
434  dirs5711.push_back(Z2i::Vector(2,-1));
435  dirs5711.push_back(Z2i::Vector(1,0));
436  dirs5711.push_back(Z2i::Vector(2,1));
437  dirs5711.push_back(Z2i::Vector(1,1));
438  dirs5711.push_back(Z2i::Vector(1,2));
439 
440  normals5711.push_back(Z2i::Vector(1,-5));
441  normals5711.push_back(Z2i::Vector(3,-4));
442  normals5711.push_back(Z2i::Vector(4,-3));
443  normals5711.push_back(Z2i::Vector(5,-1));
444  normals5711.push_back(Z2i::Vector(5,1));
445  normals5711.push_back(Z2i::Vector(4,3));
446  normals5711.push_back(Z2i::Vector(3,4));
447  normals5711.push_back(Z2i::Vector(1,5));
448 
449  Metric mask5711(dirs5711,normals5711);
450 
451  //Setting:
452  trace.beginBlock("Tessting shrinking using Q");
453  Point P(0,0);
454  Point Q(1,-2), QQ(1,2);
455  Point Lmin(10,-10);
456  Point Lmax(10,10);
457  Point midPointP,nextMidPointP;
458  Point midPointQ,nextMidPointQ;
459 
460  Metric::ConstIterator itBeg = mask5711.begin();
461  Metric::ConstIterator itEnd = mask5711.end();
462 
463  Metric::ConstIterator cone = mask5711.shrinkP(itBeg, itEnd, P, Q, Lmin, Lmax, 1, midPointP, nextMidPointP);
464  trace.info() <<" P - Shrink returns the cone "<< *cone<<" " <<*(cone+1)<<std::endl;
465  trace.info() <<" P - MidPoint "<< midPointP<<" " <<nextMidPointP<<std::endl<<std::endl;
466 
467  Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, Q, P, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
468  trace.info() <<" Q - Shrink returns the cone "<< *cone2<<" " <<*(cone2+1)<<std::endl;
469  trace.info() <<" Q - MidPoint "<< midPointQ<<" " <<nextMidPointQ<<std::endl<<std::endl;
470  trace.info() << "Checking Voro cell" <<std::endl;
471 
472  double dpmidp = mask5711(P,midPointP);
473  double dqmidp = mask5711(Q,midPointP);
474  trace.info() << ((dpmidp < dqmidp) ? "MidP closer to P" : "Mid closer to Q") << std::endl;
475  double dpnextmidp = mask5711(P,nextMidPointP);
476  double dqnextmidp = mask5711(Q,nextMidPointP);
477  trace.info() << ((dpnextmidp < dqnextmidp) ? "NextMidP closer to P" : "Mid closer to Q") << std::endl;
478  nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
479  nb++;
480  trace.info() << "(" << nbok << "/" << nb << ") "
481  << " Shrink P contains the Voronoi Edge" << std::endl;
482 
483  double dpmidq = mask5711(P,midPointQ);
484  double dqmidq = mask5711(Q,midPointQ);
485  trace.info() << ((dpmidq < dqmidq) ? "MidQ closer to P" : "Mid closer to Q") << std::endl;
486  double dpnextmidq = mask5711(P,nextMidPointQ);
487  double dqnextmidq = mask5711(Q,nextMidPointQ);
488  trace.info() << ((dpnextmidq < dqnextmidq) ? "NextMidP closer to P" : "Mid closer to Q") << std::endl;
489  nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
490  nb++;
491  trace.info() << "(" << nbok << "/" << nb << ") "
492  << " Shrink Q contains the Voronoi Edge" << std::endl;
493 
494  trace.beginBlock("Computing the lower");
495  Metric::Abscissa vorocell;
496  Metric::Vector normalP = mask5711.getNormalFromCone(cone);
497  Metric::Vector normalQ = mask5711.getNormalFromCone(cone2);
498  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]) ));
499  Point voro(Lmin[0], vorocell);
500 
501  trace.emphase() << " Lower Voronoi Cell Point "<< voro << " absc = "<<vorocell<<std::endl;
502  nbok += ( (voro >= midPointP) && (voro<nextMidPointP)) ? 1 : 0;
503  nb++;
504  trace.info() << "(" << nbok << "/" << nb << ") "
505  << " Voro cell in the cone of P" << std::endl;
506  nbok += ( (voro >= midPointQ) && (voro<nextMidPointQ)) ? 1 : 0;
507  nb++;
508  trace.info() << "(" << nbok << "/" << nb << ") "
509  << " Voro cell in the cone of Q" << std::endl;
510 
511 
512  nbok += ( (vorocell == mask5711.getLowerVoronoiEdgeAbscissa(P, Q, Lmin, Lmax, 1))) ? 1 : 0;
513  nb++;
514  trace.info() << "(" << nbok << "/" << nb << ") "
515  << " Voro cell == getLowerVoronoiEdgeAbscissa " << std::endl;
516 
517  trace.endBlock();
518 
519  trace.endBlock();
520 
521 
522  //Setting2
523  trace.beginBlock("Testing double shrinking on QQ");
524  Metric::ConstIterator coneQQ = mask5711.shrinkP(itBeg, itEnd, P, QQ, Lmin, Lmax, 1, midPointP, nextMidPointP);
525  trace.info() <<" P - Shrink returns the cone "<< *coneQQ<<" " <<*(coneQQ+1)<<std::endl;
526  trace.info() <<" P - MidPoint "<< midPointP<<" " <<nextMidPointP<<std::endl;
527  trace.info() <<" P - cone distance to P("<< mask5711(midPointP,P)<<","
528  << mask5711(nextMidPointP,P)<<")" <<std::endl;
529  trace.info() <<" P - cone distance to QQ("<< mask5711(midPointP,QQ)<<","
530  << mask5711(nextMidPointP,QQ)<<")" <<std::endl<<std::endl;
531 
532  Metric::ConstIterator coneQQ2 = mask5711.shrinkP(itBeg, itEnd, QQ, P, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
533  trace.info() <<" QQ - Shrink returns the cone "<< *coneQQ2<<" " <<*(coneQQ2+1)<<std::endl;
534  trace.info() <<" QQ - MidPoint "<< midPointQ<<" " <<nextMidPointQ<<std::endl;
535  trace.info() <<" QQ - cone distance to QQ("<< mask5711(midPointQ,QQ)<<","
536  << mask5711(nextMidPointQ,QQ)<<")" <<std::endl;
537  trace.info() <<" QQ - cone distance to P("<< mask5711(midPointQ,P)<<","
538  << mask5711(nextMidPointQ,P)<<")" <<std::endl;
539  trace.info() << "Checking Voro cell" <<std::endl<<std::endl;
540 
541  dpmidp = mask5711(P,midPointP);
542  dqmidp = mask5711(QQ,midPointP);
543  trace.info() << ((dpmidp < dqmidp) ? "MidP closer to P" : "MidP closer to QQ") << std::endl;
544  dpnextmidp = mask5711(P,nextMidPointP);
545  dqnextmidp = mask5711(QQ,nextMidPointP);
546  trace.info() << ((dpnextmidp < dqnextmidp) ? "NextMidP closer to P" : "NextMidP closer to QQ") << std::endl;
547  nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
548  nb++;
549  trace.info() << "(" << nbok << "/" << nb << ") "
550  << " Shrink P contains the Voronoi Edge" << std::endl;
551  trace.info()<< "Distances : ConeP<->P("<<dpmidp<<","<<dpnextmidp<<") ConeP<->Q("<<dqmidp<<","<<dqnextmidp<<")"<<std::endl;
552 
553 
554  dpmidq = mask5711(P,midPointQ);
555  dqmidq = mask5711(QQ,midPointQ);
556  trace.info() << ((dpmidq < dqmidq) ? "MidQ closer to P" : "MidQ closer to QQ") << std::endl;
557  dpnextmidq = mask5711(P,nextMidPointQ);
558  dqnextmidq = mask5711(QQ,nextMidPointQ);
559  trace.info() << ((dpnextmidq < dqnextmidq) ? "NextMidQ closer to P" : "NextMidQ closer to QQ") << std::endl;
560  nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
561  nb++;
562  trace.info() << "(" << nbok << "/" << nb << ") "
563  << " Shrink QQ contains the Voronoi Edge" << std::endl;
564  trace.info()<< "Distances : ConeQ<->P("<<dpmidq<<","<<dpnextmidq<<") ConeQ<->QQ("<<dqmidq<<","<<dqnextmidq<<")"<<std::endl;
565  trace.endBlock();
566 
567  trace.endBlock();
568 
569  return nbok == nb;
570 }
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
std::ostream & emphase()
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
FreemanChain< int >::Vector Vector

◆ testDoubleShrinkHorizontal()

bool testDoubleShrinkHorizontal ( )

Definition at line 573 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

574 {
575  unsigned int nbok = 0;
576  unsigned int nb = 0;
577  trace.beginBlock ( "Testing Double Shrinking Horizontal...");
578 
579  //5-7-11 metic
581  Metric::Directions dirs5711;
582  Metric::Directions normals5711;
583  //5-7-11 mask
584  dirs5711.push_back(Z2i::Vector(0,-1));
585  dirs5711.push_back(Z2i::Vector(1,-2));
586  dirs5711.push_back(Z2i::Vector(1,-1));
587  dirs5711.push_back(Z2i::Vector(2,-1));
588  dirs5711.push_back(Z2i::Vector(1,0));
589  dirs5711.push_back(Z2i::Vector(2,1));
590  dirs5711.push_back(Z2i::Vector(1,1));
591  dirs5711.push_back(Z2i::Vector(1,2));
592 
593  normals5711.push_back(Z2i::Vector(1,-5));
594  normals5711.push_back(Z2i::Vector(3,-4));
595  normals5711.push_back(Z2i::Vector(4,-3));
596  normals5711.push_back(Z2i::Vector(5,-1));
597  normals5711.push_back(Z2i::Vector(5,1));
598  normals5711.push_back(Z2i::Vector(4,3));
599  normals5711.push_back(Z2i::Vector(3,4));
600  normals5711.push_back(Z2i::Vector(1,5));
601 
602  Metric mask5711(dirs5711,normals5711);
603 
604  //Setting:
605  trace.beginBlock("Testing shrinking using Q");
606  Point P(0,0);
607  Point Q(-2,1), QQ(2,1);
608  Point Lmin(-10,10);
609  Point Lmax(10,10);
610  Point midPointP,nextMidPointP;
611  Point midPointQ,nextMidPointQ;
612 
613  Metric::ConstIterator itBeg = mask5711.begin();
614  Metric::ConstIterator itEnd = mask5711.end();
615 
616  Metric::ConstIterator cone = mask5711.shrinkP(itBeg, itEnd, P, Q, Lmin, Lmax, 0, midPointP, nextMidPointP);
617  trace.info() <<" P - Shrink returns the cone "<< *cone<<" " <<*(cone+1)<<std::endl;
618  trace.info() <<" P - MidPoint "<< midPointP<<" " <<nextMidPointP<<std::endl<<std::endl;
619 
620  Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, Q, P, Lmin, Lmax, 0, midPointQ, nextMidPointQ);
621  trace.info() <<" Q - Shrink returns the cone "<< *cone2<<" " <<*(cone2+1)<<std::endl;
622  trace.info() <<" Q - MidPoint "<< midPointQ<<" " <<nextMidPointQ<<std::endl<<std::endl;
623  trace.info() << "Checking Voro cell" <<std::endl;
624 
625 
626  double dpmidp = mask5711(P,midPointP);
627  double dqmidp = mask5711(Q,midPointP);
628  trace.info() << ((dpmidp < dqmidp) ? "MidP closer to P" : "Mid closer to Q") << std::endl;
629  double dpnextmidp = mask5711(P,nextMidPointP);
630  double dqnextmidp = mask5711(Q,nextMidPointP);
631  trace.info() << ((dpnextmidp < dqnextmidp) ? "NextMidP closer to P" : "Mid closer to Q") << std::endl;
632  nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
633  nb++;
634  trace.info() << "(" << nbok << "/" << nb << ") "
635  << " Shrink P contains the Voronoi Edge" << std::endl;
636 
637 
638  double dpmidq = mask5711(P,midPointQ);
639  double dqmidq = mask5711(Q,midPointQ);
640  trace.info() << ((dpmidq < dqmidq) ? "MidQ closer to P" : "Mid closer to Q") << std::endl;
641  double dpnextmidq = mask5711(P,nextMidPointQ);
642  double dqnextmidq = mask5711(Q,nextMidPointQ);
643  trace.info() << ((dpnextmidq < dqnextmidq) ? "NextMidP closer to P" : "Mid closer to Q") << std::endl;
644  nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
645  nb++;
646  trace.info() << "(" << nbok << "/" << nb << ") "
647  << " Shrink Q contains the Voronoi Edge" << std::endl;
648  trace.endBlock();
649 
650  //Setting2
651  trace.beginBlock("Testing double shrinking on QQ");
652  Metric::ConstIterator coneQQ = mask5711.shrinkP(itBeg, itEnd, P, QQ, Lmin, Lmax, 0, midPointP, nextMidPointP);
653  trace.info() <<" P - Shrink returns the cone "<< *coneQQ<<" " <<*(coneQQ+1)<<std::endl;
654  trace.info() <<" P - MidPoint "<< midPointP<<" " <<nextMidPointP<<std::endl;
655  trace.info() <<" P - cone distance to P("<< mask5711(midPointP,P)<<","
656  << mask5711(nextMidPointP,P)<<")" <<std::endl;
657  trace.info() <<" P - cone distance to QQ("<< mask5711(midPointP,QQ)<<","
658  << mask5711(nextMidPointP,QQ)<<")" <<std::endl<<std::endl;
659 
660  Metric::ConstIterator coneQQ2 = mask5711.shrinkP(itBeg, itEnd, QQ, P, Lmin, Lmax, 0, midPointQ, nextMidPointQ);
661  trace.info() <<" QQ - Shrink returns the cone "<< *coneQQ2<<" " <<*(coneQQ2+1)<<std::endl;
662  trace.info() <<" QQ - MidPoint "<< midPointQ<<" " <<nextMidPointQ<<std::endl;
663  trace.info() <<" QQ - cone distance to QQ("<< mask5711(midPointQ,QQ)<<","
664  << mask5711(nextMidPointQ,QQ)<<")" <<std::endl;
665  trace.info() <<" QQ - cone distance to P("<< mask5711(midPointQ,P)<<","
666  << mask5711(nextMidPointQ,P)<<")" <<std::endl;
667  trace.info() << "Checking Voro cell" <<std::endl<<std::endl;
668 
669  dpmidp = mask5711(P,midPointP);
670  dqmidp = mask5711(QQ,midPointP);
671  trace.info() << ((dpmidp < dqmidp) ? "MidP closer to P" : "MidP closer to QQ") << std::endl;
672  dpnextmidp = mask5711(P,nextMidPointP);
673  dqnextmidp = mask5711(QQ,nextMidPointP);
674  trace.info() << ((dpnextmidp < dqnextmidp) ? "NextMidP closer to P" : "NextMidP closer to QQ") << std::endl;
675  nbok += ( (dpmidp < dqmidp) != (dpnextmidp < dqnextmidp)) ? 1 : 0;
676  nb++;
677  trace.info() << "(" << nbok << "/" << nb << ") "
678  << " Shrink P contains the Voronoi Edge" << std::endl;
679  trace.info()<< "Distances : ConeP<->P("<<dpmidp<<","<<dpnextmidp<<") ConeP<->Q("<<dqmidp<<","<<dqnextmidp<<")"<<std::endl;
680 
681 
682  dpmidq = mask5711(P,midPointQ);
683  dqmidq = mask5711(QQ,midPointQ);
684  trace.info() << ((dpmidq < dqmidq) ? "MidQ closer to P" : "MidQ closer to QQ") << std::endl;
685  dpnextmidq = mask5711(P,nextMidPointQ);
686  dqnextmidq = mask5711(QQ,nextMidPointQ);
687  trace.info() << ((dpnextmidq < dqnextmidq) ? "NextMidQ closer to P" : "NextMidQ closer to QQ") << std::endl;
688  nbok += ( (dpmidq < dqmidq) != (dpnextmidq < dqnextmidq)) ? 1 : 0;
689  nb++;
690  trace.info() << "(" << nbok << "/" << nb << ") "
691  << " Shrink QQ contains the Voronoi Edge" << std::endl;
692  trace.info()<< "Distances : ConeQ<->P("<<dpmidq<<","<<dpnextmidq<<") ConeQ<->QQ("<<dqmidq<<","<<dqnextmidq<<")"<<std::endl;
693  trace.endBlock();
694 
695  trace.endBlock();
696 
697 
698  return nbok == nb;
699 }
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()

◆ testHiddenBy()

bool testHiddenBy ( )

Definition at line 702 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

703 {
704  unsigned int nbok = 0;
705  unsigned int nb = 0;
706  trace.beginBlock ( "Testing HiddenBy...");
707 
708  //5-7-11 metic
710  Metric::Directions dirs5711;
711  Metric::Directions normals5711;
712  //5-7-11 mask
713  dirs5711.push_back(Z2i::Vector(0,-1));
714  dirs5711.push_back(Z2i::Vector(1,-2));
715  dirs5711.push_back(Z2i::Vector(1,-1));
716  dirs5711.push_back(Z2i::Vector(2,-1));
717  dirs5711.push_back(Z2i::Vector(1,0));
718  dirs5711.push_back(Z2i::Vector(2,1));
719  dirs5711.push_back(Z2i::Vector(1,1));
720  dirs5711.push_back(Z2i::Vector(1,2));
721 
722  normals5711.push_back(Z2i::Vector(1,-5));
723  normals5711.push_back(Z2i::Vector(3,-4));
724  normals5711.push_back(Z2i::Vector(4,-3));
725  normals5711.push_back(Z2i::Vector(5,-1));
726  normals5711.push_back(Z2i::Vector(5,1));
727  normals5711.push_back(Z2i::Vector(4,3));
728  normals5711.push_back(Z2i::Vector(3,4));
729  normals5711.push_back(Z2i::Vector(1,5));
730 
731  Metric mask5711(dirs5711,normals5711);
732 
733  //Setting:
734  Point U(0,0);
735  Point V(0,3);
736  Point VV(-10,3);
737  Point W(0,6);
738  Point Lmin(10,-10);
739  Point Lmax(10,10);
740 
741  Point Usym(20,0);
742  Point Vsym(20,3);
743  Point VVsym(30,3);
744  Point Wsym(20,6);
745 
746  Point LminH(-10,10);
747  Point LmaxH(10,10);
748 
749  Point UH(0,0);
750  Point VH(3,0);
751  Point VVH(3,-10);
752  Point WH(6,0);
753 
754 
755  nbok += ( mask5711.hiddenBy(U,V, W, Lmin, Lmax, 1) == false ) ? 1 : 0;
756  nb++;
757  trace.info() << "(" << nbok << "/" << nb << ") "
758  << " H(U,V,W) is false" << std::endl;
759 
760  nbok += ( mask5711.hiddenBy(U,VV, W, Lmin, Lmax, 1) == true ) ? 1 : 0;
761  nb++;
762  trace.info() << "(" << nbok << "/" << nb << ") "
763  << " H(U,VV,W) is true" << std::endl;
764 
765  nbok += ( mask5711.hiddenBy(Usym,Vsym, Wsym, Lmin, Lmax, 1) == false ) ? 1 : 0;
766  nb++;
767  trace.info() << "(" << nbok << "/" << nb << ") "
768  << " H(Usym,Vsym,Wsym) is false" << std::endl;
769 
770  nbok += ( mask5711.hiddenBy(Usym,VVsym, Wsym, Lmin, Lmax, 1) == true ) ? 1 : 0;
771  nb++;
772  trace.info() << "(" << nbok << "/" << nb << ") "
773  << " H(Usym,VVsym,Wsym) is true" << std::endl;
774 
775  nbok += ( mask5711.hiddenBy(UH,VH, WH, LminH, LmaxH, 0) == false ) ? 1 : 0;
776  nb++;
777  trace.info() << "(" << nbok << "/" << nb << ") "
778  << " H(UH,VH,WH) is false" << std::endl;
779 
780  nbok += ( mask5711.hiddenBy(UH,VVH, WH, LminH, LmaxH, 0) == true ) ? 1 : 0;
781  nb++;
782  trace.info() << "(" << nbok << "/" << nb << ") "
783  << " H(UH,VVH,WH) is true" << std::endl;
784 
785  trace.endBlock();
786  return nb == nbok;
787 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()

◆ testIntersection()

bool testIntersection ( )

Definition at line 215 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::experimental::ChamferNorm2D< TSpace >::getLowerRayIntersection(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

216 {
217  unsigned int nbok = 0;
218  unsigned int nb = 0;
219  trace.beginBlock ( "Testing intersection...");
220 
221  Point P(0,0),Q(7,3),Qb(7,-3), Q2(2, -10), Q3(2,10);
222  Point Lmin(10,-10), Lmax(10,10);
224 
225  trace.info() << "Intersection "<<P<<" "<<Q<<" = "
226  << mask.getLowerRayIntersection(P,Q,Lmin,Lmax, 1)<<std::endl;
227  nbok += ( mask.getLowerRayIntersection(P,Q,Lmin,Lmax, 1) == 4) ? 1 : 0;
228  nb++;
229  trace.info() << "(" << nbok << "/" << nb << ") "
230  << "inter==4" << std::endl;
231 
232  trace.info() << "Intersection "<<P<<" "<<Qb<<" = "
233  << mask.getLowerRayIntersection(P,Qb,Lmin,Lmax, 1)<<std::endl;
234  nbok += ( mask.getLowerRayIntersection(P,Qb,Lmin,Lmax, 1) == -5) ? 1 : 0;
235  nb++;
236  trace.info() << "(" << nbok << "/" << nb << ") "
237  << "inter==-5" << std::endl;
238 
239  trace.info() << "Intersection "<<P<<" "<<Q2<<" = "
240  << mask.getLowerRayIntersection(P,Q2,Lmin,Lmax, 1)<<std::endl;
241  nbok += ( mask.getLowerRayIntersection(P,Q2,Lmin,Lmax, 1) <= Lmin[1]) ? 1 : 0;
242  nb++;
243  trace.info() << "(" << nbok << "/" << nb << ") "
244  << "inter==Lmin" << std::endl;
245 
246  trace.info() << "Intersection "<<P<<" "<<Q3<<" = "
247  << mask.getLowerRayIntersection(P,Q3,Lmin,Lmax, 1)<<std::endl;
248  nbok += ( mask.getLowerRayIntersection(P,Q3,Lmin,Lmax, 1) >= Lmax[1]) ? 1 : 0;
249  nb++;
250  trace.info() << "(" << nbok << "/" << nb << ") "
251  << "inter==Lmax" << std::endl;
252 
253  trace.info()<<std::endl;
254 
255  Point PP(0,0),QQ(3,7),QQb(-3,7), QQ2(-10, 2), QQ3(10, 2);
256  Point LLmin(-10,10), LLmax(10,10);
257 
258  trace.info() << "Intersection "<<PP<<" "<<QQ<<" = "
259  << mask.getLowerRayIntersection(PP,QQ,LLmin,LLmax, 0)<<std::endl;
260  nbok += ( mask.getLowerRayIntersection(PP,QQ,LLmin,LLmax, 0) == 4) ? 1 : 0;
261  nb++;
262  trace.info() << "(" << nbok << "/" << nb << ") "
263  << "inter==4" << std::endl;
264 
265  trace.info() << "Intersection "<<PP<<" "<<QQb<<" = "
266  << mask.getLowerRayIntersection(PP,QQb,LLmin,LLmax, 0)<<std::endl;
267  nbok += ( mask.getLowerRayIntersection(PP,QQb,LLmin,LLmax, 0) == -5) ? 1 : 0;
268  nb++;
269  trace.info() << "(" << nbok << "/" << nb << ") "
270  << "inter==-5" << std::endl;
271 
272  trace.info() << "Intersection "<<PP<<" "<<QQ2<<" = "
273  << mask.getLowerRayIntersection(PP,QQ2,LLmin,LLmax, 0)<<std::endl;
274  nbok += ( mask.getLowerRayIntersection(PP,QQ2,LLmin,LLmax, 0) <= LLmin[0]) ? 1 : 0;
275  nb++;
276  trace.info() << "(" << nbok << "/" << nb << ") "
277  << "inter==Lmin" << std::endl;
278 
279  trace.info() << "Intersection "<<PP<<" "<<QQ3<<" = "
280  << mask.getLowerRayIntersection(PP,QQ3,LLmin,LLmax, 0)<<std::endl;
281  nbok += ( mask.getLowerRayIntersection(PP,QQ3,LLmin,LLmax, 0) >= LLmax[0]) ? 1 : 0;
282  nb++;
283  trace.info() << "(" << nbok << "/" << nb << ") "
284  << "inter==Lmax" << std::endl;
285 
286  return nbok == nb;
287 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()

◆ testShrink()

bool testShrink ( )

Definition at line 290 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::trace, and DGtal::Trace::warning().

Referenced by main().

291 {
292  unsigned int nbok = 0;
293  unsigned int nb = 0;
294  trace.beginBlock ( "Testing shrinking...");
295 
296  //5-7-11 metic
298  Metric::Directions dirs5711;
299  Metric::Directions normals5711;
300  //5-7-11 mask
301  dirs5711.push_back(Z2i::Vector(0,-1));
302  dirs5711.push_back(Z2i::Vector(1,-2));
303  dirs5711.push_back(Z2i::Vector(1,-1));
304  dirs5711.push_back(Z2i::Vector(2,-1));
305  dirs5711.push_back(Z2i::Vector(1,0));
306  dirs5711.push_back(Z2i::Vector(2,1));
307  dirs5711.push_back(Z2i::Vector(1,1));
308  dirs5711.push_back(Z2i::Vector(1,2));
309 
310  normals5711.push_back(Z2i::Vector(1,-5));
311  normals5711.push_back(Z2i::Vector(3,-4));
312  normals5711.push_back(Z2i::Vector(4,-3));
313  normals5711.push_back(Z2i::Vector(5,-1));
314  normals5711.push_back(Z2i::Vector(5,1));
315  normals5711.push_back(Z2i::Vector(4,3));
316  normals5711.push_back(Z2i::Vector(3,4));
317  normals5711.push_back(Z2i::Vector(1,5));
318 
319  Metric mask5711(dirs5711,normals5711);
320 
321  //Setting:
322  Point P(0,0);
323  Point Q(1,-2), QQ(1,2);
324  Point Lmin(10,0);
325  Point Lmax(10,10);
326  Metric::ConstIterator itBeg = mask5711.begin();
327  Metric::ConstIterator itEnd = mask5711.end();
328 
329  Point midPoint, nextMidPoint;
330 
331  Metric::ConstIterator cone = mask5711.shrinkPSubMask(itBeg, itEnd, P, Q, Lmin, Lmax, 1, midPoint, nextMidPoint);
332  trace.info() <<"Shrink returns the cone "<< *cone<<" " <<*(cone+1)<<std::endl;
333  trace.info() <<"MidPoint "<< midPoint<<" " <<nextMidPoint<<std::endl<<std::endl;
334  nbok += ( midPoint == Point(10,0)) ? 1 : 0;
335  nb++;
336  trace.info() << "(" << nbok << "/" << nb << ") "
337  << "midPoint = (10,0)" << std::endl;
338  nbok += ( nextMidPoint == Point(10,5)) ? 1 : 0;
339  nb++;
340  trace.info() << "(" << nbok << "/" << nb << ") "
341  << "nextMidPoint = (10,5)" << std::endl;
342 
343 
344  trace.warning()<<" Shrinking with QQ(1,2)"<<std::endl;
345 
346  Metric::ConstIterator cone2 = mask5711.shrinkPSubMask(itBeg, itEnd, P, QQ, Lmin, Lmax, 1, midPoint, nextMidPoint);
347  trace.info() <<"Shrink returns the cone2 "<< *cone2<<" " <<*(cone2+1)<<std::endl;
348  trace.info() <<"MidPoint "<< midPoint<<" " <<nextMidPoint<<std::endl<<std::endl;
349  nbok += ( midPoint == Point(10,-5)) ? 1 : 0;
350  nb++;
351  trace.info() << "(" << nbok << "/" << nb << ") "
352  << "midPoint = (10,0)" << std::endl;
353  nbok += ( nextMidPoint == Point(10,0)) ? 1 : 0;
354  nb++;
355  trace.info() << "(" << nbok << "/" << nb << ") "
356  << "nextMidPoint = (10,5)" << std::endl;
357 
358 
359  trace.beginBlock("Testing Symmetry");
360  Point LLmin(-10,0);
361  Point LLmax(-10,10);
362  Point QQQ(-1,-2);
363  Metric::ConstIterator cone3 = mask5711.shrinkP(itBeg, itEnd, P, QQQ, LLmin, LLmax, 1, midPoint, nextMidPoint);
364  trace.info() <<"Shrink returns the cone3 "<< *cone3<<" " <<*(cone3+1)<<std::endl;
365  trace.info() <<"MidPoint "<< midPoint<<" " <<nextMidPoint<<std::endl<<std::endl;
366  nbok += ( midPoint == Point(-10,0)) ? 1 : 0;
367  nb++;
368  trace.info() << "(" << nbok << "/" << nb << ") "
369  << "midPoint = (-10,0)" << std::endl;
370  nbok += ( nextMidPoint == Point(-10,5)) ? 1 : 0;
371  nb++;
372  trace.info() << "(" << nbok << "/" << nb << ") "
373  << "nextMidPoint = (-10,5)" << std::endl;
374  trace.endBlock();
375 
376  //horizontal
377  trace.beginBlock("Testing H/V symmetry");
378  Point LLLmin(0,10);
379  Point LLLmax(10,10);
380  Point Qhori(-2,1);
381  Metric::ConstIterator cone4 = mask5711.shrinkP(itBeg, itEnd, P, Qhori, LLLmin, LLLmax, 0, midPoint, nextMidPoint);
382  trace.info() <<"Shrink returns the cone3 "<< *cone4<<" " <<*(cone4+1)<<std::endl;
383  trace.info() <<"MidPoint "<< midPoint<<" " <<nextMidPoint<<std::endl<<std::endl;
384  nbok += ( *cone4 == *cone) ? 1 : 0;
385  nb++;
386  trace.info() << "(" << nbok << "/" << nb << ") "
387  << "horiz==vert" << std::endl;
388  nbok += ( midPoint == Point(0,10)) ? 1 : 0;
389  nb++;
390  trace.info() << "(" << nbok << "/" << nb << ") "
391  << "midPoint = (0,10)" << std::endl;
392  nbok += ( nextMidPoint == Point(5,10)) ? 1 : 0;
393  nb++;
394  trace.info() << "(" << nbok << "/" << nb << ") "
395  << "nextMidPoint = (5,10)" << std::endl;
396 
397  Point LLLLmin(0,-10);
398  Point LLLLmax(10,-10);
399  Point QQhori(-2,-1);
400  Metric::ConstIterator cone5 = mask5711.shrinkP(itBeg, itEnd, P, QQhori, LLLLmin, LLLLmax, 0, midPoint, nextMidPoint);
401  trace.info() <<"Shrink returns the cone3 "<< *cone4<<" " <<*(cone4+1)<<std::endl;
402  trace.info() <<"MidPoint "<< midPoint<<" " <<nextMidPoint<<std::endl;
403  nbok += ( *cone5 == *cone) ? 1 : 0;
404  nb++;
405  trace.info() << "(" << nbok << "/" << nb << ") "
406  << "horiz==vert" << std::endl;
407  nbok += ( midPoint == Point(0,-10)) ? 1 : 0;
408  nb++;
409  trace.info() << "(" << nbok << "/" << nb << ") "
410  << "midPoint = (0,-10)" << std::endl;
411  nbok += ( nextMidPoint == Point(5,-10)) ? 1 : 0;
412  nb++;
413  trace.info() << "(" << nbok << "/" << nb << ") "
414  << "nextMidPoint = (5,-10)" << std::endl;
415  trace.endBlock();
416 
417  trace.endBlock();
418  return nbok == nb;
419 }
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
double endBlock()
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & warning()
std::ostream & info()

◆ testSpecialCase()

bool testSpecialCase ( )

Definition at line 883 of file testChamferDT.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

884 {
885  unsigned int nbok = 0;
886  unsigned int nb = 0;
887 
888  //5-7-11 metic
890  Metric::Directions dirs5711;
891  Metric::Directions normals5711;
892  //5-7-11 mask
893  dirs5711.push_back(Z2i::Vector(0,-1));
894  dirs5711.push_back(Z2i::Vector(1,-2));
895  dirs5711.push_back(Z2i::Vector(1,-1));
896  dirs5711.push_back(Z2i::Vector(2,-1));
897  dirs5711.push_back(Z2i::Vector(1,0));
898  dirs5711.push_back(Z2i::Vector(2,1));
899  dirs5711.push_back(Z2i::Vector(1,1));
900  dirs5711.push_back(Z2i::Vector(1,2));
901 
902  normals5711.push_back(Z2i::Vector(1,-5));
903  normals5711.push_back(Z2i::Vector(3,-4));
904  normals5711.push_back(Z2i::Vector(4,-3));
905  normals5711.push_back(Z2i::Vector(5,-1));
906  normals5711.push_back(Z2i::Vector(5,1));
907  normals5711.push_back(Z2i::Vector(4,3));
908  normals5711.push_back(Z2i::Vector(3,4));
909  normals5711.push_back(Z2i::Vector(1,5));
910 
911  Metric mask5711(dirs5711,normals5711);
912 
913  trace.beginBlock ( "Testing special cases...");
914  //Setting:
915  Point U(12,-12);
916  Point V(6,0);
917  Point W(-16,3);
918  Point Lmin(11,-20);
919  Point Lmax(11,20);
920  Point midPointP,nextMidPointP;
921  Point midPointQ,nextMidPointQ;
922 
923  Metric::ConstIterator itBeg = mask5711.begin();
924  Metric::ConstIterator itEnd = mask5711.end();
925 
926 
927  Metric::ConstIterator cone2 = mask5711.shrinkP(itBeg, itEnd, V, W, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
928  Metric::ConstIterator cone3 = mask5711.shrinkP(itBeg, itEnd, W, V, Lmin, Lmax, 1, midPointQ, nextMidPointQ);
929 
930  trace.info() <<" V - W Shrink returns the cone "<< *cone2<<" " <<*(cone2+1)<<std::endl;
931  trace.info() <<" W - V Shrink returns the cone "<< *cone3<<" " <<*(cone3+1)<<std::endl;
932  trace.info() <<" Q - MidPoint "<< midPointQ<<" " <<nextMidPointQ<<std::endl<<std::endl;
933 
934  Metric::Abscissa pos = mask5711.getLowerVoronoiEdgeAbscissa(V, W, Lmin, Lmax, 1);
935  trace.info() << " Pos = "<<pos<<std::endl;
936 
937 
938 
939  nbok += ( mask5711.hiddenBy(U,V, W, Lmin, Lmax, 1) == false ) ? 1 : 0;
940  nb++;
941  trace.info() << "(" << nbok << "/" << nb << ") "
942  << " H(U,V,W) is false" << std::endl;
943 
944 
945 
946  return nbok == nb;
947 
948 
949 
950 }
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Definition: ChamferNorm2D.h:86
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()