32 #include "DGtal/base/Common.h"
33 #include "DGtal/kernel/CPointPredicate.h"
34 #include "DGtal/base/CConstBidirectionalRange.h"
35 #include "DGtal/geometry/curves/ArithmeticalDSS.h"
36 #include "DGtal/geometry/curves/ArithmeticalDSSFactory.h"
37 #include "DGtal/geometry/curves/StabbingLineComputer.h"
41 using namespace DGtal;
51 template <
typename DSS>
59 unsigned int nbok = 0;
65 trace.
info() <<
"constructor, copy, assignement, equality" << std::endl;
88 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
93 if ( dss.isValid() && dss3.isValid() && dss5.isValid() )
96 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
104 trace.
info() <<
"not valid dss" << std::endl;
109 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
113 trace.
info() <<
"a,b,mu,omega accessors" << std::endl;
115 if ( (dss.a() == 0)&&(dss.b() == 1)&&(dss.mu() == 0)&&(dss.omega() == 1) )
119 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
122 trace.
info() <<
"points accessors" << std::endl;
123 if ( (dss.front() ==
Point(1,0))&&(dss.back() ==
Point(0,0)) )
126 if ( (dss.Ul() ==
Point(1,0))&&(dss.Uf() ==
Point(0,0)) )
129 if ( (dss.Ll() ==
Point(1,0))&&(dss.Lf() ==
Point(0,0)) )
133 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
138 trace.
info() <<
"remainder, position, tests" << std::endl;
141 if ( (dss7.isValid())
142 && (dss7.remainder(
Point(8,5) ) == 0)
143 &&(dss7.remainder(
Point(16,10) ) == 0)
144 &&(dss7.remainder(
Point(3,2) ) == -1)
145 &&(dss7.remainder(
Point(5,3) ) == 1) )
149 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
152 if ( (dss7.orthogonalPosition(
Point(0,0) ) == 0)
153 &&(dss7.orthogonalPosition(
Point(8,5) ) == 89)
154 &&(dss7.orthogonalPosition(
Point(1,0) ) == 8)
155 &&(dss7.orthogonalPosition(
Point(-1,0) ) == -8) )
159 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
162 if ( (dss7.isInDSL(
Point(0,0) ))
163 &&(dss7.isInDSL(
Point(16,10) ))
164 &&(dss7.isInDSL(
Point(5,3) ))
165 &&(!dss7.isInDSL(
Point(3,2) )) )
169 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
172 if ( (dss7(
Point(0,0) ))
173 &&(!dss7(
Point(16,10) ))
174 &&(dss7(
Point(5,3) ))
175 &&(!dss7(
Point(3,2) ))
176 &&(!dss7(
Point(-1,0) )) )
180 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
184 if (dss.remainder(dss.shift()) == dss.omega())
187 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
203 template <
typename DSS>
206 unsigned int nbok = 0;
216 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
225 for (I it = dss.begin(), itEnd = dss.end();
226 ( (it != itEnd)&&(res)&&(c<100) );
233 trace.
info() <<
" : " << c <<
" points " << std::endl;
236 if ( (res)&&(c == (dss.omega()+1))
237 &&(*dss.begin() == dss.back())
238 &&(*--dss.end() == dss.front()) )
242 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
247 typedef typename DSS::ConstReverseIterator I;
250 for (I it = dss.rbegin(), itEnd = dss.rend();
251 ( (it != itEnd)&&(res)&&(c<100) );
258 trace.
info() <<
" : " << c <<
" points " << std::endl;
261 if ( (res)&&(c == (dss.omega()+1))
262 &&(*dss.rbegin() == dss.front())
263 &&(*--dss.rend() == dss.back()) )
267 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
288 template <
typename DSS>
292 unsigned int& nbok,
unsigned int& nb,
293 const unsigned short int& code = 0)
299 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
301 trace.
info() <<
"to front " << newPointToFront << std::endl;
302 if (dss.isExtendableFront( newPointToFront ) == code)
305 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
310 if ( (!mdss.extendFront(newPointToFront)) )
316 if ( (mdss.extendFront(newPointToFront))&&(mdss.isValid()) )
319 std::cerr << mdss.isValid() << std::endl;
322 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
324 trace.
info() <<
"to back " << newPointToBack << std::endl;
325 if (dss.isExtendableBack( newPointToBack ) == code)
328 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
333 if ( (!mdss.extendBack(newPointToBack)) )
339 if ( (mdss.extendBack(newPointToBack))&&(mdss.isValid()) )
342 std::cerr << mdss.isValid() << std::endl;
345 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
359 template <
typename DSS>
371 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
377 Point first = mdss.back();
378 trace.
info() <<
"remove " << first << std::endl;
379 if ( ( (mdss.retractBack())
381 && (mdss(first) ==
false) ) == res )
384 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
388 if ( (mdss.extendBack(first))
389 && (mdss.isValid()) && (mdss == dss) )
392 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
396 Point last = mdss.front();
397 trace.
info() <<
"remove " << last << std::endl;
398 if ( ( (mdss.retractFront())
400 && (mdss(last) ==
false) ) == res )
404 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
408 if ( (mdss.extendFront(last))
409 && (mdss.isValid()) && (mdss == dss) )
412 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
422 template <
typename DSS>
428 unsigned int nbok = 0;
435 trace.
info() <<
"not connected point" << std::endl;
442 trace.
info() <<
"not compatible second step" << std::endl;
449 trace.
info() <<
"a third step" << std::endl;
456 trace.
info() <<
"strongly exterior" << std::endl;
463 trace.
info() <<
"confounded points" << std::endl;
470 trace.
info() <<
"strongly interior points" << std::endl;
473 dss0.Uf(), dss0.Ul(),
474 dss0.Lf(), dss0.Ll() );
480 trace.
info() <<
"weakly interior points on the left" << std::endl;
485 newPointToBack+dss0.steps().second,
486 newPointToFront-dss0.steps().second,
487 dss0.Uf(), dss0.Ul(),
488 dss0.Lf(), dss0.Ll()+
Vector(8,5) );
489 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 5 );
494 trace.
info() <<
"weakly exterior points on the left" << std::endl;
496 Point newPointToBack = dss0.Uf()+dss0.shift()-
Vector(8,5);
497 Point newPointToFront = dss0.Ll()-dss0.shift()+
Vector(8,5);
499 newPointToBack+dss0.steps().second,
500 newPointToFront-dss0.steps().second,
501 dss0.Uf(), dss0.Ul(),
502 dss0.Lf()-
Vector(8,5), dss0.Ll() );
503 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 7 );
508 trace.
info() <<
"weakly interior points on the right" << std::endl;
513 newPointToBack+dss0.steps().first,
514 newPointToFront-dss0.steps().first,
515 dss0.Uf(), dss0.Ul(),
516 dss0.Lf()-
Vector(8,5), dss0.Ll() );
517 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 6 );
522 trace.
info() <<
"weakly exterior points on the right" << std::endl;
524 Point newPointToBack = dss0.Lf()-
Vector(8,5)-dss0.shift();
525 Point newPointToFront = dss0.Ul()+
Vector(8,5)+dss0.shift();
527 newPointToBack+dss0.steps().first,
528 newPointToFront-dss0.steps().first,
529 dss0.Uf(), dss0.Ul(),
530 dss0.Lf(), dss0.Ll()+
Vector(8,5) );
531 extensionTest( dss, newPointToFront, newPointToBack, nbok, nb, 8 );
536 trace.
info() <<
"first step" << std::endl;
543 trace.
info() <<
"first step repetition" << std::endl;
550 trace.
info() <<
"second step (above)" << std::endl;
552 DSS dss(
Point(0,0),
Point(2,1) - dss0.steps().second);
553 Point newPointToBack =
Point(0,0) - dss0.steps().second;
559 trace.
info() <<
"second step (below)" << std::endl;
562 DSS dss(
Point(0,0),
Point(2,-1) - dss0a.steps().first);
563 Point newPointToBack =
Point(0,0) - dss0a.steps().first;
574 trace.
info() <<
"upper leaning points" << std::endl;
581 trace.
info() <<
"lower leaning points" << std::endl;
583 Point first = dss0.Lf();
585 DSS dss(5, 8, first, last,
593 trace.
info() <<
"upper leaning points (repetitions)" << std::endl;
600 trace.
info() <<
"lower leaning points (repetitions)" << std::endl;
602 Point first = dss0.Lf();
604 DSS dss(5, 8, first, last,
612 trace.
info() <<
"no change" << std::endl;
618 DSS dss(dss0.a(), dss0.b(), *itb, *ite,
619 dss0.Uf(), dss0.Ul(), dss0.Lf(), dss0.Ll() );
625 trace.
info() <<
"one point" << std::endl;
632 trace.
info() <<
"two points" << std::endl;
639 trace.
info() <<
"from two steps to one step" << std::endl;
658 template <
typename DSS>
661 unsigned int nbok = 0;
667 <<
", front pos: " << dss.position( dss.front() )
668 <<
", back pos: " << dss.position( dss.back() ) << std::endl;
669 if ( dss.position( dss.front() )
670 > dss.position( dss.back() ) )
674 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
683 if ( mdss.extendFront(mdss.front()-dss.shift()+dss.steps().first) )
687 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
690 if ( !mdss.extendFront(mdss.front()-dss.shift()) )
694 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
698 if ( !mdss.extendFront(mdss.front()-dss.shift()-dss.steps().first) )
702 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
707 if ( mdss.extendBack(mdss.back()+dss.shift()-dss.steps().first) )
711 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
714 if ( !mdss.extendBack(mdss.back()+dss.shift()) )
718 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
722 if ( !mdss.extendBack(mdss.back()+dss.shift()+dss.steps().first) )
726 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
739 template <
typename DSS>
747 unsigned int nbok = 0;
758 DSS dss( dss0.begin(), dss0.end() );
761 if ( (dss0.isValid())
764 && (dss.Lf() == dss.Ll())
765 && (dss.Uf() == dss.back())
766 && (dss.Ul() == dss.front())
767 && (dss.back() != dss.front()) )
770 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
778 DSS rdss( rdss0.begin(), rdss0.end() );
781 if ( (rdss0.isValid())
784 && (rdss.Uf() == rdss.Ul())
785 && (rdss.Lf() == rdss.back())
786 && (rdss.Ll() == rdss.front())
787 && (rdss.back() != rdss.front())
791 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
811 template <
typename DSS>
813 typename DSS::Position x,
typename DSS::Position y)
815 typename DSS::DSL dsl = aDSS.dsl();
816 DSS dss0( dsl.begin(dsl.getPoint(x)), dsl.end(dsl.getPoint(y)) );
817 DSS dss1( dsl, dsl.getPoint(x), dsl.getPoint(y) );
818 DSS dss2( aDSS, dsl.getPoint(x), dsl.getPoint(y) );
819 return ( (dss0 == dss1)&&(dss0 == dss2) );
832 template <
typename DSL>
835 unsigned int nbok = 0;
841 for (
typename DSL::Integer mu = 0; ( (mu-1 >= -aDSL.omega())&&(nbok == nb) ); --mu)
846 typedef typename DSL::Coordinate Coordinate;
850 Point startingPoint = aDSL.getPoint(0);
851 ASSERT( aDSL(startingPoint) );
852 Point endingPoint = aDSL.getPoint(2*aDSL.patternLength()+1);
853 ASSERT( aDSL(endingPoint) );
855 DSS dss = DSS(aDSL.begin(startingPoint), aDSL.end(endingPoint));
857 for (
typename DSL::Position l = 0; ( (l <= 2*aDSL.patternLength())&&(nbok == nb) ); ++l)
861 for (
typename DSL::Position k = 0; ( (k <= l)&&(nbok == nb) ); ++k)
883 unsigned int nbok = 0;
900 DSS DSS1(1,2,
Point(2,2),
Point(6,4),
Point(2,2),
Point(6,4),
Point(3,2),
Point(5,3));
901 DSS DSS2(3,5,
Point(-2,-1),
Point(9,6),
Point(2,2),
Point(7,5),
Point(0,0),
Point(5,3));
902 DSS res=DSS1.computeUnion(DSS2);
904 nbok +=(res==DSS2)?1:0;
908 DSS1 = DSS(2,1,
Point(2,2),
Point(4,6),
Point(2,3),
Point(3,5),
Point(2,2),
Point(4,6));
909 assert(DSS1.isValid());
910 DSS2 = DSS(5,3,
Point(-1,-2),
Point(6,9),
Point(0,0),
Point(3,5),
Point(2,2),
Point(5,7));
911 assert(DSS2.isValid());
912 res = DSS1.computeUnion(DSS2);
914 nbok +=(res==DSS2)?1:0;
918 DSS1 = DSS(2,-1,
Point(-2,2),
Point(-4,6),
Point(-2,2),
Point(-4,6),
Point(-2,3),
Point(-3,5));
919 assert(DSS1.isValid());
920 DSS2 = DSS(5,-3,
Point(1,-2),
Point(-6,9),
Point(-2,2),
Point(-5,7),
Point(0,0),
Point(-3,5));
921 assert(DSS2.isValid());
922 res = DSS1.computeUnion(DSS2);
924 nbok +=(res==DSS2)?1:0;
928 DSS1 = DSS(1,-2,
Point(-2,2),
Point(-6,4),
Point(-3,2),
Point(-5,3),
Point(-2,2),
Point(-6,4));
929 assert(DSS1.isValid());
930 DSS2 = DSS(3,-5,
Point(2,-1),
Point(-9,6),
Point(0,0),
Point(-5,3),
Point(-2,2),
Point(-7,5));
931 assert(DSS2.isValid());
932 res = DSS1.computeUnion(DSS2);
934 nbok +=(res==DSS2)?1:0;
938 DSS1 = DSS(-1,-2,
Point(-2,-2),
Point(-6,-4),
Point(-2,-2),
Point(-6,-4),
Point(-3,-2),
Point(-5,-3));
939 assert(DSS1.isValid());
940 DSS2 = DSS(-3,-5,
Point(2,1),
Point(-9,-6),
Point(-2,-2),
Point(-7,-5),
Point(0,0),
Point(-5,-3));
941 assert(DSS2.isValid());
942 res = DSS1.computeUnion(DSS2);
944 nbok +=(res==DSS2)?1:0;
954 DSS1 = DSS(3,5,
Point(-2,-1),
Point(9,6),
Point(2,2),
Point(7,5),
Point(0,0),
Point(5,3));
955 DSS2 = DSS(1,2,
Point(2,2),
Point(6,4),
Point(2,2),
Point(6,4),
Point(3,2),
Point(5,3));
956 res = DSS1.computeUnion(DSS2);
958 nbok +=(res==DSS1)?1:0;
966 trace.
info() <<
"octant 0 - no new leaning points\n";
967 DSS1 = DSS(3,7,
Point(1,3),
Point(12,7),
Point(3,4),
Point(10,7),
Point(5,4),
Point(12,7));
968 DSS2 = DSS(1,2,
Point(14,8),
Point(16,9),
Point(15,9),
Point(15,9),
Point(14,8),
Point(16,9));
969 res = DSS1.computeUnion(DSS2);
971 nbok +=(res==DSS(3,7,
Point(1,3),
Point(16,9),
Point(3,4),
Point(10,7),
Point(5,4),
Point(12,7)))?1:0;
972 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
975 trace.
info() <<
"octant 0 - new leaning points in DSS2\n";
976 DSS1 = DSS(3,7,
Point(1,3),
Point(10,7),
Point(3,4),
Point(10,7),
Point(5,4),
Point(5,4));
977 DSS2 = DSS(1,2,
Point(12,7),
Point(17,10),
Point(13,8),
Point(17,10),
Point(12,7),
Point(16,9));
978 res = DSS1.computeUnion(DSS2);
980 nbok +=(res==DSS(3,7,
Point(1,3),
Point(17,10),
Point(3,4),
Point(17,10),
Point(5,4),
Point(12,7)))?1:0;
981 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
984 trace.
info() <<
"octant 0 - new leaning points between DSS1 and DSS2\n";
985 DSS1 = DSS(3,7,
Point(1,3),
Point(10,7),
Point(3,4),
Point(10,7),
Point(5,4),
Point(5,4));
986 DSS2 = DSS(1,2,
Point(13,8),
Point(15,9),
Point(13,8),
Point(15,9),
Point(14,8),
Point(14,8));
987 res = DSS1.computeUnion(DSS2);
989 nbok +=(res==DSS(3,7,
Point(1,3),
Point(15,9),
Point(3,4),
Point(10,7),
Point(5,4),
Point(12,7)))?1:0;
990 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1006 DSS1 = DSS(1,5,
Point(0,1),
Point(5,2),
Point(1,2),
Point(1,2),
Point(0,1),
Point(5,2));
1007 DSS2 = DSS(1,4,
Point(9,2),
Point(14,3),
Point(11,3),
Point(11,3),
Point(10,2),
Point(14,3));
1008 res = DSS1.computeUnion(DSS2);
1010 nbok +=(res==DSS(1,10,
Point(0,1),
Point(14,3),
Point(1,2),
Point(11,3),
Point(0,1),
Point(10,2)))?1:0;
1011 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1021 DSS1 = DSS(1,5,
Point(0,1),
Point(5,2),
Point(1,2),
Point(1,2),
Point(0,1),
Point(5,2));
1022 DSS2 = DSS(1,4,
Point(9,2),
Point(14,3),
Point(11,3),
Point(11,3),
Point(10,2),
Point(14,3));
1023 res = DSS1.computeUnion(DSS2);
1025 nbok +=(res==DSS(1,10,
Point(0,1),
Point(14,3),
Point(1,2),
Point(11,3),
Point(0,1),
Point(10,2)))?1:0;
1026 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1029 DSS1 = DSS(1,6,
Point(0,1),
Point(6,2),
Point(1,2),
Point(1,2),
Point(0,1),
Point(6,2));
1030 DSS2 = DSS(0,1,
Point(13,3),
Point(18,3),
Point(13,3),
Point(18,3),
Point(13,3),
Point(18,3));
1031 res = DSS1.computeUnion(DSS2);
1033 nbok +=(res==DSS(1,9,
Point(0,1),
Point(18,3),
Point(1,2),
Point(10,3),
Point(0,1),
Point(18,3)))?1:0;
1034 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1039 DSS1 = DSS(6,-1,
Point(-1,0),
Point(-2,6),
Point(-2,1),
Point(-2,1),
Point(-1,0),
Point(-2,6));
1040 DSS2 = DSS(1,0,
Point(-3,13),
Point(-3,18),
Point(-3,13),
Point(-3,18),
Point(-3,13),
Point(-3,18));
1041 res = DSS1.computeUnion(DSS2);
1043 nbok +=(res==DSS(9,-1,
Point(-1,0),
Point(-3,18),
Point(-2,1),
Point(-3,10),
Point(-1,0),
Point(-3,18)))?1:0;
1044 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1057 trace.
info() <<
"DSS1 and DSS2 are not in the same octant\n";
1059 DSS1 = DSS(1,3,
Point(0,0),
Point(3,1),
Point(0,0),
Point(3,1),
Point(2,0),
Point(2,0));
1060 DSS2 = DSS(1,-3,
Point(6,2),
Point(9,1),
Point(6,2),
Point(9,1),
Point(8,2),
Point(8,2));
1061 res = DSS1.computeUnion(DSS2);
1063 nbok +=(res==DSS(
Point(0,0)))?1:0;
1064 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1068 trace.
info() <<
"DSS1 and DSS2 are in the same octant and connected\n";
1070 DSS1 = DSS(1,3,
Point(0,0),
Point(4,2),
Point(1,1),
Point(4,2),
Point(0,0),
Point(3,1));
1071 DSS2 = DSS(1,5,
Point(4,2),
Point(9,3),
Point(4,2),
Point(9,3),
Point(8,2),
Point(8,2));
1072 res = DSS1.computeUnion(DSS2);
1074 nbok +=(res==DSS(
Point(0,0)))?1:0;
1075 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1080 trace.
info() <<
"DSS1 and DSS1 are in the same octant, not connected but easy case anyway\n";
1082 DSS1 = DSS(-3,-1,
Point(0,0),
Point(-2,-5),
Point(0,0),
Point(-1,-3),
Point(-1,-1),
Point(-2,-4));
1083 DSS2 = DSS(-3,-1,
Point(-2,-8),
Point(-3,-11),
Point(-2,-10),
Point(-2,-10),
Point(-2,-8),
Point(-3,-11));
1084 res = DSS1.computeUnion(DSS2);
1086 nbok +=(res==DSS(
Point(0,0)))?1:0;
1087 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1091 trace.
info() <<
"DSS1 and DSS2 are in the same octant but not connected\n";
1093 DSS1 = DSS(-3,-1,
Point(0,0),
Point(-2,-5),
Point(0,0),
Point(-1,-3),
Point(-1,-1),
Point(-2,-4));
1094 DSS2 = DSS(-3,-1,
Point(-5,-8),
Point(-6,-11),
Point(-5,-10),
Point(-5,-10),
Point(-5,-8),
Point(-6,-11));
1095 res = DSS1.computeUnion(DSS2);
1097 nbok +=(res==DSS(
Point(0,0)))?1:0;
1098 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1117 template <
typename TCoordinate,
typename TInteger,
unsigned short adjacency>
1122 typedef typename DSS::DSL DSL;
1127 unsigned int nb = 0;
1128 unsigned int nbok = 0;
1129 unsigned int nbEasy = 0;
1134 trace.
emphase() <<
"Adjacency: " << adjacency << std::endl;
1136 for (
unsigned int i = 0; i < nbtries; ++i )
1139 Integer b( rand() % modb + 1 );
1141 while(ic.
gcd(a,b) !=1)
1145 a = a*((rand()%2==0)?1:-1);
1146 b = b*((rand()%2==0)?1:-1);
1148 if ( ic.
gcd( a, b ) == 1 )
1151 for (
unsigned int j = 0; j < 5; ++j )
1154 Integer mu = rand() % (2*modb);
1155 DSL baseDSL(a,b,-mu);
1157 for (
Integer x = 0; x < 10; ++x )
1159 Integer elemMove = (b>0)?1:-1;
1165 Integer x2 = x1 + (modx + (rand() % modx))*elemMove;
1178 Integer x3 = x1 + (rand() % (2*modb))*elemMove;
1181 Integer x4 = x3 + modx*elemMove;
1184 if(baseDSL.shift()[1] < 0)
1200 aDSL = DSL(b,-a,-mu);
1219 DSS DSSres = DSS1.computeUnion(DSS2);
1224 if(abs(aDSL.a())<=abs(aDSL.b()))
1235 DSS DSSGroundTruth(DSS1);
1236 if(aDSL.before(B,D))
1244 DSSGroundTruth.extendFront(*it);
1249 if(DSSres != DSSGroundTruth)
1252 trace.
info() <<
"DSS1 " << DSS1 <<
"\n" <<
"DSS2 " << DSS2 << std::endl;
1254 trace.
info() << DSSGroundTruth << std::endl;
1257 nbok+=(DSSres == DSSGroundTruth)?1:0;
1264 if((aDSL.beforeOrEqual(DSSres.Uf(),B) && !aDSL.isInDSL(DSSres.Uf())) || (!aDSL.before(DSSres.Uf(),C) && !aDSL.isInDSL(DSSres.Uf())))
1266 if((aDSL.beforeOrEqual(DSSres.Ul(),B) && !aDSL.isInDSL(DSSres.Ul())) || (!aDSL.before(DSSres.Ul(),C) && !aDSL.isInDSL(DSSres.Ul())))
1268 if((aDSL.beforeOrEqual(DSSres.Lf(),B) && !aDSL.isInDSL(DSSres.Lf())) || (!aDSL.before(DSSres.Lf(),C) && !aDSL.isInDSL(DSSres.Lf())))
1270 if((aDSL.beforeOrEqual(DSSres.Ll(),B) && !aDSL.isInDSL(DSSres.Ll())) || (!aDSL.before(DSSres.Ll(),C) && !aDSL.isInDSL(DSSres.Ll())))
1273 if(error || !DSSres.isValid() || DSSres==DSS(
Point(0,0)))
1276 trace.
info() <<
"DSS1 " << DSS1 <<
"\n" <<
"DSS2 " << DSS2 << std::endl;
1278 trace.
info() <<
"--------------------------------\n";
1293 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
1294 << nbEasy <<
" easy cases." << std::endl;
1304 unsigned int nb = 0;
1305 unsigned int nbok = 0;
1307 trace.
beginBlock(
"Testing creation of a DSS from direction vector, two endpoints and one upper leaning point");
1313 nbok += (Factory::createDSS(3,5,
Point(-6,-4),
Point(14,8),
Point(5,3)) == DSS8(3,5,
Point(-6,-4),
Point(14,8),
Point(-5,-3),
Point(10,6),
Point(-2,-2),
Point(13,7)))?1:0;
1316 nbok += (Factory::createDSS(3,5,
Point(0,0),
Point(14,8),
Point(3,2)) == DSS8(3,5,
Point(0,0),
Point(14,8),
Point(3,2),
Point(13,8),
Point(1,0),
Point(11,6)))?1:0;
1319 nbok += (Factory::createDSS(3,5,
Point(-3,-2),
Point(14,8),
Point(3,2)) == DSS8(3,5,
Point(-3,-2),
Point(14,8),
Point(-2,-1),
Point(13,8),
Point(1,0),
Point(11,6)))?1:0;
1322 nbok += (Factory::createDSS(3,5,
Point(0,0),
Point(14,8),
Point(3,2)) == DSS8(3,5,
Point(0,0),
Point(14,8),
Point(3,2),
Point(13,8),
Point(1,0),
Point(11,6)))?1:0;
1325 nbok += (Factory::createDSS(3,5,
Point(0,0),
Point(14,8),
Point(3,2)) == DSS8(3,5,
Point(0,0),
Point(14,8),
Point(3,2),
Point(13,8),
Point(1,0),
Point(11,6)))?1:0;
1335 unsigned int nbok = 0;
1336 unsigned int nb = 0;
1345 nbok += (dss == DSS8(-3,-1,
Point(0,0),
Point(-1,-3),
Point(0,0),
Point(-1,-3),
Point(-1,-1),
Point(-1,-1)));
1349 nbok += (dss == DSS8(-1,10,
Point(0,0),
Point(10,-1),
Point(0,0),
Point(10,-1),
Point(1,-1),
Point(1,-1)));
1353 return (nb == nbok);
1363 for (
int i = 0; i < argc; ++i )
1368 bool res = mainTest<DGtal::ArithmeticalDSS<DGtal::int32_t> >()
1369 #ifdef WITH_BIGINTEGER
1372 && mainTest<DGtal::NaiveDSS8<DGtal::int32_t> >()
1453 && updateTest<DGtal::ArithmeticalDSS<DGtal::int32_t> >()
1454 #ifdef WITH_BIGINTEGER
1460 && constructorsTest<DGtal::ArithmeticalDSS<DGtal::int32_t> >()
1461 #ifdef WITH_BIGINTEGER
1464 && constructorsTest<DGtal::NaiveDSS8<DGtal::int32_t> >()
1470 && comparisonSubsegment<NaiveDSL<DGtal::int32_t> >(5,8)
1472 && comparisonSubsegment<NaiveDSL<DGtal::int32_t> >(12,29)
1474 && comparisonSubsegment<NaiveDSL<DGtal::int32_t> >(-5,8)
1476 && comparisonSubsegment<NaiveDSL<DGtal::int32_t> >(5,-8)
1478 && comparisonSubsegment<NaiveDSL<DGtal::int32_t> >(-5,-8)
1481 && comparisonSubsegment<StandardDSL<DGtal::int32_t> >(5,8)
1483 && comparisonSubsegment<StandardDSL<DGtal::int32_t> >(-5,8)
1485 && comparisonSubsegment<StandardDSL<DGtal::int32_t> >(5,-8)
1487 && comparisonSubsegment<StandardDSL<DGtal::int32_t> >(-5,-8)
1489 #ifdef WITH_BIGINTEGER
1490 && comparisonSubsegment<StandardDSL<DGtal::int32_t, DGtal::BigInteger> >(5,8)
1505 res = res && unionComparisonTest<DGtal::int64_t,DGtal::int64_t,8>(43577,1276,200);
1506 res = res && unionComparisonTest<DGtal::int64_t, DGtal::int64_t, 4>(86731,6648,200);
1510 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Set of static methods that create digital straight segments (DSS) from some input parameters,...
Aim: This class represents a naive (resp. standard) digital straight segment (DSS),...
Integer ceilDiv(IntegerParamType na, IntegerParamType nb) const
Integer dotProduct(const Vector2I &u, const Vector2I &v) const
Integer gcd(IntegerParamType a, IntegerParamType b) const
Integer floorDiv(IntegerParamType na, IntegerParamType nb) const
Aim: This class is an alias of ArithmeticalDSS for naive DSL. It represents a naive digital straight ...
Aim: This class is an alias of ArithmeticalDSS for standard DSL. It represents a standard digital str...
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 4-co...
void beginBlock(const std::string &keyword="")
DigitalPlane::Point Vector
Point::Coordinate Integer
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Small class that contains the code that depends on the arithmetical thickness (either naive or s...
Aim: Defines the concept describing a bidirectional const range.
Aim: Defines a predicate on a point.
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/BidirectionalTraversal....
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/ReadableIterator.html.
bool unionComparisonTest(int modb, int modx, unsigned int nbtries)
bool rangeTest(const DSS &dss)
int main(int argc, char **argv)
void retractionTest(const DSS &dss, unsigned int &nbok, unsigned int &nb, bool res=true)
void extensionTest(const DSS &dss, typename DSS::Point newPointToFront, typename DSS::Point newPointToBack, unsigned int &nbok, unsigned int &nb, const unsigned short int &code=0)
bool compatibleStepsTest(const DSS &dss)
bool comparisonSubsegment(const DSS &aDSS, typename DSS::Position x, typename DSS::Position y)
bool testPatchCreatePattern()