DGtal  1.3.beta
StarShaped2D.h
1 
17 #pragma once
18 
33 #if defined(StarShaped2D_RECURSES)
34 #error Recursive header files inclusion detected in StarShaped2D.h
35 #else // defined(StarShaped2D_RECURSES)
36 
37 #define StarShaped2D_RECURSES
38 
39 #if !defined StarShaped2D_h
40 
41 #define StarShaped2D_h
42 
44 // Inclusions
45 #include <iostream>
46 #include <vector>
47 #include "DGtal/base/Common.h"
48 #include "DGtal/kernel/NumberTraits.h"
50 
51 namespace DGtal
52 {
53 
55  // template class StarShaped2D
73  template <typename TSpace>
75  {
76 
77  public:
78  typedef TSpace Space;
79  typedef typename Space::RealPoint RealPoint;
80 
84  StarShaped2D() = default;
85 
91  StarShaped2D ( const StarShaped2D & other ) = delete;
92 
99  StarShaped2D & operator= ( const StarShaped2D & other ) = delete;
100 
104  virtual ~StarShaped2D() = default;
105 
106  // ------------------------- Implemented services -------------------------
107  public:
111  virtual RealPoint interiorPoint() const
112  {
113  return center();
114  }
115 
116  // ------------------------- Abstract services ----------------------------
117  public:
118 
123  virtual RealPoint getLowerBound() const = 0;
124 
129  virtual RealPoint getUpperBound() const = 0;
130 
131 
135  virtual RealPoint center() const = 0;
136 
141  virtual void moveTo( const RealPoint& newCenter ) = 0;
142 
149  virtual double parameter( const RealPoint & p ) const = 0;
150 
157  virtual RealPoint x( const double t ) const = 0;
158 
165  virtual RealPoint xp( const double t ) const = 0;
166 
172  virtual RealPoint xpp( const double t ) const = 0;
173 
174 
175  // ------------------------- star-shaped services -------------------------
176  public:
177 
185  Orientation orientation( const RealPoint &p) const;
186 
193  RealPoint tangent( const double t ) const;
194 
201  RealPoint normal( const double t ) const;
202 
210  double curvature( const double t ) const;
211 
219  double arclength( const double t1, double t2, const unsigned int nb ) const;
220 
230  RealPoint findIntersection( const RealPoint& inner, const RealPoint& outer, const double epsilon ) const;
231 
242  RealPoint closestPointWithWitnesses( const RealPoint& p, const RealPoint& left, const RealPoint& right, const int step) const;
243 
244  // ----------------------- Interface --------------------------------------
245  public:
246 
251  void selfDisplay ( std::ostream & out ) const;
252 
257  bool isValid() const;
258 
259  // ------------------------- Hidden services ------------------------------
260  private:
261 
265  template <typename T>
266  inline
267  bool isAlmostEqual( T x, T y ) const
268  {
269  return std::abs(x - y) <= std::numeric_limits<T>::epsilon();
270  }
271 
272  }; // end of class StarShaped2D
273 
274 
281  template <typename T>
282  std::ostream&
283  operator<< ( std::ostream & out, const StarShaped2D<T> & object );
284 
285 } // namespace DGtal
286 
287 
289 // Includes inline functions.
290 #include "DGtal/shapes/parametric/StarShaped2D.ih"
291 
292 // //
294 
295 #endif // !defined StarShaped2D_h
296 
297 #undef StarShaped2D_RECURSES
298 #endif // else defined(StarShaped2D_RECURSES)
DGtal::StarShaped2D::curvature
double curvature(const double t) const
DGtal::StarShaped2D::x
virtual RealPoint x(const double t) const =0
DGtal::StarShaped2D::operator=
StarShaped2D & operator=(const StarShaped2D &other)=delete
DGtal::StarShaped2D::normal
RealPoint normal(const double t) const
DGtal::StarShaped2D
Definition: StarShaped2D.h:74
DGtal::StarShaped2D::findIntersection
RealPoint findIntersection(const RealPoint &inner, const RealPoint &outer, const double epsilon) const
DGtal::StarShaped2D::center
virtual RealPoint center() const =0
DGtal::StarShaped2D::orientation
Orientation orientation(const RealPoint &p) const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::Orientation
Orientation
Definition: Common.h:142
DGtal::StarShaped2D::getLowerBound
virtual RealPoint getLowerBound() const =0
DGtal::StarShaped2D::getUpperBound
virtual RealPoint getUpperBound() const =0
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::StarShaped2D::interiorPoint
virtual RealPoint interiorPoint() const
Definition: StarShaped2D.h:111
DGtal::StarShaped2D::tangent
RealPoint tangent(const double t) const
DGtal::StarShaped2D::Space
TSpace Space
Definition: StarShaped2D.h:78
DGtal::StarShaped2D::arclength
double arclength(const double t1, double t2, const unsigned int nb) const
DGtal::StarShaped2D::closestPointWithWitnesses
RealPoint closestPointWithWitnesses(const RealPoint &p, const RealPoint &left, const RealPoint &right, const int step) const
DGtal::StarShaped2D::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::StarShaped2D::isValid
bool isValid() const
DGtal::StarShaped2D::StarShaped2D
StarShaped2D()=default
DGtal::StarShaped2D::~StarShaped2D
virtual ~StarShaped2D()=default
DGtal::SpaceND::RealPoint
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
DGtal::StarShaped2D::xp
virtual RealPoint xp(const double t) const =0
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::StarShaped2D::isAlmostEqual
bool isAlmostEqual(T x, T y) const
Definition: StarShaped2D.h:267
DGtal::StarShaped2D::moveTo
virtual void moveTo(const RealPoint &newCenter)=0
DGtal::StarShaped2D::xpp
virtual RealPoint xpp(const double t) const =0
DGtal::StarShaped2D::parameter
virtual double parameter(const RealPoint &p) const =0
DGtal::StarShaped2D::RealPoint
Space::RealPoint RealPoint
Definition: StarShaped2D.h:79