DGtal 2.0.0
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
39using namespace std;
40using namespace DGtal;
41using namespace Z3i;
42
44// Functions for testing class SphericalAccumulator.
46void 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
77void 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
111int 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// //
void show() override
Starts the event loop and display of elements.
Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples.
std::vector< Quantity >::const_iterator ConstIterator
Type to iterate on bin values.
Z3i this namespace gathers the standard of types for 3D imagery.
Space::RealVector RealVector
Definition StdDefs.h:171
Space::Vector Vector
Definition StdDefs.h:169
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
STL namespace.
int main()
Definition testBits.cpp:56