DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testBallQuadViewer.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtal/helpers/StdDefs.h"
35
#include "DGtal/topology/ImplicitDigitalSurface.h"
36
#include "DGtal/io/viewers/PolyscopeViewer.h"
38
39
using namespace
std
;
40
using namespace
DGtal
;
41
43
// Functions for testing class BallQuad.
45
49
template
<
typename
TPo
int
3>
50
struct
ImplicitDigitalBall3
{
51
typedef
TPoint3
Point
;
52
inline
53
ImplicitDigitalBall3
(
double
r )
54
:
myR
( r )
55
{}
56
inline
57
bool
operator()
(
const
TPoint3 & p )
const
58
{
59
double
x = ( (double) p[ 0 ] );
60
double
y = ( (double) p[ 1 ] );
61
double
z = ( (double) p[ 2 ] );
62
return
( x*x + y*y + z*z -
myR
*
myR
) <= 0.0;
63
}
64
double
myR
;
65
};
66
67
68
void
testBallQuad
()
69
{
70
unsigned
int
nbok = 0;
71
unsigned
int
nb = 0;
72
73
trace
.
beginBlock
(
"Testing... Ball with quadnormal"
);
74
using namespace
Z3i
;
75
typedef
ImplicitDigitalBall3<Point>
ImplicitDigitalBall;
76
typedef
ImplicitDigitalSurface<KSpace,ImplicitDigitalBall>
Boundary;
77
typedef
Boundary::SurfelConstIterator
ConstIterator
;
78
typedef
Boundary::Surfel
Surfel
;
79
Point
p1( -100, -100, -100 );
80
Point
p2( 100, 100, 100 );
81
KSpace
K
;
82
nbok +=
K
.
init
( p1, p2,
true
) ? 1 : 0;
83
nb++;
84
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
85
<<
"K.init() is ok"
<< std::endl;
86
ImplicitDigitalBall ball( 60.0 );
87
Surfel
bel =
Surfaces<KSpace>::findABel
(
K
, ball, 10000 );
88
Boundary boundary(
K
, ball,
89
SurfelAdjacency<KSpace::dimension>
(
true
), bel );
90
unsigned
int
nbsurfels = 0;
91
92
PolyscopeViewer<Space,KSpace>
viewer(
K
);
93
viewer.
allowReuseList
=
true
;
94
95
for
(
ConstIterator
it = boundary.begin(), it_end = boundary.end();
96
it != it_end; ++it )
97
{
98
++nbsurfels;
99
viewer << *it;
100
}
101
102
trace
.
info
() << nbsurfels <<
" surfels found."
<< std::endl;
103
104
viewer.
show
();
105
}
106
108
// Standard services - public :
109
110
int
main
(
int
argc,
char
** argv )
111
{
112
trace
.
beginBlock
(
"Testing class BallQuad"
);
113
trace
.
info
() <<
"Args:"
;
114
for
(
int
i = 0; i < argc; ++i )
115
trace
.
info
() <<
" "
<< argv[ i ];
116
trace
.
info
() << endl;
117
118
testBallQuad
();
// && ... other tests
119
trace
.
emphase
() <<
"Passed."
<< endl;
120
trace
.
endBlock
();
121
return
0;
122
}
123
// //
DGtal::Display3D::allowReuseList
bool allowReuseList
Definition
Display3D.h:749
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::PolyscopeViewer
Definition
PolyscopeViewer.h:57
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:73
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
std
STL namespace.
ImplicitDigitalBall3
Definition
testBallQuadViewer.cpp:50
ImplicitDigitalBall3::operator()
bool operator()(const TPoint3 &p) const
Definition
testBallQuadViewer.cpp:57
ImplicitDigitalBall3::myR
double myR
Definition
testBallQuadViewer.cpp:64
ImplicitDigitalBall3::Point
TPoint3 Point
Definition
testBallQuadViewer.cpp:51
ImplicitDigitalBall3::ImplicitDigitalBall3
ImplicitDigitalBall3(double r)
Definition
testBallQuadViewer.cpp:53
Surfel
KSpace::SCell Surfel
Definition
testArithmeticalDSSComputerOnSurfels.cpp:50
KSpace
Z3i::KSpace KSpace
Definition
testArithmeticalDSSComputerOnSurfels.cpp:48
testBallQuad
void testBallQuad()
Definition
testBallQuadViewer.cpp:68
K
KSpace K
Definition
testCubicalComplex.cpp:62
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
io
viewers
testBallQuadViewer.cpp
Generated on
for DGtal by
1.18.0