DGtal 1.3.0
Loading...
Searching...
No Matches
testLightImplicitDigitalSurface-benchmark.cpp
1
31#include <iostream>
32#include "DGtal/base/Common.h"
33#include "DGtal/topology/DigitalSurface.h"
34#include "DGtal/topology/DigitalSetBoundary.h"
35#include "DGtal/topology/LightImplicitDigitalSurface.h"
36#include "DGtal/graph/BreadthFirstVisitor.h"
37#include "DGtal/shapes/Shapes.h"
39
40using namespace std;
41using namespace DGtal;
42
44// Functions for testing class LightImplicitDigitalSurface.
46namespace DGtal {
47 template <typename KSpace, typename PointPredicate>
48 bool
50 const PointPredicate & pp,
51 const typename KSpace::Surfel & bel )
52 {
54 typedef typename Boundary::SurfelConstIterator ConstIterator;
55
56 unsigned int nbok = 0;
57 unsigned int nb = 0;
58 trace.beginBlock ( "Testing block ... LightImplicitDigitalSurface" );
59 trace.beginBlock ( "LightImplicitDigitalSurface instanciation" );
60 Boundary boundary( K, pp,
63 trace.beginBlock ( "Counting the number of surfels (breadth first traversal)" );
64 unsigned int nbsurfels = 0;
65 for ( ConstIterator it = boundary.begin(), it_end = boundary.end();
66 it != it_end; ++it )
67 {
68 ++nbsurfels;
69 }
70 trace.info() << nbsurfels << " surfels found." << std::endl;
71 nb++; nbok += nbsurfels == 354382 ? 1 : 0;
72 trace.info() << "(" << nbok << "/" << nb << ") "
73 << "nbsurfels == 354382" << std::endl;
76 return nbok == nb;
77 }
78
79
80 template <typename TPoint3>
81 struct ImplicitDigitalEllipse3 {
82 typedef TPoint3 Point;
83 inline
84 ImplicitDigitalEllipse3( double a, double b, double c )
85 : myA( a ), myB( b ), myC( c )
86 {}
87 inline
88 bool operator()( const TPoint3 & p ) const
89 {
90 double x = ( (double) p[ 0 ] / myA );
91 double y = ( (double) p[ 1 ] / myB );
92 double z = ( (double) p[ 2 ] / myC );
93 return ( x*x + y*y + z*z ) <= 1.0;
94 }
95 double myA, myB, myC;
96 };
97}
98
100// Standard services - public :
101
102int main( int, char** )
103{
104 using namespace Z3i;
105 typedef DGtal::ImplicitDigitalEllipse3<Point> ImplicitDigitalEllipse;
106 typedef KSpace::SCell Surfel;
107 bool res;
108 trace.beginBlock ( "Testing class Object" );
109 Point p1( -200, -200, -200 );
110 Point p2( 200, 200, 200 );
111 KSpace K;
112 if ( K.init( p1, p2, true ) )
113 {
114 ImplicitDigitalEllipse ellipse( 180.0, 135.0, 102.0 );
115 Surfel bel = Surfaces<KSpace>::findABel( K, ellipse, 10000 );
116 res = testLightImplicitDigitalSurface<KSpace, ImplicitDigitalEllipse>
117 ( K, ellipse, bel );
118 }
119 else
120 res = false;
121 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
122 trace.endBlock();
123 return res ? 0 : 1;
124}
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.
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...
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
STL namespace.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
int main()
Definition: testBits.cpp:56
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
bool testLightImplicitDigitalSurface()