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" 63 using namespace DGtal;
74 trace.
info() <<
"Reading GridCurve " << endl;
76 instream.open (filename.c_str(), ifstream::in);
81 Range r = c.getPointsRange();
100 TrueCurvatureEstimator curvatureEstimator;
101 TrueTangentEstimator tangentEstimator;
102 TrueLengthEstimator lengthEstimator;
104 curvatureEstimator.init( 1, r.begin(), r.end() );
105 curvatureEstimator.attach( &ball );
106 tangentEstimator.init( 1, r.begin(), r.end() );
107 tangentEstimator.attach( &ball );
110 ConstIteratorOnPoints it = r.begin();
111 ConstIteratorOnPoints it2 = it+15;
112 lengthEstimator.init( 1, it, it2, &ball,
true);
115 trace.
info() <<
"Current point = "<<*it<<std::endl;
116 trace.
info() <<
"Current point+15 = "<<*it2<<std::endl;
117 trace.
info() <<
"Eval curvature (begin, h=1) = "<< curvatureEstimator.eval(it2)<<std::endl;
118 trace.
info() <<
"Eval tangent (begin, h=1) = "<< tangentEstimator.eval(it2)<<std::endl;
119 trace.
info() <<
"Eval length ( h=1) = "<< lengthEstimator.eval(it,it2)<<std::endl;
125 template <
typename Shape>
128 Shape & aShape,
double h )
141 dig.
init( xLow, xUp, h );
152 std::cerr <<
"[testTrueLocalEstimatorOnShapeDigitization]" 153 <<
" error in creating KSpace." << std::endl;
161 std::vector<Point> points;
171 curvatureEstimator.
init( h, r.begin(), r.end() );
172 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 double kappa = curvatureEstimator.
eval( it );
180 std::cout << i <<
" " << x[ 0 ] <<
" " << x[1]
181 <<
" " << kappa << std::endl;
186 std::cerr <<
"[testTrueLocalEstimatorOnShapeDigitization]" 187 <<
" error in finding a bel." << std::endl;
190 trace.
emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
199 int main(
int argc,
char** argv )
203 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 );
void beginBlock(const std::string &keyword="")
const Point & getLowerBound() const
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
const Point & getUpperBound() const
void attach(ConstAlias< EuclideanShape > shape)
void attach(ParametricShape *aShapePtr)
Aim: Model of the concept StarShaped represents any ellipse in the plane.
PointVector< 3, double > RealPoint
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
PointsRange getPointsRange() const
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
Aim: Model of the concept StarShaped represents any circle in the plane.
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: implements a functor that estimates the arc length of a paramtric curve.
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
bool testTrueLocalEstimator(const std::string &filename)
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
int main(int argc, char **argv)
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
bool testTrueLocalEstimatorOnShapeDigitization(const string &name, Shape &aShape, double h)
Aim: Computes the true quantity to each element of a range associated to a parametric shape.
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)
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Quantity eval(const ConstIterator &it) const
Aim: implements a functor that computes the tangent vector at a given point of a parametric shape.
TConstIterator ConstIterator
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,...
Aim: implements a functor that computes the curvature at a given point of a parametric shape.
Aim: Computes the true quantity to each element of a range associated to a parametric shape.