32#include "DGtal/base/Common.h"
33#include "ConfigTest.h"
34#include "DGtal/helpers/StdDefs.h"
35#include "DGtal/geometry/surfaces/estimation/EstimatorCache.h"
38#include "DGtal/shapes/implicit/ImplicitBall.h"
41#include "DGtal/shapes/GaussDigitizer.h"
42#include "DGtal/topology/LightImplicitDigitalSurface.h"
43#include "DGtal/topology/DigitalSurface.h"
44#include "DGtal/graph/DepthFirstVisitor.h"
45#include "DGtal/graph/GraphVisitorRange.h"
48#include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h"
49#include "DGtal/geometry/surfaces/estimation/IntegralInvariantCovarianceEstimator.h"
66 unsigned int nbok = 0;
75 typedef VisitorRange::ConstIterator VisitorConstIterator;
84 trace.beginBlock(
"Shape initialisation ..." );
94 trace.error() <<
"Problem with Khalimsky space" << std::endl;
104 trace.beginBlock(
"Curvature estimator computation ...");
106 VisitorRange range(
new Visitor( surf, *surf.
begin() ));
107 VisitorConstIterator ibegin = range.begin();
108 VisitorConstIterator iend = range.end();
110 MyIICurvatureFunctor curvatureFunctor;
111 curvatureFunctor.init( h, re );
113 MyIICurvatureEstimator curvatureEstimator( curvatureFunctor );
114 curvatureEstimator.attach(
K, dshape );
115 curvatureEstimator.setParams( re/h );
116 curvatureEstimator.init( h, ibegin, iend );
118 std::vector<MyIICurvatureEstimator::Quantity> results;
119 std::back_insert_iterator< std::vector<MyIICurvatureEstimator::Quantity> > itback(results);
121 curvatureEstimator.eval(ibegin,iend,itback);
122 trace.info() <<
"Number of values = "<< results.size()<<std::endl;
125 trace.beginBlock(
"Caching values ...");
126 VisitorRange range2(
new Visitor( surf, *surf.
begin() ));
127 VisitorConstIterator ibegin2 = range2.begin();
128 VisitorConstIterator iend2 = range2.end();
134 GaussianCache cache( curvatureEstimator );
135 cache.init( h, ibegin2, iend2 );
136 trace.info() <<
"Number of cached values = "<< cache.size()<<std::endl;
138 trace.info() <<
"Value at begin="<< cache.eval(surf.
begin())<<
" expected = "<< curvatureEstimator.eval(surf.
begin())<<std::endl;
142 trace.beginBlock(
"Complete test ...");
146 if ( cache.eval(it) != curvatureEstimator.eval(it) )
149 trace.error() <<
"Incorrect values at "<<*it<<
" read " <<cache.eval(it)<<
" and expecting "<<curvatureEstimator.eval(it)<<std::endl;
154 trace.beginBlock(
"Timing cache access ...");
157 if ( cache.eval(it) == 12345678 )
161 trace.error() <<
"Incorrect values at "<<*it<<std::endl;
166 trace.beginBlock(
"Copy construction and timing cache access ...");
167 GaussianCache cache2(cache);
168 trace.info() <<
"Number of cached values = "<< cache.size()<<std::endl;
169 trace.info() <<
"Value at begin="<< cache2.eval(surf.
begin())<<
" expected = "<< curvatureEstimator.eval(surf.
begin())<<std::endl;
172 if ( cache.eval(it) == 12345678 )
176 trace.error() <<
"Incorrect values at "<<*it<<std::endl;
185 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
186 <<
"cache == eval" << std::endl;
194int main(
int argc,
char** argv )
196 trace.beginBlock (
"Testing class EstimatorCache" );
197 trace.info() <<
"Args:";
198 for (
int i = 0; i < argc; ++i )
199 trace.info() <<
" " << argv[ i ];
200 trace.info() << endl;
203 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
194int main(
int argc,
char** argv ) {
…}
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...
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
ConstIterator begin() const
ConstIterator end() const
Aim: this class adapts any local surface estimator to cache the estimated values in a associative con...
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: This class implement an Integral Invariant estimator which computes for each surfel the covarian...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
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...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
BreadthFirstVisitor< MyDigitalSurface > Visitor
KhalimskySpaceND< 3, Integer > KSpace
Space::RealPoint RealPoint
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: This concept describes an object that can process a range of surfels (that are supposed to belon...
Aim: A functor Matrix -> Real that returns the Gaussian curvature by diagonalizing the given covarian...
bool testEstimatorCache(double h)
GaussDigitizer< Space, ImplicitShape > DigitalShape
ImplicitPolynomial3Shape< Space > ImplicitShape