32 #include "DGtal/base/Common.h"
33 #include "DGtal/topology/DigitalSurface.h"
34 #include "DGtal/topology/DigitalSetBoundary.h"
35 #include "DGtal/topology/ImplicitDigitalSurface.h"
36 #include "DGtal/topology/BreadthFirstVisitor.h"
37 #include "DGtal/shapes/Shapes.h"
41 using namespace DGtal;
47 template <
typename KSpace,
typename Po
intPredicate>
49 testImplicitDigitalSurface(
const KSpace & K,
50 const PointPredicate & pp,
51 const typename KSpace::Surfel & bel )
53 typedef typename KSpace::Point
Point;
54 typedef typename KSpace::Surfel Surfel;
56 typedef typename Boundary::SurfelConstIterator ConstIterator;
57 typedef typename Boundary::Tracker Tracker;
59 unsigned int nbok = 0;
63 Boundary boundary( K, pp,
67 trace.
beginBlock (
"Counting the number of surfels (breadth first traversal)" );
68 unsigned int nbsurfels = 0;
69 for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
74 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
75 nb++, nbok += nbsurfels == 354382 ? 1 : 0;
76 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
77 <<
"nbsurfels == 354382" << std::endl;
84 template <
typename TPo
int3>
89 : myA( a ), myB( b ), myC( c )
92 bool operator()(
const TPoint3 & p )
const
94 double x = ( (double) p[ 0 ] / myA );
95 double y = ( (double) p[ 1 ] / myB );
96 double z = ( (double) p[ 2 ] / myC );
97 return ( x*x + y*y + z*z ) <= 1.0;
106 int main(
int ,
char** )
110 typedef KSpace::SCell Surfel;
113 Point p1( -200, -200, -200 );
114 Point p2( 200, 200, 200 );
116 if ( K.init( p1, p2,
true ) )
118 ImplicitDigitalEllipse ellipse( 180.0, 135.0, 102.0 );
121 testImplicitDigitalSurface<KSpace, ImplicitDigitalEllipse>
126 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;