39 #include "DGtal/base/Common.h"
40 #include "DGtal/helpers/StdDefs.h"
41 #include "DGtal/io/boards/Board2D.h"
42 #include "DGtal/geometry/curves/OneBalancedWordComputer.h"
43 #include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
44 #include "ConfigTest.h"
45 #include "DGtal/geometry/curves/CDynamicBidirectionalSegmentComputer.h"
46 #include "DGtal/geometry/curves/GreedySegmentation.h"
51 using namespace DGtal;
68 typedef string::const_iterator codeIterator;
77 std::string filename = testPath +
"samples/france.fc";
79 fst.open (filename.c_str(), std::ios::in);
83 for ( string::const_iterator it = theContour.
chain.begin(); it != theContour.
chain.end(); ++it )
88 list<char>::iterator it = l.begin();
90 OneBalancedWordComputer_list C1;
93 OneBalancedWordComputer_list C2;
94 C2.init( C1.begin() );
96 OneBalancedWordComputer_string C3;
97 C3.init( theContour );
99 OneBalancedWordComputer_string C4;
100 C4.init( theContour.
begin() );
103 while ( C3.end() != theContour.
chain.end() )
105 bool b1 = C1.extendFront();
106 bool b2 = C2.extendFront();
107 bool b3 = C3.extendFront();
108 bool b4 = C4.extendFront();
109 if ( b1 && b2 && b3 && b4 )
112 else if ( !b1 && !b2 && !b3 && !b4 )
122 cout << b1 <<
" " << b2 <<
" " << b3 <<
" " << b4 << endl;
131 return (nbRetract == 3485) ;
141 typedef string::const_iterator codeIterator;
147 std::string filename = testPath +
"samples/manche.fc";
149 fst.open (filename.c_str(), std::ios::in);
157 while ( C.end() != theContour.
chain.end() )
159 bool a = A.extendFront();
160 bool c = C.extendFront();
164 cout <<
"Extension test error\n";
173 if ( ( C.back() != A.back() ) || ( C.front() != A.front() ) )
176 cout <<
"Equality test error\n";
180 if ( ( C.getA() != A.a() ) || ( C.getB() != A.b() ) ||
181 ( C.getMu() != A.mu() ) || ( C.getOmega() != A.omega() ) ||
182 ( C.Uf() != A.Uf() ) || ( C.Ul() != A.Ul() ) ||
183 ( C.Lf() != A.Lf() ) || ( C.Ll() != A.Ll() )
186 cout <<
"Arithmetic parameters error\n";
189 cout <<
"a() " << C.getA() <<
" --- " << A.a() <<
"\n";
190 cout <<
"b() " << C.getB() <<
" --- " << A.b() <<
"\n";
191 cout <<
"mu() " << C.getMu() <<
" --- " << A.mu() <<
"\n";
192 cout <<
"omega()" << C.getOmega() <<
" --- " << A.omega() <<
"\n";
193 cout <<
"Uf() " << C.Uf() <<
" --- " << A.Uf() <<
"\n";
194 cout <<
"Ul() " << C.Ul() <<
" --- " << A.Ul() <<
"\n";
195 cout <<
"Lf() " << C.Lf() <<
" --- " << A.Lf() <<
"\n";
196 cout <<
"Ll() " << C.Ll() <<
" --- " << A.Ll() << endl;
213 std::string filename = testPath +
"samples/BigBall.fc";
215 fst.open (filename.c_str(), std::ios::in);
218 trace.
beginBlock (
"Test OneBalancedWordComputer in greedy segmentation" );
219 combinSegmentation combin_dec( theContour.
chain.begin(), theContour.
chain.end(), combinDSS() );
220 vector<combinDSS> theCombinDSS;
221 for ( combinSegmentation::SegmentComputerIterator i = combin_dec.begin();
222 i != combin_dec.end(); ++i )
225 theCombinDSS.push_back( c );
227 bool ok = ( theCombinDSS.size() == 1593 );
251 std::stringstream ss(stringstream::in | stringstream::out);
252 ss <<
"31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111" << endl;
255 Decomposition theDecomposition( theContour.
chain.begin(), theContour.
chain.end(), combinDSS() );
262 <<
SetMode(
"PointVector",
"Grid" )
268 for ( Decomposition::SegmentComputerIterator i = theDecomposition.begin();
269 i != theDecomposition.end(); ++i )
271 combinDSS segment(*i);
273 segment.setPosition( p );
276 p = *( --( --( segment.pointEnd() )));
279 arithDSS toShow( *segment.pointBegin(), *segment.pointBegin() );
280 for (combinDSS::ConstPointIterator it = segment.pointBegin(),
281 itEnd = segment.pointEnd(); it != itEnd; ++it )
282 toShow.extendFront( *it );
284 aBoard <<
SetMode( toShow.className(),
"BoundingBox" )
288 aBoard.
saveSVG(
"testCombinDSS-greedy.svg");
296 int main(
int argc,
char** argv )
300 for (
int i = 0; i < argc; ++i )
309 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
ConstIterator begin() const
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
std::string className() const
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 4-co...
void beginBlock(const std::string &keyword="")
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Aim: Defines the concept describing a dynamic and bidirectional segment computer, ie....
bool showGreedySegmantation()
int main(int argc, char **argv)
bool testOneBalancedWordComputer()
bool testInGreedySegmentation()
FreemanChain< int > Contour
bool CompareToArithmetical()