DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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/NumberTraits.h"
48 
49 namespace DGtal
50 {
51 
53  // template class SphericalAccumulator
100  template <typename TVector>
102  {
103  // ----------------------- Standard services ------------------------------
104  public:
105 
107  typedef TVector Vector;
108 
111 
114 
116  typedef std::vector<Quantity>::const_iterator ConstIterator;
117 
120 
121  BOOST_STATIC_ASSERT( Vector::dimension == 3);
122 
132  SphericalAccumulator(const Size aNphi);
133 
138 
139  // ----------------------- Interface --------------------------------------
140  public:
141 
148  void addDirection(const Vector &aDir);
149 
159  void binCoordinates(const Vector &aDir,
160  Size &posPhi,
161  Size &posTheta) const;
162 
172  Quantity count( const Size &posPhi,
173  const Size &posTheta) const;
174 
175 
191  Vector representativeDirection(const Size &posPhi,
192  const Size &posTheta) const;
193 
203 
204 
210  Quantity samples() const;
211 
216  Quantity binNumber() const { return myBinNumber;}
217 
218 
226  void maxCountBin(Size &posPhi, Size &posTheta) const;
227 
232  void clear();
233 
234 
239  void selfDisplay ( std::ostream & out ) const;
240 
245  bool isValid() const;
246 
251  std::string className() const
252  {
253  return "SphericalAccumulator";
254  }
255 
256 
265  bool isValidBin(const Size &posPhi,
266  const Size &posTheta) const;
267 
268 
280  void getBinGeometry(const Size &posPhi,
281  const Size &posTheta,
282  RealVector &a,
283  RealVector &b,
284  RealVector &c,
285  RealVector &d) const;
286 
287  // ------------------------- Iterators ------------------------------
288 
297  {
298  return myAccumulator.begin();
299  }
300 
305  {
306  return myAccumulator.end();
307  }
308 
309 
317  void binCoordinates(ConstIterator &aDir,
318  Size &posPhi,
319  Size &posTheta) const;
320 
321  // ------------------------- Protected Datas ------------------------------
322  private:
323  // ------------------------- Private Datas --------------------------------
324  private:
325 
328 
331 
333  std::vector<Quantity> myAccumulator;
334 
336  std::vector<Vector> myAccumulatorDir;
337 
340 
343 
346 
349 
350 
351  // ------------------------- Hidden services ------------------------------
352  protected:
353 
359 
360  private:
361 
367  SphericalAccumulator ( const SphericalAccumulator & other );
368 
376 
377  // ------------------------- Internals ------------------------------------
378  private:
379 
380  }; // end of class SphericalAccumulator
381 
382 
389  template <typename T>
390  std::ostream&
391  operator<< ( std::ostream & out, const SphericalAccumulator<T> & object );
392 
393 } // namespace DGtal
394 
395 
397 // Includes inline functions.
398 #include "DGtal/geometry/tools//SphericalAccumulator.ih"
399 
400 // //
402 
403 #endif // !defined SphericalAccumulator_h
404 
405 #undef SphericalAccumulator_RECURSES
406 #endif // else defined(SphericalAccumulator_RECURSES)