DGtal  0.9.2
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)
34 
35 #define SphericalAccumulator_RECURSES
36 
37 #if !defined SphericalAccumulator_h
38 
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 
50 namespace DGtal
51 {
52 
54  // template class SphericalAccumulator
101  template <typename TVector>
103  {
104  // ----------------------- Standard services ------------------------------
105  public:
106 
108  typedef TVector Vector;
109 
112 
115 
117  typedef std::vector<Quantity>::const_iterator ConstIterator;
118 
121 
122  BOOST_STATIC_ASSERT( Vector::dimension == 3);
123 
133  SphericalAccumulator(const Size aNphi);
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 
192  Vector representativeDirection(const Size &posPhi,
193  const Size &posTheta) const;
194 
203  Vector representativeDirection(ConstIterator &it) const;
204 
205 
211  Quantity samples() const;
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 
296  RealVector getBinDirection(const Size &posPhi,
297  const Size &posTheta) const;
298 
299  // ------------------------- Iterators ------------------------------
300 
308  ConstIterator begin() const
309  {
310  return myAccumulator.begin();
311  }
312 
316  ConstIterator end() const
317  {
318  return myAccumulator.end();
319  }
320 
321 
329  void binCoordinates(ConstIterator &aDir,
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;
367  myMaxBinTheta = other.myMaxBinTheta;
368  }
369  return *this;
370  }
371 
372 
373 
374  // ------------------------- Private Datas --------------------------------
375  private:
376 
378  Size myNphi;
379 
381  Size myNtheta;
382 
384  std::vector<Quantity> myAccumulator;
385 
387  std::vector<Vector> myAccumulatorDir;
388 
390  Quantity myTotal;
391 
393  Quantity myBinNumber;
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)
SphericalAccumulator & operator=(const SphericalAccumulator &other)
std::vector< Vector > myAccumulatorDir
Accumulator reprensentative directions.
void maxCountBin(Size &posPhi, Size &posTheta) const
boost::uint32_t uint32_t
unsigned 32-bit integer.
Definition: BasicTypes.h:63
std::vector< Quantity > myAccumulator
Accumulator container.
TVector Vector
Vector direction types.
Quantity myTotal
Number of samples.
Size myMaxBinPhi
Phi coordinate of the max bin.
std::vector< Quantity >::const_iterator ConstIterator
Type to iterate on bin values.
Size myNphi
Number of slices in the phi direction.
Quantity samples() const
PointVector< 3, double > RealVector
Type to represent normalized vector (internal use).
RealVector getBinDirection(const Size &posPhi, const Size &posTheta) const
void addDirection(const Vector &aDir)
void binCoordinates(const Vector &aDir, Size &posPhi, Size &posTheta) const
Size myMaxBinTheta
Theta coordinate of the max bin.
void selfDisplay(std::ostream &out) const
Quantity count(const Size &posPhi, const Size &posTheta) const
ConstIterator begin() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples...
Size myNtheta
Number of bins in the theta direction.
Vector representativeDirection(const Size &posPhi, const Size &posTheta) const
BOOST_STATIC_ASSERT(Vector::dimension==3)
DGtal::uint32_t Size
Type to represent bin indexes.
Quantity myBinNumber
Number of bins.
DGtal::int32_t Quantity
Type to store the bin counts.
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
bool isValidBin(const Size &posPhi, const Size &posTheta) const
SphericalAccumulator(const SphericalAccumulator &other)
void getBinGeometry(const Size &posPhi, const Size &posTheta, RealVector &a, RealVector &b, RealVector &c, RealVector &d) const