DGtal 1.4.0
Loading...
Searching...
No Matches
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)
37#define StarShaped2D_RECURSES
38
39#if !defined StarShaped2D_h
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
51namespace 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
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)
PointVector< dim, double > RealPoint
Definition SpaceND.h:117
RealPoint closestPointWithWitnesses(const RealPoint &p, const RealPoint &left, const RealPoint &right, const int step) const
RealPoint tangent(const double t) const
virtual RealPoint interiorPoint() const
RealPoint findIntersection(const RealPoint &inner, const RealPoint &outer, const double epsilon) const
virtual ~StarShaped2D()=default
bool isValid() const
virtual void moveTo(const RealPoint &newCenter)=0
Space::RealPoint RealPoint
Orientation orientation(const RealPoint &p) const
RealPoint normal(const double t) const
StarShaped2D(const StarShaped2D &other)=delete
bool isAlmostEqual(T x, T y) const
virtual RealPoint getUpperBound() const =0
virtual double parameter(const RealPoint &p) const =0
void selfDisplay(std::ostream &out) const
virtual RealPoint x(const double t) const =0
virtual RealPoint xpp(const double t) const =0
virtual RealPoint getLowerBound() const =0
StarShaped2D()=default
virtual RealPoint center() const =0
StarShaped2D & operator=(const StarShaped2D &other)=delete
double arclength(const double t1, double t2, const unsigned int nb) const
virtual RealPoint xp(const double t) const =0
double curvature(const double t) const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Orientation
Definition Common.h:141