34#include "DGtal/base/Common.h"
35#include "DGtal/kernel/SpaceND.h"
36#include "DGtal/kernel/domains/HyperRectDomain.h"
37#include "DGtal/kernel/sets/DigitalSetSelector.h"
38#include "DGtal/topology/KhalimskySpaceND.h"
39#include "DGtal/topology/SurfelAdjacency.h"
40#include "DGtal/topology/SurfelNeighborhood.h"
42#include "DGtal/shapes/Shapes.h"
43#include "DGtal/shapes/ShapeFactory.h"
44#include "DGtal/shapes/GaussDigitizer.h"
46#include "DGtal/geometry/curves/GridCurve.h"
47#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
48#include "DGtal/geometry/curves/estimation/CCurveLocalGeometricEstimator.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"
54#include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
55#include "DGtal/geometry/curves/estimation/CompareLocalEstimators.h"
58#include "ConfigTest.h"
74 trace.
info() <<
"Reading GridCurve " << endl;
76 instream.open (filename.c_str(), ifstream::in);
81 Range r = c.getPointsRange();
99 TrueCurvatureEstimator curvatureEstimator;
100 TrueTangentEstimator tangentEstimator;
101 TrueLengthEstimator lengthEstimator;
103 curvatureEstimator.attach( ball );
104 tangentEstimator.attach( ball );
105 lengthEstimator.attach ( ball );
107 ConstIteratorOnPoints it = r.begin();
108 ConstIteratorOnPoints it2 = it+15;
110 trace.
info() <<
"Current point = " << *it << std::endl;
111 trace.
info() <<
"Current point+15 = " << *it2 << std::endl;
114 trace.
info() <<
"Eval curvature (begin, h=1) = " << curvatureEstimator.eval(it2, 1.) << std::endl;
115 trace.
info() <<
"Eval tangent (begin, h=1) = " << tangentEstimator.eval(it2, 1.) << std::endl;
116 trace.
info() <<
"Eval length (h=1) = " << lengthEstimator.eval(it, it2, 1.) << std::endl;
117 trace.
info() <<
"Eval ball length (h=1) = " << lengthEstimator.eval() << std::endl;
122template <
typename Shape>
125 Shape & aShape,
double h )
138 dig.
init( xLow, xUp, h );
149 std::cerr <<
"[testTrueLocalEstimatorOnShapeDigitization]"
150 <<
" error in creating KSpace." << std::endl;
160 std::vector<Point> points;
172 curvatureEstimator.
attach( aShape );
174 std::cout <<
"# idx x y kappa" << endl;
176 for ( ConstIteratorOnPoints it = r.begin(), ite = r.end();
177 it != ite; ++it, ++i )
180 const double kappa = curvatureEstimator.
eval( it, h );
181 std::cout << i <<
" " << x[0] <<
" " << x[1]
182 <<
" " << kappa << std::endl;
187 std::cerr <<
"[testTrueLocalEstimatorOnShapeDigitization]"
188 <<
" error in finding a bel." << std::endl;
192 trace.
emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
201int main(
int argc,
char** argv )
205 for (
int i = 0; i < argc; ++i )
209 std::string sinus2D4 = testPath +
"samples/sinus2D4.dat";
212 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
216 MyEllipse ellipse( 1.2, 0.1, 4.0, 3.0, 0.3 );
218 testTrueLocalEstimatorOnShapeDigitization<MyEllipse>
219 (
"Ellipse-4-3-0.3-s1", ellipse, 1 );
221 testTrueLocalEstimatorOnShapeDigitization<MyEllipse>
222 (
"Ellipse-4-3-0.3-s0.5", ellipse, 0.5 );
225 MyFlower flower( 0.5, -2.3, 5.0, 0.7, 6, 0.3 );
227 testTrueLocalEstimatorOnShapeDigitization<MyFlower>
228 (
"Flower-5-0.3-6-0.3-s1", flower, 1 );
230 testTrueLocalEstimatorOnShapeDigitization<MyFlower>
231 (
"Flower-5-0.3-6-0.3-s0.25", flower, 0.25 );
Aim: Model of the concept StarShaped represents any circle in the plane.
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Aim: Model of the concept StarShaped represents any ellipse in the plane.
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
const Point & getUpperBound() const
void attach(ConstAlias< EuclideanShape > shape)
const Point & getLowerBound() const
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
bool initFromVectorStream(std::istream &in)
PointsRange getPointsRange() const
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: implements a functor that estimates the arc length of a paramtric curve.
Aim: implements a functor that computes the curvature at a given point of a parametric shape.
Aim: implements a functor that computes the tangent vector at a given point of a parametric shape.
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
TConstIterator ConstIterator
static void track2DBoundaryPoints(std::vector< Point > &aVectorOfPoints, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
Aim: Computes the true quantity associated to a parametric shape or to a subrange associated to a par...
Aim: Computes the true quantity to each element of a range associated to a parametric shape.
Quantity eval(const ConstIterator &it, const double h=1.) const
void attach(const ParametricShape &aShape)
DGtal is the top-level namespace which contains all DGtal functions and types.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: This concept describes an object that can process a range so as to return one estimated quantity...
bool testTrueLocalEstimator(const std::string &filename)
bool testTrueLocalEstimatorOnShapeDigitization(const string &name, Shape &aShape, double h)