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" 42 using namespace DGtal;
59 typedef Boundary::Surfel Surfel;
60 typedef Boundary::DigitalSurfaceTracker DigitalSurfaceTracker;
64 unsigned int nbok = 0;
69 EuclideanShape ball( c, 2 );
72 shape.
init( RealPoint( -10.0, -10.0, -10.0 ),
73 RealPoint( 10.0, 10.0, 10.0 ), 1.0 );
79 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 80 <<
"K.init() is ok" << std::endl;
89 MyDigitalSurface digSurf( boundary );
92 DigitalSurfaceTracker* ptrTracker = boundary.newTracker( bel );
93 MyUmbrellaComputer umbrella;
94 KSpace::DirIterator dirIt = K.sDirs( bel );
98 umbrella.init( *ptrTracker, k,
true, j );
99 unsigned int nb_forward = 0;
100 Surfel init_bel = bel;
102 Point x = K.sKCoords( bel );
106 bel = umbrella.surfel();
107 }
while ( bel != init_bel );
110 unsigned int nb_backward = 0;
112 Point x = K.sKCoords( bel );
116 bel = umbrella.surfel();
117 }
while ( bel != init_bel );
118 nb++, nbok += nb_forward == nb_backward ? 1 : 0;
120 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 121 <<
" nb_forward(" << nb_forward
122 <<
") == nb_backward(" << nb_backward <<
")" 125 unsigned int nbsurfels = 0;
126 for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
131 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
150 typedef Boundary::Surfel Surfel;
158 unsigned int nbok = 0;
163 EuclideanShape ball( c, 8 );
166 shape.
init( RealPoint( -2.0, -3.0, -10.0 ),
167 RealPoint( 10.0, 10.0, 10.0 ), 1.0 );
173 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 174 <<
"K.init() is ok" << std::endl;
178 Boundary boundary( K,
183 MyDigitalSurface digSurf( boundary );
188 for ( MyDigitalSurface::FaceSet::const_iterator it = all_faces.begin(),
189 it_end = all_faces.end(); it != it_end; ++it )
191 std::cerr <<
" face=" << K.sKCoords( digSurf.
pivot( *it ) ) <<
":";
192 std::cerr <<
"(" << it->nbVertices <<
")" << (it->isClosed() ?
"C":
"O");
194 for (
unsigned int i = 0; i < vtx.size(); ++i )
196 std::cerr <<
" " << K.sKCoords( vtx[ i ] );
198 std::cerr << std::endl;
205 unsigned int nbvtcs = 0;
206 unsigned int nbarcs = 0;
207 unsigned int nbfaces = 0;
208 for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
209 it != it_end; ++it, ++nbvtcs )
211 const Vertex & vtx = *it;
213 for (
unsigned int i = 0; i < arcs.size(); ++i, ++nbarcs )
215 const Arc & arc = arcs[ i ];
218 for (
unsigned int j = 0; j < faces.size(); ++j, ++nbfaces )
220 const Face & face = faces[ j ];
225 while ( ( k < vertices.size() ) && ( vertices[ k ] != vtx ) )
228 if ( k == vertices.size() )
229 trace.
info() <<
"Error at vertex " << vtx
230 <<
". Vertex not found in incident face." 234 if ( digSurf.
head( arc ) != vertices[ (k+1) % vertices.size() ] )
235 trace.
info() <<
"Error at vertex " << vtx
236 <<
". Arc is not in incident face." 242 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 243 <<
"Tested nbvtcs=" << nbvtcs
244 <<
" nbarcs=" << nbarcs
245 <<
" nbfaces=" << nbfaces
249 trace.
beginBlock(
"Testing block ... export as OFF: ex-digital-surface.off" );
250 ofstream fout(
"ex-digital-surface.off" );
258 unsigned int nbsurfels = 0;
259 for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
264 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
274 int main(
int argc,
char** argv )
278 for (
int i = 0; i < argc; ++i )
284 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
void beginBlock(const std::string &keyword="")
VertexRange verticesAroundFace(const Face &f) const
HyperRectDomain< Space > Domain
std::vector< Vertex > VertexRange
The range of vertices is defined as a vector.
std::vector< Arc > ArcRange
The range of arcs is defined as a vector.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
const Domain domain(Point(1, 2), Point(6, 5))
MyDigitalSurface::ConstIterator ConstIterator
SCell pivot(const Face &f) const
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Vertex head(const Arc &a) const
DGtal::uint32_t Dimension
int main(int argc, char **argv)
const Point & upperBound() const
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
std::set< Face > FaceSet
The set of faces is defined as set.
Aim: Implements basic operations that will be used in Point and Vector classes.
void attach(const EuclideanShape &shape)
void exportSurfaceAs3DOFF(std::ostream &out) const
bool testUmbrellaComputer()
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
std::vector< Face > FaceRange
The range of faces is defined as a vector.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
Surfel Vertex
Defines the type for a vertex.
DGtal is the top-level namespace which contains all DGtal functions and types.
FaceRange facesAroundArc(const Arc &a) const
const Point & lowerBound() const
MyDigitalSurface::Vertex Vertex
bool testCombinatorialSurface()
ArcRange outArcs(const Vertex &v) const
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface