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/ArithmeticalDSSComputer.h"
51 #include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
52 #include "DGtal/geometry/curves/estimation/CCurveLocalGeometricEstimator.h"
55 #include "ConfigTest.h"
58 using namespace DGtal;
71 bool test(
const I& itb,
const I& ite)
73 typedef I ConstIterator;
77 typedef typename SCEstimator::Quantity Value;
87 unsigned int nbok = 0;
88 std::vector<Value> v1, v2, v3;
91 trace.
info() <<
"Eval at one element" << endl;
94 ConstIterator it = itb;
107 trace.
info() <<
"Eval for each element between begin and end " << endl;
108 e.eval(itb, ite, std::back_inserter(v2));
110 for (
typename std::vector<Value>::iterator i = v2.begin(); i != v2.end(); ++i) {
116 nbok += ( ( v1.size() == v2.size() ) &&
117 ( std::equal(v1.begin(), v1.end(), v2.begin() ) ) )?1:0;
120 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
122 if ( (ite-itb) >= 10)
125 trace.
info() <<
"Eval for each element between begin+4 and begin+9 " << endl;
127 e.eval((itb+4),(itb+9),std::back_inserter(v3));
129 for (
typename vector<Value>::iterator i = v3.begin(); i != v3.end(); ++i) {
134 nbok += ( (v3.size() == 5) &&
135 ( std::equal( (v1.begin()+4), (v1.begin()+9), v3.begin()) ) )?1:0;
138 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
148 bool testEval(
string filename)
152 trace.
info() <<
"Reading GridCurve from " << filename << endl;
155 instream.open (filename.c_str(), ifstream::in);
162 trace.
info() <<
"Building Estimator (process range as";
166 return test(r.
c(), r.
c());
176 int main(
int argc,
char **argv)
179 trace.
beginBlock (
"Testing class MostCenteredMaximalSegmentEstimator" );
181 for (
int i = 0; i < argc; ++i )
185 std::string sinus2D4 = testPath +
"samples/sinus2D4.dat";
186 std::string
square = testPath +
"samples/smallSquare.dat";
187 std::string dss = testPath +
"samples/DSS.dat";
189 bool res = testEval(sinus2D4)
194 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
void beginBlock(const std::string &keyword="")
PointsRange getPointsRange() const
Aim: A model of CLocalCurveGeometricEstimator that assigns to each element of a (sub)range a quantity...
Struct representing a 2D point.
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Aim: This concept describes an object that can process a range so as to return one estimated quantity...
bool initFromVectorStream(std::istream &in)
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...
bool isNotEmpty(const IC &itb, const IC &ite)