33#include "DGtal/base/Common.h"
34#include "DGtal/shapes/implicit/ImplicitBall.h"
35#include "DGtal/shapes/GaussDigitizer.h"
36#include "DGtal/topology/LightImplicitDigitalSurface.h"
37#include "DGtal/topology/DigitalSurface.h"
38#include "DGtal/topology/UmbrellaComputer.h"
57 typedef Boundary::Surfel
Surfel;
58 typedef Boundary::DigitalSurfaceTracker DigitalSurfaceTracker;
62 unsigned int nbok = 0;
64 trace.beginBlock (
"Testing block ... UmbrellaComputer" );
67 EuclideanShape ball( c, 2 );
75 nbok +=
K.init(
domain.lowerBound(),
domain.upperBound(),
true ) ? 1 : 0;
77 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
78 <<
"K.init() is ok" << std::endl;
90 DigitalSurfaceTracker* ptrTracker = boundary.newTracker( bel );
91 MyUmbrellaComputer umbrella;
95 trace.beginBlock (
"Testing block ... forward umbrella" );
96 umbrella.init( *ptrTracker, k,
true, j );
97 unsigned int nb_forward = 0;
100 Point x =
K.sKCoords( bel );
101 trace.info() << x << std::endl;
104 bel = umbrella.surfel();
105 }
while ( bel != init_bel );
107 trace.beginBlock (
"Testing block ... backward umbrella" );
108 unsigned int nb_backward = 0;
110 Point x =
K.sKCoords( bel );
111 trace.info() << x << std::endl;
114 bel = umbrella.surfel();
115 }
while ( bel != init_bel );
116 nb++; nbok += nb_forward == nb_backward ? 1 : 0;
118 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
119 <<
" nb_forward(" << nb_forward
120 <<
") == nb_backward(" << nb_backward <<
")"
123 unsigned int nbsurfels = 0;
124 for (
ConstIterator it = boundary.begin(), it_end = boundary.end();
129 trace.info() << nbsurfels <<
" surfels found." << std::endl;
146 typedef Boundary::Surfel
Surfel;
154 unsigned int nbok = 0;
156 trace.beginBlock (
"Testing block ... Combinatorial surface" );
159 EuclideanShape ball( c, 8 );
167 nbok +=
K.init(
domain.lowerBound(),
domain.upperBound(),
true ) ? 1 : 0;
169 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
170 <<
"K.init() is ok" << std::endl;
174 Boundary boundary(
K,
182 trace.beginBlock (
"Testing block ... Digital surface faces." );
184 for ( MyDigitalSurface::FaceSet::const_iterator it = all_faces.begin(),
185 it_end = all_faces.end(); it != it_end; ++it )
187 std::cerr <<
" face=" <<
K.sKCoords( digSurf.
pivot( *it ) ) <<
":";
188 std::cerr <<
"(" << it->nbVertices <<
")" << (it->isClosed() ?
"C":
"O");
190 for (
unsigned int i = 0; i < vtx.size(); ++i )
192 std::cerr <<
" " <<
K.sKCoords( vtx[ i ] );
194 std::cerr << std::endl;
200 trace.beginBlock(
"Testing block ...Check order faces/arcs" );
201 unsigned int nbvtcs = 0;
202 unsigned int nbarcs = 0;
203 unsigned int nbfaces = 0;
204 for (
ConstIterator it = boundary.begin(), it_end = boundary.end();
205 it != it_end; ++it, ++nbvtcs )
209 for (
unsigned int i = 0; i < arcs.size(); ++i, ++nbarcs )
211 const Arc & arc = arcs[ i ];
214 for (
unsigned int j = 0; j < faces.size(); ++j, ++nbfaces )
216 const Face & face = faces[ j ];
221 while ( ( k < vertices.size() ) && ( vertices[ k ] != vtx ) )
224 if ( k == vertices.size() )
225 trace.info() <<
"Error at vertex " << vtx
226 <<
". Vertex not found in incident face."
230 if ( digSurf.
head( arc ) != vertices[ (k+1) % vertices.size() ] )
231 trace.info() <<
"Error at vertex " << vtx
232 <<
". Arc is not in incident face."
238 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
239 <<
"Tested nbvtcs=" << nbvtcs
240 <<
" nbarcs=" << nbarcs
241 <<
" nbfaces=" << nbfaces
245 trace.beginBlock(
"Testing block ... export as OFF: ex-digital-surface.off" );
246 ofstream fout(
"ex-digital-surface.off" );
254 unsigned int nbsurfels = 0;
255 for (
ConstIterator it = boundary.begin(), it_end = boundary.end();
260 trace.info() << nbsurfels <<
" surfels found." << std::endl;
270int main(
int argc,
char** argv )
272 trace.beginBlock (
"Testing class UmbrellaComputer" );
273 trace.info() <<
"Args:";
274 for (
int i = 0; i < argc; ++i )
275 trace.info() <<
" " << argv[ i ];
276 trace.info() << endl;
280 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
270int main(
int argc,
char** argv ) {
…}
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
ArcRange outArcs(const Vertex &v) const
void exportSurfaceAs3DOFF(std::ostream &out) const
SCell pivot(const Face &f) const
Surfel Vertex
Defines the type for a vertex.
std::vector< Vertex > VertexRange
std::vector< Arc > ArcRange
std::vector< Face > FaceRange
VertexRange verticesAroundFace(const Face &f) const
FaceRange facesAroundArc(const Arc &a) const
Vertex head(const Arc &a) const
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
void attach(ConstAlias< EuclideanShape > shape)
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
typename PreCellularGridSpace::DirIterator DirIterator
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...
Aim: Useful for computing umbrellas on 'DigitalSurface's, ie set of n-1 cells around a n-3 cell.
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
GaussDigitizer< Space, ImplicitShape > DigitalShape
PointVector< 3, double > RealPoint
bool testCombinatorialSurface()
bool testUmbrellaComputer()