DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testSphericalAccumulatorViewer.cpp
1
16
29
32
#include <iostream>
33
#include "DGtal/base/Common.h"
34
#include "DGtal/helpers/StdDefs.h"
35
#include "DGtal/io/viewers/PolyscopeViewer.h"
36
#include "DGtal/geometry/tools/SphericalAccumulator.h"
38
39
using namespace
std
;
40
using namespace
DGtal
;
41
using namespace
Z3i
;
42
44
// Functions for testing class SphericalAccumulator.
46
void
testSphericalViewer()
47
{
48
trace
.
beginBlock
(
"Testing Spherical Accumulator Viewer..."
);
49
50
typedef
Z3i::RealVector
Vector
;
51
52
SphericalAccumulator<Vector>
accumulator(15);
53
trace
.
info
()<< accumulator << std::endl;
54
55
for
(
unsigned
int
i=0; i< 10000; i++)
56
accumulator.addDirection(
Vector
(1+10.0*(rand()-RAND_MAX/2)/(
double
)RAND_MAX,
57
(1+10.0*(rand()-RAND_MAX/2))/(
double
)RAND_MAX,
58
(1+10.0*(rand()-RAND_MAX/2))/(
double
)RAND_MAX));
59
60
PolyscopeViewer<>
viewer;
61
Vector
a,b,c,d;
62
viewer << accumulator;
63
64
trace
.
info
() <<
"Bin values: "
;
65
for
(
SphericalAccumulator<Vector>::ConstIterator
it=accumulator.begin(), itend=accumulator.end();
66
it != itend;
67
++it)
68
trace
.
info
() << *it<<
" "
;
69
trace
.
info
() << std::endl;
70
trace
.
info
() << accumulator<<std::endl;
71
72
trace
.
emphase
() <<
"Passed."
<< endl;
73
trace
.
endBlock
();
74
viewer.
show
();
75
}
76
77
void
testSphericalViewerInteger()
78
{
79
trace
.
beginBlock
(
"Testing Spherical Accumulator Viewer with Integer numbers..."
);
80
81
typedef
Z3i::Vector
Vector
;
82
83
SphericalAccumulator<Vector>
accumulator(15);
84
trace
.
info
()<< accumulator << std::endl;
85
86
for
(
unsigned
int
i=0; i< 10000; i++)
87
accumulator.addDirection(
Vector
(1+(rand()-RAND_MAX/2),
88
(1+(rand()-RAND_MAX/2)),
89
(1+(rand()-RAND_MAX/2))));
90
91
PolyscopeViewer<>
viewer;
92
viewer << accumulator;
93
// Display3DFactory<Space,KSpace>::draw(viewer,accumulator, Z3i::RealVector(1.0,1.0,1.0), 3.0);
94
95
trace
.
info
() <<
"Bin values: "
;
96
for
(
SphericalAccumulator<Vector>::ConstIterator
it=accumulator.begin(), itend=accumulator.end();
97
it != itend;
98
++it)
99
trace
.
info
() << *it<<
" "
;
100
trace
.
info
() << std::endl;
101
trace
.
info
() << accumulator<<std::endl;
102
103
trace
.
emphase
() <<
"Passed."
<< endl;
104
trace
.
endBlock
();
105
viewer.
show
();
106
}
107
109
// Standard services - public :
110
111
int
main
(
int
argc,
char
** argv )
112
{
113
trace
.
beginBlock
(
"Testing class SphericalAccumulator"
);
114
trace
.
info
() <<
"Args:"
;
115
for
(
int
i = 0; i < argc; ++i )
116
trace
.
info
() <<
" "
<< argv[ i ];
117
trace
.
info
() << endl;
118
119
testSphericalViewer();
120
testSphericalViewerInteger();
121
trace
.
emphase
() <<
"Passed."
<< endl;
122
trace
.
endBlock
();
123
return
0;
124
}
125
// //
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::Vector
DGtal::SphericalAccumulator
Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples.
Definition
SphericalAccumulator.h:103
DGtal::SphericalAccumulator::ConstIterator
std::vector< Quantity >::const_iterator ConstIterator
Type to iterate on bin values.
Definition
SphericalAccumulator.h:117
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::Z3i::RealVector
Space::RealVector RealVector
Definition
StdDefs.h:171
DGtal::Z3i::Vector
Space::Vector Vector
Definition
StdDefs.h:169
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.
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
geometry
tools
testSphericalAccumulatorViewer.cpp
Generated on
for DGtal by
1.18.0