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"
69 typedef string::const_iterator codeIterator;
78 std::string filename = testPath +
"samples/france.fc";
80 fst.open (filename.c_str(), std::ios::in);
84 for ( string::const_iterator it = theContour.
chain.begin(); it != theContour.
chain.end(); ++it )
89 list<char>::iterator it = l.begin();
91 OneBalancedWordComputer_list C1;
94 OneBalancedWordComputer_list C2;
95 C2.init( C1.begin() );
97 OneBalancedWordComputer_string C3;
98 C3.init( theContour );
100 OneBalancedWordComputer_string C4;
101 C4.init( theContour.
begin() );
104 while ( C3.end() != theContour.
chain.end() )
106 bool b1 = C1.extendFront();
107 bool b2 = C2.extendFront();
108 bool b3 = C3.extendFront();
109 bool b4 = C4.extendFront();
110 if ( b1 && b2 && b3 && b4 )
113 else if ( !b1 && !b2 && !b3 && !b4 )
123 cout << b1 <<
" " << b2 <<
" " << b3 <<
" " << b4 << endl;
132 return (nbRetract == 3485) ;
142 typedef string::const_iterator codeIterator;
148 std::string filename = testPath +
"samples/manche.fc";
150 fst.open (filename.c_str(), std::ios::in);
152 Contour::ConstIterator it = theContour.
begin();
158 while ( C.end() != theContour.
chain.end() )
160 bool a = A.extendFront();
161 bool c = C.extendFront();
165 cout <<
"Extension test error\n";
174 if ( ( C.back() != A.back() ) || ( C.front() != A.front() ) )
177 cout <<
"Equality test error\n";
181 if ( ( C.getA() != A.a() ) || ( C.getB() != A.b() ) ||
182 ( C.getMu() != A.mu() ) || ( C.getOmega() != A.omega() ) ||
183 ( C.Uf() != A.Uf() ) || ( C.Ul() != A.Ul() ) ||
184 ( C.Lf() != A.Lf() ) || ( C.Ll() != A.Ll() )
187 cout <<
"Arithmetic parameters error\n";
190 cout <<
"a() " << C.getA() <<
" --- " << A.a() <<
"\n";
191 cout <<
"b() " << C.getB() <<
" --- " << A.b() <<
"\n";
192 cout <<
"mu() " << C.getMu() <<
" --- " << A.mu() <<
"\n";
193 cout <<
"omega()" << C.getOmega() <<
" --- " << A.omega() <<
"\n";
194 cout <<
"Uf() " << C.Uf() <<
" --- " << A.Uf() <<
"\n";
195 cout <<
"Ul() " << C.Ul() <<
" --- " << A.Ul() <<
"\n";
196 cout <<
"Lf() " << C.Lf() <<
" --- " << A.Lf() <<
"\n";
197 cout <<
"Ll() " << C.Ll() <<
" --- " << A.Ll() << endl;
214 std::string filename = testPath +
"samples/BigBall.fc";
216 fst.open (filename.c_str(), std::ios::in);
219 trace.
beginBlock (
"Test OneBalancedWordComputer in greedy segmentation" );
220 combinSegmentation combin_dec( theContour.
chain.begin(), theContour.
chain.end(), combinDSS() );
221 vector<combinDSS> theCombinDSS;
222 for ( combinSegmentation::SegmentComputerIterator i = combin_dec.begin();
223 i != combin_dec.end(); ++i )
226 theCombinDSS.push_back( c );
228 bool ok = ( theCombinDSS.size() == 1593 );
252 std::stringstream ss(stringstream::in | stringstream::out);
253 ss <<
"31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111" << endl;
256 Decomposition theDecomposition( theContour.
chain.begin(), theContour.
chain.end(), combinDSS() );
263 <<
SetMode(
"PointVector",
"Grid" )
269 for ( Decomposition::SegmentComputerIterator i = theDecomposition.begin();
270 i != theDecomposition.end(); ++i )
272 combinDSS segment(*i);
274 segment.setPosition( p );
277 p = *( --( --( segment.pointEnd() )));
280 arithDSS toShow( *segment.pointBegin(), *segment.pointBegin() );
281 for (combinDSS::ConstPointIterator it = segment.pointBegin(),
282 itEnd = segment.pointEnd(); it != itEnd; ++it )
283 toShow.extendFront( *it );
285 aBoard <<
SetMode( toShow.className(),
"BoundingBox" )
289 aBoard.
saveSVG(
"testCombinDSS-greedy.svg");
297int main(
int argc,
char** argv )
301 for (
int i = 0; i < argc; ++i )
310 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()
bool testOneBalancedWordComputer()
FreemanChain< int >::Vector Vector
bool testInGreedySegmentation()
FreemanChain< int > Contour
bool CompareToArithmetical()