43 #include "DGtal/base/Common.h"
44 #include "DGtal/base/Exceptions.h"
45 #include "DGtal/io/boards/Board2D.h"
47 #include "DGtal/topology/KhalimskySpaceND.h"
49 #include "DGtal/geometry/curves/GridCurve.h"
50 #include "DGtal/geometry/curves/ArithmeticalDSS.h"
51 #include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
54 #include "ConfigTest.h"
57 using namespace DGtal;
59 using namespace LibBoard;
70 bool test(
const I& itb,
const I& ite)
72 typedef I ConstIterator;
76 typedef typename SCEstimator::Quantity Value;
86 unsigned int nbok = 0;
87 std::vector<Value> v1, v2, v3;
90 trace.
info() <<
"Eval at one element" << endl;
93 ConstIterator it = itb;
106 trace.
info() <<
"Eval for each element between begin and end " << endl;
107 e.eval(itb, ite, std::back_inserter(v2));
109 for (
typename std::vector<Value>::iterator i = v2.begin(); i != v2.end(); ++i) {
115 nbok += ( ( v1.size() == v2.size() ) &&
116 ( std::equal(v1.begin(), v1.end(), v2.begin() ) ) )?1:0;
119 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
121 if ( (ite-itb) >= 10)
124 trace.
info() <<
"Eval for each element between begin+4 and begin+9 " << endl;
126 e.eval((itb+4),(itb+9),std::back_inserter(v3));
128 for (
typename vector<Value>::iterator i = v3.begin(); i != v3.end(); ++i) {
133 nbok += ( (v3.size() == 5) &&
134 ( std::equal( (v1.begin()+4), (v1.begin()+9), v3.begin()) ) )?1:0;
137 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
147 bool testEval(
string filename)
151 trace.
info() <<
"Reading GridCurve from " << filename << endl;
154 instream.open (filename.c_str(), ifstream::in);
161 trace.
info() <<
"Building Estimator (process range as";
165 return test(r.c(), r.c());
175 int main(
int argc,
char **argv)
178 trace.
beginBlock (
"Testing class MostCenteredMaximalSegmentEstimator" );
180 for (
int i = 0; i < argc; ++i )
184 std::string sinus2D4 = testPath +
"samples/sinus2D4.dat";
185 std::string square = testPath +
"samples/smallSquare.dat";
186 std::string dss = testPath +
"samples/DSS.dat";
188 bool res = testEval(sinus2D4)
193 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;