DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testLightImplicitDigitalSurface-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/LightImplicitDigitalSurface.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 LightImplicitDigitalSurface.
46
namespace
DGtal
{
47
template
<
typename
KSpace,
typename
Po
int
Predicate>
48
bool
49
testLightImplicitDigitalSurface
(
const
KSpace
&
K
,
50
const
PointPredicate & pp,
51
const
typename
KSpace::Surfel
& bel )
52
{
53
typedef
LightImplicitDigitalSurface<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 ... LightImplicitDigitalSurface"
);
59
trace
.
beginBlock
(
"LightImplicitDigitalSurface instantiation"
);
60
Boundary boundary(
K
, pp,
61
SurfelAdjacency<KSpace::dimension>
(
true
), bel );
62
trace
.
endBlock
();
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;
74
trace
.
endBlock
();
75
trace
.
endBlock
();
76
return
nbok == nb;
77
}
78
79
80
template
<
typename
TPo
int
3>
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
102
int
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
}
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::LightImplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Definition
LightImplicitDigitalSurface.h:116
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::testLightImplicitDigitalSurface
bool testLightImplicitDigitalSurface(const KSpace &K, const PointPredicate &pp, const typename KSpace::Surfel &bel)
Definition
testLightImplicitDigitalSurface-benchmark.cpp:49
DGtal::trace
Trace trace
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
testLightImplicitDigitalSurface-benchmark.cpp:88
DGtal::ImplicitDigitalEllipse3::ImplicitDigitalEllipse3
ImplicitDigitalEllipse3(double a, double b, double c)
Definition
testLightImplicitDigitalSurface-benchmark.cpp:84
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
testLightImplicitDigitalSurface-benchmark.cpp
Generated on
for DGtal by
1.18.0