Example of a test. To be completed.
65{
66 unsigned int nbok = 0;
67 unsigned int nb = 0;
68
75 typedef VisitorRange::ConstIterator VisitorConstIterator;
76
79
80
81 double re = 5.0;
82 double radius = 5.0;
83
84 trace.beginBlock(
"Shape initialisation ..." );
85
90
93 {
94 trace.error() <<
"Problem with Khalimsky space" << std::endl;
95 return false;
96 }
97
101
103
104 trace.beginBlock(
"Curvature estimator computation ...");
105
106 VisitorRange range(
new Visitor( surf, *surf.begin() ));
107 VisitorConstIterator ibegin = range.begin();
108 VisitorConstIterator iend = range.end();
109
110 MyIICurvatureFunctor curvatureFunctor;
111 curvatureFunctor.init( h, re );
112
113 MyIICurvatureEstimator curvatureEstimator( curvatureFunctor );
114 curvatureEstimator.attach(
K, dshape );
115 curvatureEstimator.setParams( re/h );
116 curvatureEstimator.init( h, ibegin, iend );
117
118 std::vector<MyIICurvatureEstimator::Quantity> results;
119 std::back_insert_iterator< std::vector<MyIICurvatureEstimator::Quantity> > itback(results);
120
121 curvatureEstimator.eval(ibegin,iend,itback);
122 trace.info() <<
"Number of values = "<< results.size()<<std::endl;
124
125 trace.beginBlock(
"Caching values ...");
126 VisitorRange range2(
new Visitor( surf, *surf.begin() ));
127 VisitorConstIterator ibegin2 = range2.begin();
128 VisitorConstIterator iend2 = range2.end();
129
131
133
134 GaussianCache cache( curvatureEstimator );
135 cache.init( h, ibegin2, iend2 );
136 trace.info() <<
"Number of cached values = "<< cache.size()<<std::endl;
137
138 trace.info() <<
"Value at begin="<< cache.eval(surf.begin())<<
" expected = "<< curvatureEstimator.eval(surf.begin())<<std::endl;
140
141
142 trace.beginBlock(
"Complete test ...");
143 bool ok=true;
145 {
146 if ( cache.eval(it) != curvatureEstimator.eval(it) )
147 {
148 ok=false;
149 trace.error() <<
"Incorrect values at "<<*it<<
" read " <<cache.eval(it)<<
" and expecting "<<curvatureEstimator.eval(it)<<std::endl;
150 }
151 }
153
154 trace.beginBlock(
"Timing cache access ...");
156 {
157 if ( cache.eval(it) == 12345678 )
158
159 {
160 ok=false;
161 trace.error() <<
"Incorrect values at "<<*it<<std::endl;
162 }
163 }
165
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;
171 {
172 if ( cache.eval(it) == 12345678 )
173
174 {
175 ok=false;
176 trace.error() <<
"Incorrect values at "<<*it<<std::endl;
177 }
178 }
180
181
182
183 nbok += ok ? 1 : 0;
184 nb++;
185 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
186 << "cache == eval" << std::endl;
187
188 return nbok == nb;
189}
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
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
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...
GaussDigitizer< Space, ImplicitShape > DigitalShape
ImplicitPolynomial3Shape< Space > ImplicitShape