32 #include "DGtal/base/Common.h" 
   35 #include "DGtal/kernel/SpaceND.h" 
   36 #include "DGtal/kernel/domains/HyperRectDomain.h" 
   37 #include "DGtal/topology/KhalimskySpaceND.h" 
   40 #include "DGtal/shapes/ShapeFactory.h" 
   41 #include "DGtal/shapes/Shapes.h" 
   42 #include "DGtal/helpers/StdDefs.h" 
   43 #include "DGtal/topology/helpers/Surfaces.h" 
   45 #include "DGtal/shapes/GaussDigitizer.h" 
   46 #include "DGtal/geometry/curves/GridCurve.h" 
   49 #include "DGtal/geometry/curves/estimation/TrueLocalEstimatorOnPoints.h" 
   50 #include "DGtal/geometry/curves/estimation/TrueGlobalEstimatorOnPoints.h" 
   51 #include "DGtal/geometry/curves/estimation/ParametricShapeCurvatureFunctor.h" 
   52 #include "DGtal/geometry/curves/estimation/ParametricShapeTangentFunctor.h" 
   53 #include "DGtal/geometry/curves/estimation/ParametricShapeArcLengthFunctor.h" 
   55 #include "DGtal/geometry/curves/estimation/L1LengthEstimator.h" 
   56 #include "DGtal/geometry/curves/estimation/TwoStepLocalLengthEstimator.h" 
   57 #include "DGtal/geometry/curves/estimation/BLUELocalLengthEstimator.h" 
   58 #include "DGtal/geometry/curves/estimation/RosenProffittLocalLengthEstimator.h" 
   60 #include "DGtal/geometry/curves/estimation/MLPLengthEstimator.h" 
   61 #include "DGtal/geometry/curves/estimation/FPLengthEstimator.h" 
   62 #include "DGtal/geometry/curves/estimation/DSSLengthEstimator.h" 
   64 #include "ConfigTest.h" 
   66 #include "DGtal/io/boards/Board2D.h" 
   71 using namespace DGtal;
 
   78 bool testLengthEstimatorsOnBall(
double radius, 
double h)
 
   84   typedef Space::Point 
Point;
 
   85   typedef Space::RealPoint RealPoint;
 
   89   typedef KSpace::SCell 
SCell;
 
   92   typedef PointsRange::ConstIterator ConstIteratorOnPoints;
 
   96   Shape aShape(Point(0,0), radius);
 
   98   trace.
info() << 
"#ball created, r=" << radius << endl;
 
  101   RealPoint xLow ( -radius-1, -radius-1 );
 
  102   RealPoint xUp( radius+1, radius+1 );
 
  105   dig.
init( xLow, xUp, h ); 
 
  115                 << 
" error in creating KSpace." << std::endl;
 
  124     std::vector<Point> points;
 
  130     trace.
info() << 
"#grid curve created, h=" << h << endl;
 
  137     double trueValue = 
M_PI*2*radius;
 
  139     l1length.
init(h, ra.c(), ra.c());
 
  141     locallength.init(h, ra.begin(), ra.end(), gridcurve.
isClosed());
 
  143     BLUElength.
init(h, ra.begin(), ra.end(), gridcurve.
isClosed());
 
  145     RosenProffittlength.
init(h, ra.begin(), ra.end(), gridcurve.
isClosed());
 
  147     DSSlength.
init(h, rp.begin(), rp.end(), gridcurve.
isClosed());
 
  149     MLPlength.
init(h, rp.begin(), rp.end(), gridcurve.
isClosed());
 
  151     FPlength.
init(h, rp.begin(), rp.end(), gridcurve.
isClosed());
 
  153     trace.
info() << 
"#Estimations" <<std::endl;
 
  154     trace.
info() << 
"#h true naive 1-sqrt(2) BLUE RosenProffitt DSS MLP FP " <<std::endl;
 
  156                  << 
" " << l1length.
eval() 
 
  157                  << 
" " << locallength.eval() 
 
  158                  << 
" " << BLUElength.
eval() 
 
  159                  << 
" " << RosenProffittlength.
eval() 
 
  160                  <<  
" " << DSSlength.
eval() 
 
  161                  << 
" " << MLPlength.
eval() 
 
  162                  <<  
" " << FPlength.
eval() << std::endl;
 
  168                 << 
" error in finding a bel." << std::endl;
 
  179 bool testDisplay(
double radius, 
double h)
 
  189   typedef KSpace::SCell SCell;
 
  193   typedef PointsRange::ConstIterator ConstIteratorOnPoints;
 
  197   Shape aShape(Point(0,0), radius);
 
  199   trace.
info() << 
"#ball created, r=" << radius << endl;
 
  202   RealPoint xLow ( -radius-1, -radius-1 );
 
  203   RealPoint xUp( radius+1, radius+1 );
 
  206   dig.
init( xLow, xUp, h ); 
 
  216                 << 
" error in creating KSpace." << std::endl;
 
  225     std::vector<Point> points;
 
  231     trace.
info() << 
"#grid curve created, h=" << h << endl;
 
  244     board << domain << 
set;
 
  245     board.
saveSVG( 
"Ranges-Set.svg" );
 
  253     board.
saveSVG( 
"Ranges-Points.svg" );
 
  262     board.
saveSVG( 
"Ranges-SCells.svg" );
 
  277     board.
saveSVG( 
"Ranges-Arrows.svg" );
 
  283                 << 
" error in finding a bel." << std::endl;
 
  295 int main( 
int argc, 
char** argv )
 
  299   for ( 
int i = 0; i < argc; ++i )
 
  304   bool res = testLengthEstimatorsOnBall(r,1)
 
  305     && testLengthEstimatorsOnBall(r,0.1)
 
  306     && testLengthEstimatorsOnBall(r,0.01)
 
  307     && testLengthEstimatorsOnBall(r,0.001)
 
  308     && testDisplay(r,0.9);
 
  311   trace.
emphase() << ( res ? 
"Passed." : 
"Error." ) << endl;