33#include "DGtal/base/Common.h"
36#include "DGtal/shapes/implicit/ImplicitBall.h"
39#include "DGtal/shapes/GaussDigitizer.h"
40#include "DGtal/topology/LightImplicitDigitalSurface.h"
41#include "DGtal/topology/DigitalSurface.h"
42#include "DGtal/graph/DepthFirstVisitor.h"
43#include "DGtal/graph/GraphVisitorRange.h"
46#include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h"
47#include "DGtal/geometry/surfaces/estimation/IntegralInvariantVolumeEstimator.h"
67 typedef VisitorRange::ConstIterator VisitorConstIterator;
71 typedef MyIICurvatureFunctor::Value
Value;
75 double realValue = 1.0/radius;
87 trace.
error() <<
"Problem with Khalimsky space" << std::endl;
100 VisitorConstIterator ibegin = range.begin();
101 VisitorConstIterator iend = range.end();
103 MyIICurvatureFunctor curvatureFunctor;
104 curvatureFunctor.init( h,
re );
106 MyIICurvatureEstimator curvatureEstimator( curvatureFunctor );
107 curvatureEstimator.attach(
K, dshape );
108 curvatureEstimator.setParams(
re/h );
109 curvatureEstimator.init( h, ibegin, iend );
115 std::vector< Value > results;
116 std::back_insert_iterator< std::vector< Value > > resultsIt( results );
117 curvatureEstimator.eval( ibegin, iend, resultsIt );
121 trace.
beginBlock (
"Comparing results of integral invariant 2D curvature ..." );
124 double rsize =
static_cast<double>(results.size());
128 trace.
error() <<
"ERROR: surface is empty" << std::endl;
133 for (
unsigned int i = 0; i < rsize; ++i )
135 mean += results[ i ];
141 trace.
error() <<
"ERROR: result is NaN" << std::endl;
146 double v = std::abs ( realValue - mean );
148 trace.
warning() <<
"True value: " << realValue << std::endl;
150 trace.
warning() <<
"Delta: " << delta <<
" |true - mean|: " << v << std::endl;
169 typedef VisitorRange::ConstIterator VisitorConstIterator;
173 typedef MyIICurvatureFunctor::Value
Value;
177 double realValue = 1.0/radius;
189 trace.
error() <<
"Problem with Khalimsky space" << std::endl;
201 VisitorRange range(
new Visitor( surf, *surf.
begin() ));
202 VisitorConstIterator ibegin = range.begin();
203 VisitorConstIterator iend = range.end();
205 MyIICurvatureFunctor curvatureFunctor;
206 curvatureFunctor.init( h,
re );
208 MyIICurvatureEstimator curvatureEstimator( curvatureFunctor );
209 curvatureEstimator.attach(
K, dshape );
210 curvatureEstimator.setParams(
re/h );
211 curvatureEstimator.init( h, ibegin, iend );
217 std::vector< Value > results;
218 std::back_insert_iterator< std::vector< Value > > resultsIt( results );
219 curvatureEstimator.eval( ibegin, iend, resultsIt );
223 trace.
beginBlock (
"Comparing results of integral invariant 3D mean curvature ..." );
226 unsigned int rsize = results.size();
230 trace.
error() <<
"ERROR: surface is empty" << std::endl;
235 for (
unsigned int i = 0; i < rsize; ++i )
237 mean += results[ i ];
243 trace.
error() <<
"ERROR: result is NaN" << std::endl;
248 double v = std::abs ( realValue - mean );
250 trace.
warning() <<
"True value: " << realValue << std::endl;
252 trace.
warning() <<
"Delta: " << delta <<
" |true - mean|: " << v << std::endl;
269 trace.
beginBlock (
"Testing class IntegralInvariantVolumeEstimator and 2d/3d mean curvature functors" );
271 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << std::endl;
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
ConstIterator begin() const
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: Transforms a graph visitor into a single pass input range.
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Aim: model of CEuclideanOrientedShape concepts to create a shape from a polynomial.
Aim: This class implement an Integral Invariant estimator which computes for each surfel the volume o...
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: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: Implements basic operations that will be used in Point and Vector classes.
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="")
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
BreadthFirstVisitor< MyDigitalSurface > Visitor
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: A functor Real -> Real that returns the 2d curvature by transforming the given volume....
Aim: A functor Real -> Real that returns the 3d mean curvature by transforming the given volume....
bool testCurvature2d(double h, double delta)
bool testMeanCurvature3d(double h, double delta)
std::default_random_engine re