DGtal  0.9.2
ShapeGeometricFunctors.h
1 
17 #pragma once
18 
31 #if defined(ShapeGeometricFunctors_RECURSES)
32 #error Recursive header files inclusion detected in ShapeGeometricFunctors.h
33 #else // defined(ShapeGeometricFunctors_RECURSES)
34 
35 #define ShapeGeometricFunctors_RECURSES
36 
37 #if !defined ShapeGeometricFunctors_h
38 
39 #define ShapeGeometricFunctors_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal
48 {
49  namespace functors
50  {
51 
52  namespace ShapeGeometricFunctors
53  {
54 
63  template <typename TShape>
65  typedef TShape Shape;
66  typedef typename Shape::RealPoint RealPoint;
67  typedef RealPoint Argument;
68  typedef RealPoint Quantity;
69  typedef Quantity Value;
70 
77  ShapePositionFunctor( ConstAlias<Shape> aShape = 0 ) : myShape( aShape ) {}
78 
85  void attach( ConstAlias<Shape> aShape )
86  {
87  myShape = aShape;
88  }
89 
95  Quantity operator()( const RealPoint & p ) const
96  {
97  return p;
98  }
99 
100  private:
103  };
104 
113  template <typename TShape>
115  typedef TShape Shape;
116  typedef typename Shape::RealPoint RealPoint;
117  typedef typename Shape::RealVector RealVector;
118  typedef RealPoint Argument;
119  typedef typename RealVector::Component Scalar;
120  typedef RealVector Quantity;
121  typedef Quantity Value;
122 
130 
137  void attach( ConstAlias<Shape> aShape )
138  {
139  myShape = aShape;
140  }
141 
147  Quantity operator()( const RealPoint & p ) const
148  {
149  RealVector v = myShape->gradient( p );
150  Scalar norm = v.norm();
151  return ( norm != 0 ) ? v / norm : v;
152  }
153 
154  private:
157  };
158 
159 
168  template <typename TShape>
170  typedef TShape Shape;
171  typedef typename Shape::RealPoint RealPoint;
172  typedef typename Shape::RealVector RealVector;
173  typedef typename RealVector::Component Scalar;
174  typedef RealPoint Argument;
175  typedef Scalar Quantity;
176  typedef Quantity Value;
177 
185 
192  void attach( ConstAlias<Shape> aShape )
193  {
194  myShape = aShape;
195  }
196 
202  Quantity operator()( const RealPoint & p ) const
203  {
204  return myShape->meanCurvature( p );
205  }
206 
207  private:
210  };
211 
212  } // namespace ShapeGeometricFunctors
213  }
214 } // namespace DGtal
215 
216 
218 // Includes inline functions.
219 #include "DGtal/shapes/ShapeGeometricFunctors.ih"
220 
221 // //
223 
224 #endif // !defined ShapeGeometricFunctors_h
225 
226 #undef ShapeGeometricFunctors_RECURSES
227 #endif // else defined(ShapeGeometricFunctors_RECURSES)
Aim: A functor RealPoint -> Quantity that returns the position of the point itself.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
Aim: A functor RealPoint -> Quantity that returns the mean curvature at given point.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> Quantity that returns the normal vector at given point.
DGtal is the top-level namespace which contains all DGtal functions and types.