DGtal  0.9.2
BinomialConvolver.h
1 
17 #pragma once
18 
31 #if defined(BinomialConvolver_RECURSES)
32 #error Recursive header files inclusion detected in BinomialConvolver.h
33 #else // defined(BinomialConvolver_RECURSES)
34 
35 #define BinomialConvolver_RECURSES
36 
37 #if !defined BinomialConvolver_h
38 
39 #define BinomialConvolver_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <map>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/math/Signal.h"
48 
49 namespace DGtal
50 {
51 
53  // template class BinomialConvolver
72  template <typename TConstIteratorOnPoints, typename TValue = double>
74  {
75  // ----------------------- Standard services ------------------------------
76  public:
77  typedef TValue Value;
78  typedef TConstIteratorOnPoints ConstIteratorOnPoints;
79  typedef typename ConstIteratorOnPoints::value_type Point;
80 
89  BinomialConvolver( unsigned int n = 1 );
90 
91 
96 
101  void setSize( unsigned int n );
102 
107  unsigned int size() const;
108 
114  static
115  unsigned int suggestedSize( const double h,
116  const ConstIteratorOnPoints& itb,
117  const ConstIteratorOnPoints& ite );
118 
128  void init( const double h,
129  const ConstIteratorOnPoints& itb,
130  const ConstIteratorOnPoints& ite,
131  const bool isClosed );
132 
143  int index( const ConstIteratorOnPoints& it ) const;
144 
150  std::pair<Value,Value> x( int i ) const;
151 
158  std::pair<Value,Value> dx( int i ) const;
159 
166  std::pair<Value,Value> d2x( int i ) const;
167 
174  std::pair<Value,Value> tangent( int i ) const;
175 
183  Value curvature( int i ) const;
184 
185 
186  // ----------------------- Interface --------------------------------------
187  public:
188 
193  void selfDisplay ( std::ostream & out ) const;
194 
199  bool isValid() const;
200 
201  // ------------------------- Protected Datas ------------------------------
202  protected:
203  unsigned int myN;
204  double myH;
211 
213  ConstIteratorOnPoints myBegin;
214 
216  ConstIteratorOnPoints myEnd;
217 
218  // Stores the mapping Iterator => Index.
219  std::map<ConstIteratorOnPoints,int> myMapIt2Idx;
220 
221  // ------------------------- Private Datas --------------------------------
222  private:
223 
224  // ------------------------- Hidden services ------------------------------
225  protected:
226 
227  private:
228 
234  BinomialConvolver ( const BinomialConvolver & other );
235 
243 
244  // ------------------------- Internals ------------------------------------
245  private:
246 
247  }; // end of class BinomialConvolver
248 
258  template <typename TBinomialConvolver, typename TRealPoint>
260  {
261  public:
262  // ----------------------- inner type ------------------------------
263  typedef TRealPoint Value;
264  typedef TRealPoint RealPoint;
265  typedef TBinomialConvolver BinomialConvolver;
266  typedef typename TBinomialConvolver::Value SignalValue;
267  typedef typename TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints;
268 
276  Value operator()( const BinomialConvolver & bc,
277  const ConstIteratorOnPoints & it ) const;
278 
279  };
280 
290  template <typename TBinomialConvolver, typename TReal>
292  {
293  public:
294  // ----------------------- inner type ------------------------------
295  typedef TReal Value;
296  typedef TReal Real;
297  typedef TBinomialConvolver BinomialConvolver;
298  typedef typename TBinomialConvolver::Value SignalValue;
299  typedef typename TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints;
300 
308  Value operator()( const BinomialConvolver & bc,
309  const ConstIteratorOnPoints & it ) const;
310 
311  };
312 
323  template <typename TBinomialConvolver, typename TBinomialConvolverFunctor>
325  {
326  public:
327  typedef TBinomialConvolver BinomialConvolver;
328  typedef TBinomialConvolverFunctor BinomialConvolverFunctor;
330  typedef ConstIteratorOnPoints ConstIterator;
331  typedef typename BinomialConvolverFunctor::Value Value;
332  typedef Value Quantity;
333 
334  BinomialConvolverEstimator( unsigned int n = 0,
335  const BinomialConvolverFunctor & f
337 
345  void init( const double h,
346  const ConstIterator & itb,
347  const ConstIterator & ite,
348  const bool isClosed = true );
349 
353  Quantity eval( const ConstIterator& it );
354 
359  template <typename OutputIterator>
360  OutputIterator eval( const ConstIterator& itb,
361  const ConstIterator& ite,
362  OutputIterator result );
363 
364 
365 
366  private:
367  BinomialConvolver myBC;
368  BinomialConvolverFunctor myFunctor;
369 
370  };
371 
378  template <typename TConstIteratorOnPoints, typename TValue >
379  std::ostream&
380  operator<< ( std::ostream & out,
382 
383 } // namespace DGtal
384 
385 
387 // Includes inline functions.
388 #include "DGtal/geometry/curves/BinomialConvolver.ih"
389 
390 // //
392 
393 #endif // !defined BinomialConvolver_h
394 
395 #undef BinomialConvolver_RECURSES
396 #endif // else defined(BinomialConvolver_RECURSES)
Aim: This class is a functor for getting the tangent vector of a binomial convolver.
TConstIteratorOnPoints ConstIteratorOnPoints
TBinomialConvolverFunctor BinomialConvolverFunctor
BinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints
Value operator()(const BinomialConvolver &bc, const ConstIteratorOnPoints &it) const
ConstIteratorOnPoints myEnd
Copy of the end iterator.
void init(const double h, const ConstIterator &itb, const ConstIterator &ite, const bool isClosed=true)
ConstIteratorOnPoints myBegin
Copy of the begin iterator.
std::pair< Value, Value > dx(int i) const
void init(const double h, const ConstIteratorOnPoints &itb, const ConstIteratorOnPoints &ite, const bool isClosed)
BinomialConvolver & operator=(const BinomialConvolver &other)
Aim: This class is a functor for getting the curvature of a binomial convolver.
std::pair< Value, Value > tangent(int i) const
BinomialConvolver(unsigned int n=1)
std::map< ConstIteratorOnPoints, int > myMapIt2Idx
unsigned int size() const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
ConstIteratorOnPoints::value_type Point
BinomialConvolverEstimator(unsigned int n=0, const BinomialConvolverFunctor &f=BinomialConvolverFunctor())
Value curvature(int i) const
Aim: This class represents a 2D contour convolved by some binomial. It computes first and second orde...
DGtal is the top-level namespace which contains all DGtal functions and types.
Value operator()(const BinomialConvolver &bc, const ConstIteratorOnPoints &it) const
int index(const ConstIteratorOnPoints &it) const
void selfDisplay(std::ostream &out) const
std::pair< Value, Value > x(int i) const
void setSize(unsigned int n)
TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints
Quantity eval(const ConstIterator &it)
std::pair< Value, Value > d2x(int i) const
TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints
BinomialConvolverFunctor::Value Value
BinomialConvolverFunctor myFunctor
Aim: This class encapsulates a BinomialConvolver and a functor on BinomialConvolver so as to be a mod...
static unsigned int suggestedSize(const double h, const ConstIteratorOnPoints &itb, const ConstIteratorOnPoints &ite)