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"
54#include "DGtal/io/boards/Board2D.h"
72 typedef VisitorRange::ConstIterator VisitorConstIterator;
83 typedef MyIICurvatureEstimator::Quantity
Value;
85 static_assert(std::is_same_v<typename MyIICurvatureEstimator::Quantity, typename MyIICurvatureEstimatorP::Quantity>);
94 dshape.attach( ishape );
98 if ( !
K.
init( dshape.getLowerBound(), dshape.getUpperBound(),
true ) )
100 trace.
error() <<
"Problem with Khalimsky space" << std::endl;
116 VisitorRange range(
new Visitor( surf, *surf.
begin() ));
117 VisitorConstIterator ibegin = range.begin();
118 VisitorConstIterator iend = range.end();
120 VisitorRange rangeP(
new Visitor( surf, *surf.
begin() ));
121 VisitorConstIterator ibeginP = rangeP.begin();
122 VisitorConstIterator iendP = rangeP.end();
124 MyIICurvatureFunctor curvatureFunctor;
125 curvatureFunctor.init( h, re );
128 MyIICurvatureEstimator curvatureEstimator ( curvatureFunctor);
129 curvatureEstimator.attach(
K, dshape );
130 curvatureEstimator.setParams( re/h );
131 curvatureEstimator.init( h, ibegin, iend );
136 MyIICurvatureEstimatorP curvatureEstimatorP(
splitter, 4, curvatureFunctor );
137 curvatureEstimatorP.attach(
K, dshape );
138 curvatureEstimatorP.setParams( re/h );
139 curvatureEstimatorP.init( h, ibeginP, iendP );
146 std::vector< Value > results, resultsP;
147 std::back_insert_iterator< std::vector< Value > > resultsIt ( results );
148 std::back_insert_iterator< std::vector< Value > > resultsItP( resultsP );
150 curvatureEstimator .eval( ibegin , iend , resultsIt );
151 curvatureEstimatorP.eval( ibeginP, iendP, resultsItP );
155 trace.
beginBlock (
"Comparing results of integral invariant 2D curvature ..." );
158 board << dshape.getDomain();
159 for(
auto p: dshape.getDomain())
162 board.
saveSVG(
"debugging-para.svg");
164 trace.
info() << dshape.getDomain() << std::endl;
166 auto splits =
splitter(dshape.getDomain(), 4);
167 for(
const auto &sd: splits)
171 auto rsize = results.size();
172 auto rsizeP = resultsP.size();
176 trace.
error() <<
"Size mismatch between parallel and non-parallel versions: " << rsize <<
" / " << rsizeP;
181 for (
unsigned int i = 0; i < rsize; ++i )
183 if (std::abs(results[i] - resultsP[i]) >= 1e-6)
185 trace.
error() <<
"Result mismatch between parallel and non-parallel versions at linel " << i <<
": " << results[i] <<
" / " << resultsP[i] <<
"\n";
198 trace.
beginBlock (
"Testing class ParrallelIIEstimator with IntegralInvariantVolumeEstimator in 2d" );
201 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << std::endl;
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
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...
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="")
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
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
bool testCurvature2dP(double h)
GaussDigitizer< Space, ImplicitShape > DigitalShape
ImplicitPolynomial3Shape< Space > ImplicitShape