DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
118  {
119  return RealPoint2D(myCenter[0] - myRadius, myCenter[1] - myRadius);
120  }
121 
127  {
128  return RealPoint2D(myCenter[0] + myRadius, myCenter[1] + myRadius);
129  }
130 
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 
179 
183  double myRadius;
184 
185  /*
186  * Number of sides of the ngon.
187  */
188  unsigned int myK;
189 
190  /*
191  * Phase of the ngon (radian).
192  */
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)