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 )
137 dig.
init( xLow, xUp, h );
148 std::cerr <<
"[testTrueLocalEstimatorOnShapeDigitization]"
149 <<
" error in creating KSpace." << std::endl;
159 std::vector<Point> points;
171 curvatureEstimator.
attach( aShape );
173 std::cout <<
"# idx x y kappa" << endl;
175 for ( ConstIteratorOnPoints it = r.begin(), ite = r.end();
176 it != ite; ++it, ++i )
179 const double kappa = curvatureEstimator.
eval( it, h );
180 std::cout << i <<
" " << x[0] <<
" " << x[1]
181 <<
" " << kappa << std::endl;
186 std::cerr <<
"[testTrueLocalEstimatorOnShapeDigitization]"
187 <<
" error in finding a bel." << std::endl;
191 trace.
emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
200int main(
int argc,
char** argv )
204 for (
int i = 0; i < argc; ++i )
208 std::string sinus2D4 = testPath +
"samples/sinus2D4.dat";
211 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
215 MyEllipse ellipse( 1.2, 0.1, 4.0, 3.0, 0.3 );
218 (
"Ellipse-4-3-0.3-s1", ellipse, 1 );
221 (
"Ellipse-4-3-0.3-s0.5", ellipse, 0.5 );
224 MyFlower flower( 0.5, -2.3, 5.0, 0.7, 6, 0.3 );
227 (
"Flower-5-0.3-6-0.3-s1", flower, 1 );
230 (
"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)