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;
58 typedef Boundary::DigitalSurfaceTracker DigitalSurfaceTracker;
62 unsigned int nbok = 0;
67 EuclideanShape ball( c, 2 );
77 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
78 <<
"K.init() is ok" << std::endl;
90 DigitalSurfaceTracker* ptrTracker = boundary.newTracker( bel );
91 MyUmbrellaComputer umbrella;
96 umbrella.init( *ptrTracker, k,
true, j );
97 unsigned int nb_forward = 0;
104 bel = umbrella.surfel();
105 }
while ( bel != init_bel );
108 unsigned int nb_backward = 0;
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;
154 unsigned int nbok = 0;
159 EuclideanShape ball( c, 8 );
169 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
170 <<
"K.init() is ok" << std::endl;
174 Boundary boundary(
K,
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;
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;
270 int main(
int argc,
char** argv )
274 for (
int i = 0; i < argc; ++i )
280 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
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
The range of vertices is defined as a vector.
std::vector< Arc > ArcRange
The range of arcs is defined as a vector.
std::vector< Face > FaceRange
The range of faces is defined as a vector.
VertexRange verticesAroundFace(const Face &f) const
std::set< Face > FaceSet
The set of faces is defined as set.
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)
const Point & lowerBound() const
const Point & upperBound() const
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
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.
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
const Point & sKCoords(const SCell &c) const
Return its Khalimsky coordinates.
typename PreCellularGridSpace::DirIterator DirIterator
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
void beginBlock(const std::string &keyword="")
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
PointVector< 3, double > RealPoint
bool testCombinatorialSurface()
int main(int argc, char **argv)
bool testUmbrellaComputer()