DGtal  0.9.2
NGon2D.h
1 
17 #pragma once
18 
33 #if defined(NGon2D_RECURSES)
34 #error Recursive header files inclusion detected in NGon2D.h
35 #else // defined(NGon2D_RECURSES)
36 
37 #define NGon2D_RECURSES
38 
39 #if !defined NGon2D_h
40 
41 #define NGon2D_h
42 
44 // Inclusions
45 #include <iostream>
46 #include "DGtal/base/Common.h"
47 #include "DGtal/shapes/parametric/StarShaped2D.h"
49 
50 namespace DGtal
51 {
52 
54  // template class NGon2D
62  template <typename TSpace>
63  class NGon2D: public StarShaped2D<TSpace>
64  {
65  // ----------------------- Standard services ------------------------------
66  public:
67 
68  typedef TSpace Space;
69  typedef typename Space::Point Point;
70  typedef typename Space::RealPoint RealPoint2D;
71  typedef typename Space::RealVector RealVector2D;
72 
76  ~NGon2D();
77 
86  NGon2D( const double x0, const double y0, const double r ,
87  const unsigned int k, const double phi );
88 
96  NGon2D(const RealPoint2D &aPoint, const double r,
97  const unsigned int k, const double phi);
98 
106  NGon2D(const Point &aPoint, const double r,
107  const unsigned int k, const double phi);
108 
109 
110  // ------------- Implementation of 'StarShaped' services ------------------
111  public:
112 
117  RealPoint2D getLowerBound() const
118  {
119  return RealPoint2D(myCenter[0] - myRadius, myCenter[1] - myRadius);
120  }
121 
126  RealPoint2D getUpperBound() const
127  {
128  return RealPoint2D(myCenter[0] + myRadius, myCenter[1] + myRadius);
129  }
130 
134  RealPoint2D center() const
135  {
136  return myCenter;
137  }
138 
145  double parameter( const RealPoint2D & p ) const;
146 
147 
154  RealPoint2D x( const double t ) const;
155 
162  RealVector2D xp( const double t ) const;
163 
169  RealVector2D xpp( const double t ) const;
170 
171 
172  // ------------------------- data ----------------------------
173  private:
174 
178  RealPoint2D myCenter;
179 
183  double myRadius;
184 
188  unsigned int myK;
189 
193  double myPhi;
194 
195 
196 
197  // ----------------------- Interface --------------------------------------
198  public:
199 
204  void selfDisplay ( std::ostream & out ) const;
205 
210  bool isValid() const;
211 
212 
213  // ------------------------- Hidden services ------------------------------
214  protected:
215 
220  NGon2D();
221 
222  private:
223 
229  // NGon2D ( const NGon2D & other );
230 
237  NGon2D & operator= ( const NGon2D & other );
238 
239  // ------------------------- Internals ------------------------------------
240  private:
241 
242  }; // end of class NGon2D
243 
244 
251  template <typename T>
252  std::ostream&
253  operator<< ( std::ostream & out, const NGon2D<T> & object );
254 
255 } // namespace DGtal
256 
257 
259 // Includes inline functions.
260 #include "DGtal/shapes/parametric/NGon2D.ih"
261 
262 // //
264 
265 #endif // !defined NGon2D_h
266 
267 #undef NGon2D_RECURSES
268 #endif // else defined(NGon2D_RECURSES)
RealPoint2D myCenter
Definition: NGon2D.h:178
double myPhi
Definition: NGon2D.h:193
double parameter(const RealPoint2D &p) const
NGon2D & operator=(const NGon2D &other)
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
void selfDisplay(std::ostream &out) const
Aim: Model of the concept StarShaped represents any regular k-gon in the plane.
Definition: NGon2D.h:63
RealVector2D xpp(const double t) const
double myRadius
Definition: NGon2D.h:183
RealVector2D xp(const double t) const
Space::Point Point
Definition: NGon2D.h:69
bool isValid() const
DGtal is the top-level namespace which contains all DGtal functions and types.
RealPoint2D center() const
Definition: NGon2D.h:134
unsigned int myK
Definition: NGon2D.h:188
Space::RealVector RealVector2D
Definition: NGon2D.h:71
TSpace Space
Definition: NGon2D.h:68
Space::RealPoint RealPoint2D
Definition: NGon2D.h:70
RealPoint2D x(const double t) const
RealPoint2D getLowerBound() const
Definition: NGon2D.h:117
RealPoint2D getUpperBound() const
Definition: NGon2D.h:126