DGtal  1.5.beta
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)
35 #define BinomialConvolver_RECURSES
36 
37 #if !defined BinomialConvolver_h
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 
214 
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 
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;
267  typedef typename TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints;
268 
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;
299  typedef typename TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints;
300 
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;
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 
354 
359  template <typename OutputIterator>
360  OutputIterator eval( const ConstIterator& itb,
361  const ConstIterator& ite,
362  OutputIterator result );
363 
364 
365 
366  private:
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 encapsulates a BinomialConvolver and a functor on BinomialConvolver so as to be a mod...
BinomialConvolverEstimator(unsigned int n=0, const BinomialConvolverFunctor &f=BinomialConvolverFunctor())
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite, const bool isClosed=true)
BinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints
TBinomialConvolverFunctor BinomialConvolverFunctor
BinomialConvolverFunctor::Value Value
Quantity eval(const ConstIterator &it)
BinomialConvolverFunctor myFunctor
Aim: This class represents a 2D contour convolved by some binomial. It computes first and second orde...
ConstIteratorOnPoints::value_type Point
BinomialConvolver & operator=(const BinomialConvolver &other)
std::pair< Value, Value > dx(int i) const
static unsigned int suggestedSize(const double h, const ConstIteratorOnPoints &itb, const ConstIteratorOnPoints &ite)
void init(const double h, const ConstIteratorOnPoints &itb, const ConstIteratorOnPoints &ite, const bool isClosed)
std::pair< Value, Value > x(int i) const
BinomialConvolver(const BinomialConvolver &other)
ConstIteratorOnPoints myBegin
Copy of the begin iterator.
BinomialConvolver(unsigned int n=1)
void selfDisplay(std::ostream &out) const
ConstIteratorOnPoints myEnd
Copy of the end iterator.
std::pair< Value, Value > d2x(int i) const
Value curvature(int i) const
void setSize(unsigned int n)
int index(const ConstIteratorOnPoints &it) const
std::map< ConstIteratorOnPoints, int > myMapIt2Idx
unsigned int size() const
std::pair< Value, Value > tangent(int i) const
TConstIteratorOnPoints ConstIteratorOnPoints
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Aim: This class is a functor for getting the curvature of a binomial convolver.
Value operator()(const BinomialConvolver &bc, const ConstIteratorOnPoints &it) const
TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints
Aim: This class is a functor for getting the tangent vector of a binomial convolver.
Value operator()(const BinomialConvolver &bc, const ConstIteratorOnPoints &it) const
TBinomialConvolver::ConstIteratorOnPoints ConstIteratorOnPoints