DGtal  0.9.2
Ball3D.h
1 
17 #pragma once
18 
31 #if defined(Ball3D_RECURSES)
32 #error Recursive header files inclusion detected in Ball3D.h
33 #else // defined(Ball3D_RECURSES)
34 
35 #define Ball3D_RECURSES
36 
37 #if !defined Ball3D_h
38 
39 #define Ball3D_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "StarShaped3D.h"
47 
48 namespace DGtal
49 {
50 
52  // template class Ball3D
59  template <typename TSpace>
60  class Ball3D: public StarShaped3D<TSpace>
61  {
62  // ----------------------- Standard services ------------------------------
63  public:
64 
65  typedef TSpace Space;
66  typedef typename Space::RealPoint RealPoint;
67  typedef std::pair<double,double> AngularCoordinates;
68 
72  ~Ball3D();
73 
81  Ball3D( const double x0, const double y0, const double z0, const double r );
82 
88  Ball3D(const RealPoint &aPoint, const double r);
89 
90 
91  /*
92  * Constructor.
93  * @param aPoint the sphere center.
94  * @param r the radius of the sphere.
95  */
96  /*
97  Ball3D(const Point &aPoint, const double r);
98  */
99 
100  // ------------- Implementation of 'StarShaped' services ------------------
101  public:
102 
107  RealPoint getLowerBound() const
108  {
109 
110  return RealPoint(myCenter[0] - myRadius,
111  myCenter[1] - myRadius ,
112  myCenter[2] - myRadius );
113  }
114 
119  RealPoint getUpperBound() const
120  {
121  return RealPoint(myCenter[0] + myRadius ,
122  myCenter[1] + myRadius,
123  myCenter[2] + myRadius);
124  }
125 
129  RealPoint center() const
130  {
131  return myCenter;
132  }
133 
141  AngularCoordinates parameter( const RealPoint & p ) const;
142 
143 
144 
151  RealPoint x( const AngularCoordinates t ) const;
152 
153 
154 
155 
161  virtual RealPoint gradient( const AngularCoordinates t) const ;
162 
163 
164 
170  virtual RealPoint rt( const AngularCoordinates t) const ;
171 
172 
173 
179  virtual RealPoint rp( const AngularCoordinates t) const ;
180 
181 
187  virtual RealPoint rtt( const AngularCoordinates t) const ;
188 
189 
190 
196  virtual RealPoint rpp( const AngularCoordinates t) const ;
197 
198 
204  virtual RealPoint rtp( const AngularCoordinates t) const ;
205 
206 
207 
208 
209  // ------------------------- data ----------------------------
210  private:
211 
215  double myRadius;
216 
220  RealPoint myCenter;
221 
222 
223  // ----------------------- Interface --------------------------------------
224  public:
225 
230  void selfDisplay ( std::ostream & out ) const;
231 
236  bool isValid() const;
237 
238 
239  // ------------------------- Hidden services ------------------------------
240  protected:
241 
246  Ball3D();
247 
248  private:
249 
255  // Ball3D ( const Ball3D & other );
256 
263  Ball3D & operator= ( const Ball3D & other );
264 
265  // ------------------------- Internals ------------------------------------
266  private:
267 
268  }; // end of class Ball3D
269 
270 
277  template <typename T>
278  std::ostream&
279  operator<< ( std::ostream & out, const Ball3D<T> & object );
280 
281 } // namespace DGtal
282 
283 
285 // Includes inline functions.
286 #include "Ball3D.ih"
287 
288 // //
290 
291 #endif // !defined Ball3D_h
292 
293 #undef Ball3D_RECURSES
294 #endif // else defined(Ball3D_RECURSES)
TSpace Space
Definition: Ball3D.h:65
bool isValid() const
void selfDisplay(std::ostream &out) const
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
virtual RealPoint rt(const AngularCoordinates t) const
virtual RealPoint rtt(const AngularCoordinates t) const
std::pair< double, double > AngularCoordinates
Definition: Ball3D.h:67
AngularCoordinates parameter(const RealPoint &p) const
RealPoint center() const
Definition: Ball3D.h:129
virtual RealPoint rpp(const AngularCoordinates t) const
double myRadius
Definition: Ball3D.h:215
RealPoint myCenter
Definition: Ball3D.h:220
RealPoint getLowerBound() const
Definition: Ball3D.h:107
DGtal is the top-level namespace which contains all DGtal functions and types.
virtual RealPoint gradient(const AngularCoordinates t) const
Ball3D & operator=(const Ball3D &other)
RealPoint getUpperBound() const
Definition: Ball3D.h:119
Space::RealPoint RealPoint
Definition: Ball3D.h:66
virtual RealPoint rtp(const AngularCoordinates t) const
virtual RealPoint rp(const AngularCoordinates t) const
RealPoint x(const AngularCoordinates t) const
Aim: Model of the concept StarShaped3D represents any Sphere in the space.
Definition: Ball3D.h:60