DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testDigitalSurface.cpp
1 
30 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/base/CConstSinglePassRange.h"
34 #include "DGtal/topology/DigitalSurface.h"
35 #include "DGtal/topology/DigitalSetBoundary.h"
36 #include "DGtal/topology/ImplicitDigitalSurface.h"
37 #include "DGtal/topology/LightImplicitDigitalSurface.h"
38 #include "DGtal/topology/ExplicitDigitalSurface.h"
39 #include "DGtal/topology/LightExplicitDigitalSurface.h"
40 #include "DGtal/topology/BreadthFirstVisitor.h"
41 #include "DGtal/topology/helpers/FrontierPredicate.h"
42 #include "DGtal/topology/helpers/BoundaryPredicate.h"
43 #include "DGtal/topology/CUndirectedSimpleLocalGraph.h"
44 #include "DGtal/topology/CUndirectedSimpleGraph.h"
45 
46 #include "DGtal/shapes/Shapes.h"
48 
49 using namespace std;
50 using namespace DGtal;
51 
53 // Functions for testing class DigitalSurface.
55 
59 bool testDigitalSetBoundary()
60 {
61  unsigned int nbok = 0;
62  unsigned int nb = 0;
63 
64  trace.beginBlock ( "Testing block ... DigitalSetBoundary" );
65  using namespace Z2i;
67  typedef Boundary::SurfelConstIterator ConstIterator;
68  typedef Boundary::Tracker Tracker;
69  typedef Boundary::Surfel Surfel;
70  Point p1( -10, -10 );
71  Point p2( 10, 10 );
72  Domain domain( p1, p2 );
73  DigitalSet dig_set( domain );
74  Shapes<Domain>::addNorm2Ball( dig_set, Point( 0, 0 ), 5 );
75  Shapes<Domain>::removeNorm2Ball( dig_set, Point( 0, 0 ), 1 );
76  KSpace K;
77  nbok += K.init( domain.lowerBound(), domain.upperBound(), true ) ? 1 : 0;
78  nb++;
79  trace.info() << "(" << nbok << "/" << nb << ") "
80  << "K.init() is ok" << std::endl;
81  Boundary boundary( K, dig_set );
82  unsigned int nbsurfels = 0;
83  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
84  it != it_end; ++it )
85  {
86  ++nbsurfels;
87  }
88  trace.info() << nbsurfels << " surfels found." << std::endl;
89  nb++, nbok += nbsurfels == ( 12 + 44 ) ? 1 : 0;
90  trace.info() << "(" << nbok << "/" << nb << ") "
91  << "nbsurfels == (12 + 44 )" << std::endl;
92  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
93  it != it_end; ++it )
94  {
95  Tracker* ptrTracker = boundary.newTracker( *it );
96  Surfel s = ptrTracker->current();
97  Dimension trackDir = * K.sDirs( s );
98  Surfel s1, s2;
99  unsigned int m1 = ptrTracker->adjacent( s1, trackDir, true );
100  unsigned int m2 = ptrTracker->adjacent( s2, trackDir, false );
101  trace.info() << "s = " << s << std::endl;
102  trace.info() << "s1 = " << s1 << " m1 = " << m1 << std::endl;
103  trace.info() << "s2 = " << s2 << " m2 = " << m2 << std::endl;
104  nb++, nbok += boundary.isInside( s1 ) ? 1 : 0;
105  trace.info() << "(" << nbok << "/" << nb << ") "
106  << "boundary.isInside( s1 )" << std::endl;
107  nb++, nbok += boundary.isInside( s2 ) ? 1 : 0;
108  trace.info() << "(" << nbok << "/" << nb << ") "
109  << "boundary.isInside( s2 )" << std::endl;
110  delete ptrTracker;
111  }
112  trace.endBlock();
113  return nbok == nb;
114 }
115 
116 template <typename TPoint3>
118  typedef TPoint3 Point;
119  inline
120  ImplicitDigitalEllipse3( double a, double b, double c )
121  : myA( a ), myB( b ), myC( c )
122  {}
123  inline
124  bool operator()( const TPoint3 & p ) const
125  {
126  double x = ( (double) p[ 0 ] / myA );
127  double y = ( (double) p[ 1 ] / myB );
128  double z = ( (double) p[ 2 ] / myC );
129  return ( x*x + y*y + z*z ) <= 1.0;
130  }
131  double myA, myB, myC;
132 };
133 
134 bool testImplicitDigitalSurface()
135 {
136  unsigned int nbok = 0;
137  unsigned int nb = 0;
138 
139  trace.beginBlock ( "Testing block ... ImplicitDigitalSurface" );
140  using namespace Z3i;
141  typedef ImplicitDigitalEllipse3<Point> ImplicitDigitalEllipse;
143  typedef Boundary::SurfelConstIterator ConstIterator;
144  typedef Boundary::Tracker Tracker;
145  typedef Boundary::Surfel Surfel;
146  Point p1( -10, -10, -10 );
147  Point p2( 10, 10, 10 );
148  KSpace K;
149  nbok += K.init( p1, p2, true ) ? 1 : 0;
150  nb++;
151  trace.info() << "(" << nbok << "/" << nb << ") "
152  << "K.init() is ok" << std::endl;
153  ImplicitDigitalEllipse ellipse( 6.0, 4.5, 3.4 );
154  Surfel bel = Surfaces<KSpace>::findABel( K, ellipse, 10000 );
155  Boundary boundary( K, ellipse,
156  SurfelAdjacency<KSpace::dimension>( true ), bel );
157  unsigned int nbsurfels = 0;
158  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
159  it != it_end; ++it )
160  {
161  ++nbsurfels;
162  }
163  trace.info() << nbsurfels << " surfels found." << std::endl;
164  // nb++, nbok += nbsurfels == ( 12 + 44 ) ? 1 : 0;
165  // trace.info() << "(" << nbok << "/" << nb << ") "
166  // << "nbsurfels == (12 + 44 )" << std::endl;
167  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
168  it != it_end; ++it )
169  {
170  Tracker* ptrTracker = boundary.newTracker( *it );
171  Surfel s = ptrTracker->current();
172  Dimension trackDir = * K.sDirs( s );
173  Surfel s1, s2;
174  unsigned int m1 = ptrTracker->adjacent( s1, trackDir, true );
175  unsigned int m2 = ptrTracker->adjacent( s2, trackDir, false );
176  trace.info() << "s = " << s << std::endl;
177  trace.info() << "s1 = " << s1 << " m1 = " << m1 << std::endl;
178  trace.info() << "s2 = " << s2 << " m2 = " << m2 << std::endl;
179  nb++, nbok += boundary.isInside( s1 ) ? 1 : 0;
180  trace.info() << "(" << nbok << "/" << nb << ") "
181  << "boundary.isInside( s1 )" << std::endl;
182  nb++, nbok += boundary.isInside( s2 ) ? 1 : 0;
183  trace.info() << "(" << nbok << "/" << nb << ") "
184  << "boundary.isInside( s2 )" << std::endl;
185  delete ptrTracker;
186  }
187  trace.endBlock();
188  return nbok == nb;
189 }
190 
191 //-----------------------------------------------------------------------------
192 // Testing LightImplicitDigitalSurface
193 //-----------------------------------------------------------------------------
194 bool testLightImplicitDigitalSurface()
195 {
196  using namespace Z3i;
197  typedef ImplicitDigitalEllipse3<Point> ImplicitDigitalEllipse;
199  typedef Boundary::SurfelConstIterator ConstIterator;
200  typedef Boundary::Tracker Tracker;
201  typedef Boundary::Surfel Surfel;
202 
203  unsigned int nbok = 0;
204  unsigned int nb = 0;
205  trace.beginBlock ( "Testing block ... LightImplicitDigitalSurface" );
206  Point p1( -10, -10, -10 );
207  Point p2( 10, 10, 10 );
208  KSpace K;
209  nbok += K.init( p1, p2, true ) ? 1 : 0;
210  nb++;
211  trace.info() << "(" << nbok << "/" << nb << ") "
212  << "K.init() is ok" << std::endl;
213  ImplicitDigitalEllipse ellipse( 6.0, 4.5, 3.4 );
214  Surfel bel = Surfaces<KSpace>::findABel( K, ellipse, 10000 );
215  Boundary boundary( K, ellipse,
216  SurfelAdjacency<KSpace::dimension>( true ), bel );
217  unsigned int nbsurfels = 0;
218  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
219  it != it_end; ++it )
220  {
221  ++nbsurfels;
222  }
223  trace.info() << nbsurfels << " surfels found." << std::endl;
224  trace.beginBlock ( "Checks if adjacent surfels are part of the surface." );
225 
226  for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
227  it != it_end; ++it )
228  {
229  Tracker* ptrTracker = boundary.newTracker( *it );
230  Surfel s = ptrTracker->current();
231  Dimension trackDir = * K.sDirs( s );
232  Surfel s1, s2;
233  // unsigned int m1 =
234  ptrTracker->adjacent( s1, trackDir, true );
235  // unsigned int m2 =
236  ptrTracker->adjacent( s2, trackDir, false );
237  // trace.info() << "s = " << s << std::endl;
238  // trace.info() << "s1 = " << s1 << " m1 = " << m1 << std::endl;
239  // trace.info() << "s2 = " << s2 << " m2 = " << m2 << std::endl;
240  nb++, nbok += boundary.isInside( s1 ) ? 1 : 0;
241  // trace.info() << "(" << nbok << "/" << nb << ") "
242  // << "boundary.isInside( s1 )" << std::endl;
243  nb++, nbok += boundary.isInside( s2 ) ? 1 : 0;
244  // trace.info() << "(" << nbok << "/" << nb << ") "
245  // << "boundary.isInside( s2 )" << std::endl;
246  delete ptrTracker;
247  }
248  trace.info() << "(" << nbok << "/" << nb << ") isInside tests." << std::endl;
249  trace.endBlock();
250  trace.endBlock();
251  return nbok == nb;
252 }
253 
254 template <typename Image3D>
255 void fillImage3D( Image3D & img,
256  typename Image3D::Point low,
257  typename Image3D::Point up,
258  typename Image3D::Value value )
259 {
260  typedef typename Image3D::Point Point;
261  typedef typename Image3D::Integer Integer;
262  for ( Integer z = low[ 2 ]; z <= up[ 2 ]; ++z )
263  for ( Integer y = low[ 1 ]; y <= up[ 1 ]; ++y )
264  for ( Integer x = low[ 0 ]; x <= up[ 0 ]; ++x )
265  img.setValue( Point( x, y, z ), value );
266 }
267 
268 //-----------------------------------------------------------------------------
269 // Testing ExplicitDigitalSurface
270 //-----------------------------------------------------------------------------
271 bool testExplicitDigitalSurface()
272 {
273  using namespace Z3i;
275  typedef FrontierPredicate<KSpace, Image> SurfelPredicate;
277  typedef Frontier::SurfelConstIterator ConstIterator;
278  typedef Frontier::Tracker Tracker;
279  typedef Frontier::SCell SCell;
280  typedef Frontier::Surfel Surfel;
281 
282  unsigned int nbok = 0;
283  unsigned int nb = 0;
284  trace.beginBlock ( "Testing block ... ExplicitDigitalSurface" );
285  Point p1( -5, -5, -5 );
286  Point p2( 5, 5, 5 );
287  KSpace K;
288  nbok += K.init( p1, p2, true ) ? 1 : 0;
289  nb++;
290  trace.info() << "(" << nbok << "/" << nb << ") "
291  << "K.init() is ok" << std::endl;
292  Image image( Domain(p1, p2) );
293  fillImage3D( image, p1, p2, 0 );
294  fillImage3D( image, Point(-2,-2,-2 ), Point( 2, 2, 2 ), 1 );
295  fillImage3D( image, Point( 0, 0,-2 ), Point( 0, 0, 2 ), 2 );
296  fillImage3D( image, Point(-1,-1, 2 ), Point( 1, 1, 2 ), 2 );
297  {
298  SCell vox2 = K.sSpel( Point( 0, 0, 2 ), K.POS );
299  SCell bel20 = K.sIncident( vox2, 2, true );
300  SurfelPredicate surfPredicate( K, image, 2, 0 );
301  Frontier frontier20( K, surfPredicate,
303  bel20 );
304  unsigned int nbsurfels = 0;
305  for ( ConstIterator it = frontier20.begin(), it_end = frontier20.end();
306  it != it_end; ++it )
307  {
308  ++nbsurfels;
309  }
310  trace.info() << nbsurfels << " surfels found." << std::endl;
311  nb++, nbok += nbsurfels == 9 ? 1 : 0;
312  trace.info() << "(" << nbok << "/" << nb << ") "
313  << "frontier20: nbsurfels == 9" << std::endl;
314  }
315  {
316  SCell vox1 = K.sSpel( Point( 2, 0, 0 ), K.POS );
317  SCell bel10 = K.sIncident( vox1, 0, true );
318  SurfelPredicate surfPredicate( K, image, 1, 0 );
319  Frontier frontier10( K, surfPredicate,
321  bel10 );
322  unsigned int nbsurfels = 0;
323  for ( ConstIterator it = frontier10.begin(), it_end = frontier10.end();
324  it != it_end; ++it )
325  {
326  ++nbsurfels;
327  }
328  trace.info() << nbsurfels << " surfels found." << std::endl;
329  nb++, nbok += nbsurfels == 140 ? 1 : 0; // 4*25(sides) + 16(top) + 24(bot)
330  trace.info() << "(" << nbok << "/" << nb << ") "
331  << "frontier10: nbsurfels == 140" << std::endl;
332  }
333  {
334  SCell vox1 = K.sSpel( Point( 1, 0, 0 ), K.POS );
335  SCell bel12 = K.sIncident( vox1, 0, false );
336  SurfelPredicate surfPredicate( K, image, 1, 2 );
337  Frontier frontier12( K, surfPredicate,
339  bel12 );
340  unsigned int nbsurfels = 0;
341  for ( ConstIterator it = frontier12.begin(), it_end = frontier12.end();
342  it != it_end; ++it )
343  {
344  ++nbsurfels;
345  }
346  trace.info() << nbsurfels << " surfels found." << std::endl;
347  nb++, nbok += nbsurfels == 36 ? 1 : 0; // 8+12(top) + 16(axis)
348  trace.info() << "(" << nbok << "/" << nb << ") "
349  << "frontier12: nbsurfels == 36" << std::endl;
350  }
351  {
352  typedef BoundaryPredicate<KSpace, Image> SecondSurfelPredicate;
354  typedef Boundary::SurfelConstIterator EConstIterator;
355  // typedef Boundary::Tracker Tracker;
356  // typedef Boundary::SCell SCell;
357  // typedef Boundary::Surfel Surfel;
358  SCell vox1 = K.sSpel( Point( 1, 0, 0 ), K.POS );
359  SCell bel1x = K.sIncident( vox1, 0, false );
360  SecondSurfelPredicate surfPredicate( K, image, 1 );
361  Boundary boundary1x( K, surfPredicate,
363  bel1x );
364  unsigned int nbsurfels = 0;
365  for ( EConstIterator it = boundary1x.begin(), it_end = boundary1x.end();
366  it != it_end; ++it )
367  {
368  ++nbsurfels;
369  }
370  trace.info() << nbsurfels << " surfels found." << std::endl;
371  nb++, nbok += nbsurfels == 176 ? 1 : 0;
372  trace.info() << "(" << nbok << "/" << nb << ") "
373  << "boundary1x: nbsurfels == 176" << std::endl;
374  }
375  trace.endBlock();
376  return nbok == nb;
377 }
378 
379 //-----------------------------------------------------------------------------
380 // Testing LightExplicitDigitalSurface
381 //-----------------------------------------------------------------------------
382 bool testLightExplicitDigitalSurface()
383 {
384  using namespace Z3i;
386  typedef FrontierPredicate<KSpace, Image> SurfelPredicate;
388  typedef Frontier::SurfelConstIterator ConstIterator;
389  typedef Frontier::Tracker Tracker;
390  typedef Frontier::SCell SCell;
391  typedef Frontier::Surfel Surfel;
392 
393  unsigned int nbok = 0;
394  unsigned int nb = 0;
395  trace.beginBlock ( "Testing block ... LightExplicitDigitalSurface" );
396  Point p1( -5, -5, -5 );
397  Point p2( 5, 5, 5 );
398  KSpace K;
399  nbok += K.init( p1, p2, true ) ? 1 : 0;
400  nb++;
401  trace.info() << "(" << nbok << "/" << nb << ") "
402  << "K.init() is ok" << std::endl;
403  Image image( Domain(p1, p2) );
404  fillImage3D( image, p1, p2, 0 );
405  fillImage3D( image, Point(-2,-2,-2 ), Point( 2, 2, 2 ), 1 );
406  fillImage3D( image, Point( 0, 0,-2 ), Point( 0, 0, 2 ), 2 );
407  fillImage3D( image, Point(-1,-1, 2 ), Point( 1, 1, 2 ), 2 );
408  {
409  SCell vox2 = K.sSpel( Point( 0, 0, 2 ), K.POS );
410  SCell bel20 = K.sIncident( vox2, 2, true );
411  SurfelPredicate surfPredicate( K, image, 2, 0 );
412  Frontier frontier20( K, surfPredicate,
414  bel20 );
415  unsigned int nbsurfels = 0;
416  for ( ConstIterator it = frontier20.begin(), it_end = frontier20.end();
417  it != it_end; ++it )
418  {
419  ++nbsurfels;
420  }
421  trace.info() << nbsurfels << " surfels found." << std::endl;
422  nb++, nbok += nbsurfels == 9 ? 1 : 0;
423  trace.info() << "(" << nbok << "/" << nb << ") "
424  << "frontier20: nbsurfels == 9" << std::endl;
425  }
426  {
427  SCell vox1 = K.sSpel( Point( 2, 0, 0 ), K.POS );
428  SCell bel10 = K.sIncident( vox1, 0, true );
429  SurfelPredicate surfPredicate( K, image, 1, 0 );
430  Frontier frontier10( K, surfPredicate,
432  bel10 );
433  unsigned int nbsurfels = 0;
434  for ( ConstIterator it = frontier10.begin(), it_end = frontier10.end();
435  it != it_end; ++it )
436  {
437  ++nbsurfels;
438  }
439  trace.info() << nbsurfels << " surfels found." << std::endl;
440  nb++, nbok += nbsurfels == 140 ? 1 : 0; // 4*25(sides) + 16(top) + 24(bot)
441  trace.info() << "(" << nbok << "/" << nb << ") "
442  << "frontier10: nbsurfels == 140" << std::endl;
443  }
444  {
445  SCell vox1 = K.sSpel( Point( 1, 0, 0 ), K.POS );
446  SCell bel12 = K.sIncident( vox1, 0, false );
447  SurfelPredicate surfPredicate( K, image, 1, 2 );
448  Frontier frontier12( K, surfPredicate,
450  bel12 );
451  unsigned int nbsurfels = 0;
452  for ( ConstIterator it = frontier12.begin(), it_end = frontier12.end();
453  it != it_end; ++it )
454  {
455  ++nbsurfels;
456  }
457  trace.info() << nbsurfels << " surfels found." << std::endl;
458  nb++, nbok += nbsurfels == 36 ? 1 : 0; // 8+12(top) + 16(axis)
459  trace.info() << "(" << nbok << "/" << nb << ") "
460  << "frontier12: nbsurfels == 36" << std::endl;
461  }
462  {
463  typedef BoundaryPredicate<KSpace, Image> SecondSurfelPredicate;
465  typedef Boundary::SurfelConstIterator LEConstIterator;
466  //typedef Boundary::Tracker Tracker;
467  //typedef Boundary::SCell SCell;
468  //typedef Boundary::Surfel Surfel;
469  SCell vox1 = K.sSpel( Point( 1, 0, 0 ), K.POS );
470  SCell bel1x = K.sIncident( vox1, 0, false );
471  SecondSurfelPredicate surfPredicate( K, image, 1 );
472  Boundary boundary1x( K, surfPredicate,
474  bel1x );
475  unsigned int nbsurfels = 0;
476  for ( LEConstIterator it = boundary1x.begin(), it_end = boundary1x.end();
477  it != it_end; ++it )
478  {
479  ++nbsurfels;
480  }
481  trace.info() << nbsurfels << " surfels found." << std::endl;
482  nb++, nbok += nbsurfels == 176 ? 1 : 0;
483  trace.info() << "(" << nbok << "/" << nb << ") "
484  << "boundary1x: nbsurfels == 176" << std::endl;
485  }
486  trace.endBlock();
487  return nbok == nb;
488 }
489 
490 
491 
492 template <typename KSpace>
493 bool testDigitalSurface()
494 {
495  unsigned int nbok = 0;
496  unsigned int nb = 0;
497  std::string msg( "Testing block ... DigitalSurface in K" );
498  msg += '0' + KSpace::dimension;
499  trace.beginBlock ( msg );
500  //"Testing block ... DigitalSurface " + std::string( KSpace.dimension ) );
501  typedef typename KSpace::Space Space;
502  typedef typename KSpace::Size Size;
503  typedef typename Space::Point Point;
506 
507  trace.beginBlock ( "Creating object and DigitalSurfaceContainer" );
508  Point p0 = Point::diagonal( 0 );
509  Point p1 = Point::diagonal( -6 );
510  Point p2 = Point::diagonal( 6 );
511  Domain domain( p1, p2 );
512  DigitalSet dig_set( domain );
513  Shapes<Domain>::addNorm2Ball( dig_set, p0, 3 );
514  Shapes<Domain>::removeNorm2Ball( dig_set, p0, 1 );
515  KSpace K;
516  nbok += K.init( domain.lowerBound(), domain.upperBound(), true ) ? 1 : 0;
517  nb++;
518  trace.info() << "(" << nbok << "/" << nb << ") "
519  << "K.init() is ok" << std::endl;
520  trace.endBlock();
521 
522  trace.beginBlock ( "Testing DigitalSurface" );
523  typedef DigitalSetBoundary<KSpace,DigitalSet> DSContainer;
524  typedef DigitalSurface<DSContainer> MyDS;
525 
526  //Checking the type as a model of CSinglePassConstRange
527  BOOST_CONCEPT_ASSERT(( CConstSinglePassRange < MyDS> ));
528  BOOST_CONCEPT_ASSERT(( CUndirectedSimpleLocalGraph < MyDS> ));
529  BOOST_CONCEPT_ASSERT(( CUndirectedSimpleGraph < MyDS> ));
530 
531 
532  typedef typename MyDS::Surfel Surfel;
533  DSContainer* ptrBdry = new DSContainer( K, dig_set );
534  MyDS digsurf( ptrBdry ); // acquired
535  Size nbsurfels =
536  ( K.dimension == 2 ) ? 12+28 :
537  ( K.dimension == 3 ) ? 30+174 :
538  ( K.dimension == 4 ) ? 56+984 :
539  ( K.dimension == 5 ) ? 4340 : 0;
540  nb++, nbok += digsurf.size() == nbsurfels ? 1 : 0;
541  trace.info() << "(" << nbok << "/" << nb << ") "
542  << "digsurf.size() = " << digsurf.size()
543  << " == " << nbsurfels << std::endl;
544  for ( typename MyDS::ConstIterator it = digsurf.begin(),
545  it_end = digsurf.end();
546  it != it_end;
547  ++it )
548  {
549  Surfel s = *it;
550  nb++, nbok += digsurf.degree( s ) == 2*(K.dimension-1) ? 1 : 0;
551  }
552  trace.info() << "(" << nbok << "/" << nb << ") "
553  << "digsurf.degree( s ) == "
554  << 2*(K.dimension-1) << std::endl;
555  trace.endBlock();
556  trace.beginBlock ( "Testing BreadthFirstVisitor on DigitalSurface" );
557  BreadthFirstVisitor< MyDS > visitor( digsurf, *digsurf.begin() );
558  typedef typename BreadthFirstVisitor< MyDS >::Node BFVNode;
559  typedef typename BreadthFirstVisitor< MyDS >::MarkSet BFVMarkSet;
560  unsigned int nb_dist_1 = 0;
561  BFVNode node;
562  while ( ! visitor.finished() )
563  {
564  node = visitor.current();
565  if ( node.second == 1 ) ++nb_dist_1;
566  visitor.expand();
567  }
568  trace.info() << "last node v=" << node.first << " d=" << node.second << std::endl;
569  nb++, nbok += nb_dist_1 == 2*(K.dimension-1) ? 1 : 0;
570  trace.info() << "(" << nbok << "/" << nb << ") "
571  << "nb surfels at distance 1 == "
572  << 2*(K.dimension-1) << std::endl;
573  const BFVMarkSet & visitedVtx = visitor.markedVertices();
574  Size nbsurfelsComp1 =
575  ( K.dimension == 2 ) ? 28 :
576  ( K.dimension == 3 ) ? 174 :
577  ( K.dimension == 4 ) ? 984 : 0;
578  nb++, nbok += visitedVtx.size() == nbsurfelsComp1 ? 1 : 0;
579  trace.info() << "(" << nbok << "/" << nb << ") "
580  << "nb visited = " << visitedVtx.size() << " == "
581  << nbsurfelsComp1 << std::endl;
582 
583  trace.endBlock();
584 
585 
586  trace.endBlock();
587  return nbok == nb;
588 }
589 
591 // Standard services - public :
592 
593 int main( int argc, char** argv )
594 {
595  trace.beginBlock ( "Testing class DigitalSurface" );
596  trace.info() << "Args:";
597  for ( int i = 0; i < argc; ++i )
598  trace.info() << " " << argv[ i ];
599  trace.info() << endl;
600 
601  bool res = testDigitalSetBoundary()
602  && testImplicitDigitalSurface()
603  && testLightImplicitDigitalSurface()
604  && testExplicitDigitalSurface()
605  && testLightExplicitDigitalSurface()
606  && testDigitalSurface<KhalimskySpaceND<2> >()
607  && testDigitalSurface<KhalimskySpaceND<3> >()
608  && testDigitalSurface<KhalimskySpaceND<4> >();
609  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
610  trace.endBlock();
611  return res ? 0 : 1;
612 }
613 // //