DGtal  1.2.0
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)
35 #define ShapeGeometricFunctors_RECURSES
36
37 #if !defined ShapeGeometricFunctors_h
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;
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;
119  typedef typename RealVector::Component Scalar;
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;
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
220  template <typename TShape>
222  typedef TShape Shape;
223  typedef typename Shape::RealPoint RealPoint;
224  typedef typename Shape::RealVector RealVector;
225  typedef typename RealVector::Component Scalar;
227  typedef Scalar Quantity;
228  typedef Quantity Value;
229
237
244  void attach( ConstAlias<Shape> aShape )
245  {
246  myShape = aShape;
247  }
248
254  Quantity operator()( const RealPoint & p ) const
255  {
256  return myShape->gaussianCurvature( p );
257  }
258
259  private:
262  };
263
272  template <typename TShape>
274  typedef TShape Shape;
275  typedef typename Shape::RealPoint RealPoint;
276  typedef typename Shape::RealVector RealVector;
277  typedef typename RealVector::Component Scalar;
279  typedef Scalar Quantity;
280  typedef Quantity Value;
281
289  : myShape( aShape ) {}
290
297  void attach( ConstAlias<Shape> aShape )
298  {
299  myShape = aShape;
300  }
301
307  Quantity operator()( const RealPoint & p ) const
308  {
309  Quantity k1, k2;
310  myShape->principalCurvatures( p, k1, k2 );
311  return k1;
312  }
313
314  private:
317  }; // struct ShapeFirstPrincipalCurvatureFunctor
318
327  template <typename TShape>
329  typedef TShape Shape;
330  typedef typename Shape::RealPoint RealPoint;
331  typedef typename Shape::RealVector RealVector;
332  typedef typename RealVector::Component Scalar;
334  typedef Scalar Quantity;
335  typedef Quantity Value;
336
344  : myShape( aShape ) {}
345
352  void attach( ConstAlias<Shape> aShape )
353  {
354  myShape = aShape;
355  }
356
362  Quantity operator()( const RealPoint & p ) const
363  {
364  Quantity k1, k2;
365  myShape->principalCurvatures( p, k1, k2 );
366  return k2;
367  }
368
369  private:
372  }; // struct ShapeSecondPrincipalCurvatureFunctor
373
384  template <typename TShape>
386  typedef TShape Shape;
387  typedef typename Shape::RealPoint RealPoint;
388  typedef typename Shape::RealVector RealVector;
389  typedef typename RealVector::Component Scalar;
392  typedef Quantity Value;
393
401  : myShape( aShape ) {}
402
409  void attach( ConstAlias<Shape> aShape )
410  {
411  myShape = aShape;
412  }
413
419  Quantity operator()( const RealPoint & p ) const
420  {
421  Quantity d1, d2;
422  myShape->principalDirections( p, d1, d2 );
423  return d1;
424  }
425
426  private:
429  }; // struct ShapeFirstPrincipalDirectionFunctor
430
441  template <typename TShape>
443  typedef TShape Shape;
444  typedef typename Shape::RealPoint RealPoint;
445  typedef typename Shape::RealVector RealVector;
446  typedef typename RealVector::Component Scalar;
449  typedef Quantity Value;
450
458  : myShape( aShape ) {}
459
466  void attach( ConstAlias<Shape> aShape )
467  {
468  myShape = aShape;
469  }
470
476  Quantity operator()( const RealPoint & p ) const
477  {
478  Quantity d1, d2;
479  myShape->principalDirections( p, d1, d2 );
480  return d2;
481  }
482
483  private:
486  }; // struct ShapeSecondPrincipalDirectionFunctor
487
498  template <typename TShape>
500  typedef TShape Shape;
501  typedef typename Shape::RealPoint RealPoint;
502  typedef typename Shape::RealVector RealVector;
503  typedef typename RealVector::Component Scalar;
505  typedef std::tuple<Scalar,Scalar,RealVector,RealVector> Quantity;
506  typedef Quantity Value;
507
515  : myShape( aShape ) {}
516
523  void attach( ConstAlias<Shape> aShape )
524  {
525  myShape = aShape;
526  }
527
536  Quantity operator()( const RealPoint & p ) const
537  {
538  Scalar k1, k2;
539  RealVector d1, d2;
540  myShape->principalCurvatures( p, k1, k2 );
541  myShape->principalDirections( p, d1, d2 );
542  return std::make_tuple( k1, k2, d1, d2 );
543  }
544
545  private:
548  }; // struct ShapePrincipalCurvaturesAndDirectionsFunctor
549
550
551  } // namespace ShapeGeometricFunctors
552  } // namespace functors
553 } // namespace DGtal
554
555
557 // Includes inline functions.
558 #include "DGtal/shapes/ShapeGeometricFunctors.ih"
559
560 // //
562
563 #endif // !defined ShapeGeometricFunctors_h
564
565 #undef ShapeGeometricFunctors_RECURSES
566 #endif // else defined(ShapeGeometricFunctors_RECURSES)
Space::RealPoint RealPoint
Definition: Astroid2D.h:67
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
TEuclideanRing Component
Type for Vector elements.
Definition: PointVector.h:614
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A functor RealPoint -> Quantity that returns the first principal curvature at given point (i....
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> RealVector that returns the first principal direction at given point (i....
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> Quantity that returns the gaussian curvature at given point.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> Quantity that returns the mean curvature at given point.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> Quantity that returns the normal vector at given point.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> Quantity that returns the position of the point itself.
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> (Scalar,Scalar,RealVector,RealVector that returns the principal curvature...
Aim: A functor RealPoint -> Quantity that returns the second principal curvature at given point (i....
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.
Aim: A functor RealPoint -> RealVector that returns the second principal direction at given point (i....
CountedConstPtrOrConstPtr< Shape > myShape
The shape of interest.