DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ParametricShapeArcLengthFunctor.h
1 
17 #pragma once
18 
34 #if defined(ParametricShapeArcLengthFunctor_RECURSES)
35 #error Recursive header files inclusion detected in ParametricShapeArcLengthFunctor.h
36 #else // defined(ParametricShapeArcLengthFunctor_RECURSES)
37 
38 #define ParametricShapeArcLengthFunctor_RECURSES
39 
40 #if !defined ParametricShapeArcLengthFunctor_h
41 
42 #define ParametricShapeArcLengthFunctor_h
43 
45 // Inclusions
46 #include <iostream>
47 #include "DGtal/base/Common.h"
49 
50 namespace DGtal
51 {
52 
54  // template class ParametricShapeArcLengthFunctor
63  template <typename TParametricShape>
65  {
66 
67  // ----------------------- Standard services ------------------------------
68  public:
69 
71  typedef TParametricShape ParametricShape;
72 
74  typedef typename TParametricShape::RealPoint RealPoint;
75  typedef typename TParametricShape::Point Point;
76  typedef typename TParametricShape::Point Vector;
77  typedef typename Point::Coordinate Integer;
78 
80  typedef double Quantity;
81 
87 
88 
94 
95 
100 
101 
102  // ----------------------- Interface --------------------------------------
103  public:
104 
112  {
113  myShape = other.myShape;
114  return *this;
115  }
116 
117 
125  Quantity operator()(const RealPoint &aFirstPoint,const RealPoint &aSecondPoint)
126  {
127 
128  ASSERT(myShape);
129 
130  //determining nbSamples from the bounding box size of the shape
131  Vector v = myShape->getUpperBound() - myShape->getLowerBound();
132  double n = (double) NumberTraits<Integer>::castToInt64_t( (const DGtal::int32_t)v.norm(Vector::L_infty) );
133  unsigned int nbSamples = (unsigned int) ceil( n*100 );
134 
135  //computes the angles
136  double t = myShape->parameter( aFirstPoint );
137  double t2 = myShape->parameter( aSecondPoint );
138  return myShape->arclength (t,t2,nbSamples);
139 
140  }
141 
148  {
149 
150  ASSERT(myShape);
151 
152  //determining nbSamples from the bounding box size of the shape
153  Vector v = myShape->getUpperBound() - myShape->getLowerBound();
154  double n = (double) NumberTraits<Integer>::castToInt64_t( (const DGtal::int32_t)v.norm(Vector::L_infty) );
155  unsigned int nbSamples = (unsigned int) ceil( n*100 );
156 
157  return myShape->arclength (0,2*M_PI,nbSamples);
158  }
159 
160  // ------------------------- Private Datas --------------------------------
161  private:
162 
165 
166  // ------------------------- Internals ------------------------------------
167  private:
168 
169  }; // end of class ParametricShapeArcLengthFunctor
170 
171 } // namespace DGtal
172 
173  //
175 
176 #endif // !defined ParametricShapeArcLengthFunctor_h
177 
178 #undef ParametricShapeArcLengthFunctor_RECURSES
179 #endif // else defined(ParametricShapeArcLengthFunctor_RECURSES)