34#include "DGtal/base/Common.h"
37#include "DGtal/shapes/implicit/ImplicitBall.h"
40#include "DGtal/shapes/GaussDigitizer.h"
41#include "DGtal/topology/LightImplicitDigitalSurface.h"
42#include "DGtal/topology/DigitalSurface.h"
43#include "DGtal/graph/DepthFirstVisitor.h"
44#include "DGtal/graph/GraphVisitorRange.h"
47#include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h"
48#include "DGtal/geometry/surfaces/estimation/IntegralInvariantVolumeEstimator.h"
49#include "DGtal/geometry/surfaces/estimation/ParallelIIEstimator.h"
50#include "DGtal/kernel/domains/DomainSplitter.h"
62bool testCurvature2dP (
double h )
70 typedef VisitorRange::ConstIterator VisitorConstIterator;
80 typedef MyIICurvatureEstimator::Quantity
Value;
82 static_assert(std::is_same_v<typename MyIICurvatureEstimator::Quantity, typename MyIICurvatureEstimatorP::Quantity>);
91 dshape.attach( ishape );
95 if ( !
K.
init( dshape.getLowerBound(), dshape.getUpperBound(),
true ) )
97 trace.
error() <<
"Problem with Khalimsky space" << std::endl;
111 VisitorRange range(
new Visitor( surf, *surf.begin() ));
112 VisitorConstIterator ibegin = range.begin();
113 VisitorConstIterator iend = range.end();
115 VisitorRange rangeP(
new Visitor( surf, *surf.begin() ));
116 VisitorConstIterator ibeginP = rangeP.begin();
117 VisitorConstIterator iendP = rangeP.end();
119 MyIICurvatureFunctor curvatureFunctor;
120 curvatureFunctor.init( h, re );
123 MyIICurvatureEstimator curvatureEstimator ( curvatureFunctor);
124 curvatureEstimator.attach(
K, dshape );
125 curvatureEstimator.setParams( re/h );
126 curvatureEstimator.init( h, ibegin, iend );
131 MyIICurvatureEstimatorP curvatureEstimatorP(
splitter, 4, curvatureFunctor );
132 curvatureEstimatorP.attach(
K, dshape );
133 curvatureEstimatorP.setParams( re/h );
134 curvatureEstimatorP.init( h, ibeginP, iendP );
141 std::vector< Value > results, resultsP;
142 std::back_insert_iterator< std::vector< Value > > resultsIt ( results );
143 std::back_insert_iterator< std::vector< Value > > resultsItP( resultsP );
145 curvatureEstimator .eval( ibegin , iend , resultsIt );
146 curvatureEstimatorP.eval( ibeginP, iendP, resultsItP );
150 trace.
beginBlock (
"Comparing results of integral invariant 2D curvature ..." );
152 unsigned int rsize = results.size();
153 unsigned int rsizeP = resultsP.size();
157 trace.
error() <<
"Size mismatch between parallel and non-parallel versions: " << rsize <<
" / " << rsizeP;
162 for (
unsigned int i = 0; i < rsize; ++i )
164 if (std::abs(results[i] - resultsP[i]) >= 1e-2)
166 trace.
error() <<
"Result mismatch between parallel and non-parallel versions at voxel " << i <<
": " << results[i] <<
" / " << resultsP[i] <<
"\n";
177int main(
int ,
char** )
179 trace.
beginBlock (
"Testing class ParrallelIIEstimator with IntegralInvariantVolumeEstimator in 2d" );
181 bool res = testCurvature2dP( 0.05 );
182 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...
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
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 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...
Run an Integral Invariant estimator in parallel.
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.
Splits a domain evenly along all dimensions.
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....
AxisDomainSplitter< Domain > splitter
GaussDigitizer< Space, ImplicitShape > DigitalShape
ImplicitPolynomial3Shape< Space > ImplicitShape