DGtal 1.3.0
Loading...
Searching...
No Matches
SphericalAccumulator.h
1
17#pragma once
18
31#if defined(SphericalAccumulator_RECURSES)
32#error Recursive header files inclusion detected in SphericalAccumulator.h
33#else // defined(SphericalAccumulator_RECURSES)
35#define SphericalAccumulator_RECURSES
36
37#if !defined SphericalAccumulator_h
39#define SphericalAccumulator_h
40
42// Inclusions
43#include <iostream>
44#include <algorithm>
45#include "DGtal/base/Common.h"
46#include "DGtal/kernel/PointVector.h"
47#include "DGtal/kernel/NumberTraits.h"
49
50namespace DGtal
51{
52
54 // template class SphericalAccumulator
101 template <typename TVector>
103 {
104 // ----------------------- Standard services ------------------------------
105 public:
106
108 typedef TVector Vector;
109
112
114 typedef size_t Size;
115
117 typedef std::vector<Quantity>::const_iterator ConstIterator;
118
121
122 BOOST_STATIC_ASSERT( Vector::dimension == 3);
123
134
139
140 // ----------------------- Interface --------------------------------------
141 public:
142
149 void addDirection(const Vector &aDir);
150
160 void binCoordinates(const Vector &aDir,
161 Size &posPhi,
162 Size &posTheta) const;
163
173 Quantity count( const Size &posPhi,
174 const Size &posTheta) const;
175
176
193 const Size &posTheta) const;
194
204
205
212
217 Quantity binNumber() const { return myBinNumber;}
218
219
227 void maxCountBin(Size &posPhi, Size &posTheta) const;
228
233 void clear();
234
235
240 void selfDisplay ( std::ostream & out ) const;
241
246 bool isValid() const;
247
252 std::string className() const
253 {
254 return "SphericalAccumulator";
255 }
256
257
266 bool isValidBin(const Size &posPhi,
267 const Size &posTheta) const;
268
269
281 void getBinGeometry(const Size &posPhi,
282 const Size &posTheta,
283 RealVector &a,
284 RealVector &b,
285 RealVector &c,
286 RealVector &d) const;
287
297 const Size &posTheta) const;
298
299 // ------------------------- Iterators ------------------------------
300
309 {
310 return myAccumulator.begin();
311 }
312
317 {
318 return myAccumulator.end();
319 }
320
321
330 Size &posPhi,
331 Size &posTheta) const;
332
333
339 {
340 myNphi = other.myNphi;
341 myNtheta = other.myNtheta;
344 myTotal = other.myTotal;
345 myBinNumber = other.myBinNumber;
346 myMaxBinPhi = other.myMaxBinPhi;
348 }
349
357 {
358 if (this!=other)
359 {
360 myNphi = other.myNphi;
361 myNtheta = other.myNtheta;
364 myTotal = other.myTotal;
365 myBinNumber = other.myBinNumber;
366 myMaxBinPhi = other.myMaxBinPhi;
368 }
369 return *this;
370 }
371
372
373
374 // ------------------------- Private Datas --------------------------------
375 private:
376
379
382
384 std::vector<Quantity> myAccumulator;
385
387 std::vector<Vector> myAccumulatorDir;
388
391
394
397
400
401
402 // ------------------------- Hidden services ------------------------------
403 protected:
404
410
411 private:
412
413 // ------------------------- Internals ------------------------------------
414 private:
415
416 }; // end of class SphericalAccumulator
417
418
425 template <typename T>
426 std::ostream&
427 operator<< ( std::ostream & out, const SphericalAccumulator<T> & object );
428
429} // namespace DGtal
430
431
433// Includes inline functions.
434#include "DGtal/geometry/tools//SphericalAccumulator.ih"
435
436// //
438
439#endif // !defined SphericalAccumulator_h
440
441#undef SphericalAccumulator_RECURSES
442#endif // else defined(SphericalAccumulator_RECURSES)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples.
SphericalAccumulator & operator=(const SphericalAccumulator &other)
Quantity myBinNumber
Number of bins.
std::vector< Quantity >::const_iterator ConstIterator
Type to iterate on bin values.
std::vector< Vector > myAccumulatorDir
Accumulator reprensentative directions.
Vector representativeDirection(ConstIterator &it) const
Size myMaxBinTheta
Theta coordinate of the max bin.
void maxCountBin(Size &posPhi, Size &posTheta) const
Quantity count(const Size &posPhi, const Size &posTheta) const
RealVector getBinDirection(const Size &posPhi, const Size &posTheta) const
void binCoordinates(const Vector &aDir, Size &posPhi, Size &posTheta) const
void selfDisplay(std::ostream &out) const
void getBinGeometry(const Size &posPhi, const Size &posTheta, RealVector &a, RealVector &b, RealVector &c, RealVector &d) const
BOOST_STATIC_ASSERT(Vector::dimension==3)
TVector Vector
Vector direction types.
size_t Size
Type to represent bin indexes.
DGtal::int32_t Quantity
Type to store the bin counts.
Size myNphi
Number of slices in the phi direction.
void binCoordinates(ConstIterator &aDir, Size &posPhi, Size &posTheta) const
Quantity myTotal
Number of samples.
SphericalAccumulator(const SphericalAccumulator &other)
PointVector< 3, double > RealVector
Type to represent normalized vector (internal use).
Size myNtheta
Number of bins in the theta direction.
Vector representativeDirection(const Size &posPhi, const Size &posTheta) const
std::vector< Quantity > myAccumulator
Accumulator container.
SphericalAccumulator(const Size aNphi)
bool isValidBin(const Size &posPhi, const Size &posTheta) const
Size myMaxBinPhi
Phi coordinate of the max bin.
Quantity samples() const
void addDirection(const Vector &aDir)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72