31 #include "DGtal/base/Common.h"
35 #include "DGtal/geometry/curves/DSLSubsegment.h"
36 #include "DGtal/arithmetic/StandardDSLQ0.h"
37 #include "DGtal/kernel/CPointPredicate.h"
38 #include "DGtal/arithmetic/IntegerComputer.h"
39 #include "DGtal/arithmetic/SternBrocot.h"
40 #include "DGtal/arithmetic/LighterSternBrocot.h"
41 #include "DGtal/arithmetic/LightSternBrocot.h"
42 #include "DGtal/arithmetic/Pattern.h"
43 #include "DGtal/geometry/curves/ArithDSSIterator.h"
44 #include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
45 #include "DGtal/base/Clock.h"
48 using namespace DGtal;
57 template <
typename Integer,
typename Fraction>
83 while(ic.
gcd(a,b) !=1)
94 trace.
beginBlock(
"Draw random values for a,b,mu and abscissa of the first point");
95 trace.
info() <<
"a b mu xf:" << a <<
" " << b <<
" " << mu <<
" " << xf << std::endl;
103 trace.
beginBlock(
"Compare DSLSubsegment/Farey fan with ArithmeticalDSS algorithm");
104 for(
unsigned int i = 0; i<l; i++)
105 for(
unsigned int j = i+1; j<l; j++)
116 DSLSubseg DSLsub(a,b,mu,A,B,
"farey");
120 DSSIterator it(a,b,-mu,A);
121 ArithDSS myDSS(*it, *it);
123 while ( (*it)[0] <=x2 && myDSS.extendFront(*it))
127 if(DSLsub.getA() != myDSS.a() || DSLsub.getB() != myDSS.b() || DSLsub.getMu() != - myDSS.mu())
130 trace.
info() << error1 <<
" errors." << std::endl;
135 trace.
beginBlock(
"Compare DSLSubsegment/localCH with DSLSubsegment/FareyFan");
136 for(
unsigned int i = 0; i<l; i++)
137 for(
unsigned int j = i+1; j<l; j++)
148 DSLSubseg DSLsubCH(a,b,mu,A,B,
"localCH");
151 DSLSubseg DSLsubF(a,b,mu,A,B,
"farey");
155 if(DSLsubCH.getA() != DSLsubF.getA() || DSLsubCH.getB() != DSLsubF.getB() || DSLsubCH.getMu() != DSLsubF.getMu())
159 trace.
info() << error2 <<
" errors." << std::endl;
164 trace.
beginBlock(
"Compare DSLSubsegment/FareyFan with ReversedSmartDSS for 4-connected DSL");
165 for(
unsigned int i = 0; i<l; i++)
166 for(
unsigned int j = i+1; j<l; j++)
172 PointDSL AA = D.lowestY( x1 );
173 PointDSL BB = D.lowestY( x2 );
176 DSL S = D.reversedSmartDSS(AA,BB);
189 DSLSubseg D2(a,a+b,-mu,A2,B2,
"farey");
192 if(!(D2.getA()==S.a() && (D2.getB()-D2.getA())==S.b() && D2.getMu()==-S.mu()))
196 trace.
info() << error3 <<
" errors." << std::endl;
200 return (error1==0 && error2==0 && error3==0);
213 typedef LSB::Fraction Fraction;
219 srand((
unsigned int)time(NULL));
221 bool res = testDSLSubsegment<Integer,Fraction>(i);
223 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: An iterator on the points of a Digital Straight Segment. Template parameters are the integer typ...
Aim: Given a Digital Straight line and two endpoints A and B on this line, compute the minimal charac...
Integer gcd(IntegerParamType a, IntegerParamType b) const
Integer floorDiv(IntegerParamType na, IntegerParamType nb) const
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 8-co...
Aim: Represents a digital straight line with slope in the first quadrant (Q0: x >= 0,...
void beginBlock(const std::string &keyword="")
Point::Coordinate Integer
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int64_t int64_t
signed 94-bit integer.
bool testDSLSubsegment(Integer modb)