DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testImplicitDigitalSurface-benchmark.cpp
1
16
29
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/ImplicitDigitalSurface.h"
36
#include "DGtal/graph/BreadthFirstVisitor.h"
37
#include "DGtal/shapes/Shapes.h"
39
40
using namespace
std
;
41
using namespace
DGtal
;
42
44
// Functions for testing class ImplicitDigitalSurface.
46
namespace
DGtal
{
47
template
<
typename
KSpace,
typename
Po
int
Predicate>
48
bool
49
testImplicitDigitalSurface
(
const
KSpace
&
K
,
50
const
PointPredicate & pp,
51
const
typename
KSpace::Surfel
& bel )
52
{
53
typedef
ImplicitDigitalSurface<KSpace,PointPredicate>
Boundary;
54
typedef
typename
Boundary::SurfelConstIterator
ConstIterator
;
55
56
unsigned
int
nbok = 0;
57
unsigned
int
nb = 0;
58
trace
.
beginBlock
(
"Testing block ... ImplicitDigitalSurface"
);
59
trace
.
beginBlock
(
"ImplicitDigitalSurface instantiation"
);
60
Boundary boundary(
K
, pp,
61
SurfelAdjacency<KSpace::dimension>
(
true
), bel,
62
true
);
63
trace
.
endBlock
();
64
trace
.
beginBlock
(
"Counting the number of surfels (breadth first traversal)"
);
65
unsigned
int
nbsurfels = 0;
66
for
(
ConstIterator
it = boundary.begin(), it_end = boundary.end();
67
it != it_end; ++it )
68
{
69
++nbsurfels;
70
}
71
trace
.
info
() << nbsurfels <<
" surfels found."
<< std::endl;
72
nb++; nbok += nbsurfels == 354382 ? 1 : 0;
73
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
74
<<
"nbsurfels == 354382"
<< std::endl;
75
trace
.
endBlock
();
76
trace
.
endBlock
();
77
return
nbok == nb;
78
}
79
80
81
template
<
typename
TPo
int
3>
82
struct
ImplicitDigitalEllipse3
{
83
typedef
TPoint3
Point
;
84
inline
85
ImplicitDigitalEllipse3
(
double
a,
double
b,
double
c )
86
:
myA
( a ),
myB
( b ),
myC
( c )
87
{}
88
inline
89
bool
operator()
(
const
TPoint3 & p )
const
90
{
91
double
x = ( (double) p[ 0 ] /
myA
);
92
double
y = ( (double) p[ 1 ] /
myB
);
93
double
z = ( (double) p[ 2 ] /
myC
);
94
return
( x*x + y*y + z*z ) <= 1.0;
95
}
96
double
myA
,
myB
,
myC
;
97
};
98
}
99
101
// Standard services - public :
102
103
int
main
(
int
,
char
** )
104
{
105
using namespace
Z3i
;
106
typedef
DGtal::ImplicitDigitalEllipse3<Point>
ImplicitDigitalEllipse;
107
typedef
KSpace::SCell
Surfel
;
108
bool
res;
109
trace
.
beginBlock
(
"Testing class Object"
);
110
Point
p1( -200, -200, -200 );
111
Point
p2( 200, 200, 200 );
112
KSpace
K
;
113
if
(
K
.
init
( p1, p2,
true
) )
114
{
115
ImplicitDigitalEllipse ellipse( 180.0, 135.0, 102.0 );
116
Surfel
bel =
Surfaces<KSpace>::findABel
(
K
, ellipse, 10000 );
117
res =
118
testImplicitDigitalSurface<KSpace, ImplicitDigitalEllipse>
119
(
K
, ellipse, bel );
120
}
121
else
122
res =
false
;
123
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
124
trace
.
endBlock
();
125
return
res ? 0 : 1;
126
}
DGtal::ImplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Definition
ImplicitDigitalSurface.h:72
DGtal::ConstIterator
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::KhalimskySpaceND< 3, Integer >::SCell
SignedKhalimskyCell< dim, Integer > SCell
Definition
KhalimskySpaceND.h:417
DGtal::KhalimskySpaceND< 3, Integer >::Surfel
SCell Surfel
Definition
KhalimskySpaceND.h:420
DGtal::Point
DGtal::Surfaces::findABel
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
DGtal::testImplicitDigitalSurface
bool testImplicitDigitalSurface(const KSpace &K, const PointPredicate &pp, const typename KSpace::Surfel &bel)
Definition
testImplicitDigitalSurface-benchmark.cpp:49
std
STL namespace.
DGtal::ImplicitDigitalEllipse3
Definition
testImplicitDigitalSurface-benchmark.cpp:82
DGtal::ImplicitDigitalEllipse3::myC
double myC
Definition
testImplicitDigitalSurface-benchmark.cpp:96
DGtal::ImplicitDigitalEllipse3::operator()
bool operator()(const TPoint3 &p) const
Definition
testImplicitDigitalSurface-benchmark.cpp:89
DGtal::ImplicitDigitalEllipse3::ImplicitDigitalEllipse3
ImplicitDigitalEllipse3(double a, double b, double c)
Definition
testImplicitDigitalSurface-benchmark.cpp:85
DGtal::ImplicitDigitalEllipse3::myA
double myA
Definition
testImplicitDigitalSurface-benchmark.cpp:96
DGtal::ImplicitDigitalEllipse3::myB
double myB
Definition
testImplicitDigitalSurface-benchmark.cpp:96
DGtal::ImplicitDigitalEllipse3::Point
TPoint3 Point
Definition
testImplicitDigitalSurface-benchmark.cpp:83
Surfel
KSpace::SCell Surfel
Definition
testArithmeticalDSSComputerOnSurfels.cpp:50
KSpace
Z3i::KSpace KSpace
Definition
testArithmeticalDSSComputerOnSurfels.cpp:48
K
KSpace K
Definition
testCubicalComplex.cpp:62
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
benchmarks
topology
testImplicitDigitalSurface-benchmark.cpp
Generated on
for DGtal by
1.18.0