DGtal  1.5.beta
Point2ScalarFunctors.h
1 
17 #pragma once
18 
31 #if defined(Point2ScalarFunctors_RECURSES)
32 #error Recursive header files inclusion detected in Point2ScalarFunctors.h
33 #else // defined(Point2ScalarFunctors_RECURSES)
35 #define Point2ScalarFunctors_RECURSES
36 
37 #if !defined Point2ScalarFunctors_h
39 #define Point2ScalarFunctors_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal {
48  namespace functors {
49 
54  template <typename TPoint, typename TScalar>
56  typedef TPoint Point;
57  typedef TScalar Scalar;
59  typedef Scalar value_type;
60 
65 
66  public:
68  : myV0( v0 ), myV0OverR( v0 / r ), myR( r ), myR2( r*r ) {}
69  Scalar operator()( const Point& p ) const
70  {
71  Scalar d = 0;
72  for ( typename Point::ConstIterator it = p.begin(), itE = p.end(); it != itE; ++it )
73  d += functions::square( (Scalar) *it );
74  if ( d >= myR2 ) return 0.0;
75  d = sqrt( d );
76  return myV0 - myV0OverR * d;
77  }
78  };
79 
84  template <typename TPoint, typename TScalar>
86  typedef TPoint Point;
87  typedef TScalar Scalar;
89  typedef Scalar value_type;
90 
93 
94  public:
96  : myV0( v0 ), myR2( r*r ) {}
97  Scalar operator()( const Point& p ) const
98  {
99  Scalar d = 0;
100  for ( typename Point::ConstIterator it = p.begin(), itE = p.end(); it != itE; ++it )
101  d += functions::square( (Scalar) *it );
102  return ( d > myR2 ) ? 0.0 : myV0;
103  }
104  };
105 
106  } // namespace functors
107 } // namespace DGtal
108 
109 
111 // Includes inline functions.
112 #include "DGtal/kernel/Point2ScalarFunctors.ih"
113 
114 // //
116 
117 #endif // !defined Point2ScalarFunctors_h
118 
119 #undef Point2ScalarFunctors_RECURSES
120 #endif // else defined(Point2ScalarFunctors_RECURSES)
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Scalar operator()(const Point &p) const