DGtal  1.1.0
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)
34 
35 #define Point2ScalarFunctors_RECURSES
36 
37 #if !defined Point2ScalarFunctors_h
38 
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)
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
DGtal::functors::HatPointFunction::Point
TPoint Point
Definition: Point2ScalarFunctors.h:56
DGtal::functors::BallConstantPointFunction::myR2
Scalar myR2
Definition: Point2ScalarFunctors.h:92
DGtal::functors::BallConstantPointFunction::myV0
Scalar myV0
Definition: Point2ScalarFunctors.h:91
DGtal::functors::HatPointFunction::myV0OverR
Scalar myV0OverR
Definition: Point2ScalarFunctors.h:62
DGtal::functors::HatPointFunction::operator()
Scalar operator()(const Point &p) const
Definition: Point2ScalarFunctors.h:69
DGtal::functors::HatPointFunction::argument_type
Point argument_type
Definition: Point2ScalarFunctors.h:58
DGtal::functors::BallConstantPointFunction::BallConstantPointFunction
BallConstantPointFunction(Scalar v0, Scalar r)
Definition: Point2ScalarFunctors.h:95
DGtal::functors::BallConstantPointFunction::operator()
Scalar operator()(const Point &p) const
Definition: Point2ScalarFunctors.h:97
DGtal::functors::HatPointFunction::value_type
Scalar value_type
Definition: Point2ScalarFunctors.h:59
DGtal::functors::BallConstantPointFunction::value_type
Scalar value_type
Definition: Point2ScalarFunctors.h:89
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::functions::square
T square(T x)
Definition: BasicMathFunctions.h:133
DGtal::functors::BallConstantPointFunction::Point
TPoint Point
Definition: Point2ScalarFunctors.h:86
DGtal::functors::BallConstantPointFunction::Scalar
TScalar Scalar
Definition: Point2ScalarFunctors.h:87
DGtal::functors::HatPointFunction::Scalar
TScalar Scalar
Definition: Point2ScalarFunctors.h:57
DGtal::functors::HatPointFunction
Definition: Point2ScalarFunctors.h:55
DGtal::functors::HatPointFunction::myR2
Scalar myR2
Definition: Point2ScalarFunctors.h:64
DGtal::functors::HatPointFunction::myR
Scalar myR
Definition: Point2ScalarFunctors.h:63
DGtal::functors::BallConstantPointFunction::argument_type
Point argument_type
Definition: Point2ScalarFunctors.h:88
DGtal::functors::BallConstantPointFunction
Definition: Point2ScalarFunctors.h:85
DGtal::functors::HatPointFunction::HatPointFunction
HatPointFunction(Scalar v0, Scalar r)
Definition: Point2ScalarFunctors.h:67
DGtal::functors::HatPointFunction::myV0
Scalar myV0
Definition: Point2ScalarFunctors.h:61