DGtal  1.2.0
ImplicitBall.h
1 
17 #pragma once
18 
31 #if defined(ImplicitBall_RECURSES)
32 #error Recursive header files inclusion detected in ImplicitBall.h
33 #else // defined(ImplicitBall_RECURSES)
35 #define ImplicitBall_RECURSES
36 
37 #if !defined ImplicitBall_h
39 #define ImplicitBall_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/kernel/NumberTraits.h"
46 #include "DGtal/shapes/implicit/CImplicitFunction.h"
48 
49 namespace DGtal
50 {
51 
53 
63  template <typename TSpace>
65  {
66 
67  public:
69  typedef TSpace Space;
70  typedef typename Space::RealPoint RealPoint;
71  typedef typename Space::Integer Integer;
72  typedef double Value;
73 
81  ImplicitBall(const RealPoint &aCenter, const double &aRadius): myCenter(aCenter),
82  myRadius(aRadius)
83  {};
84 
90 
91 
92  // ----------------------- Interface --------------------------------------
93  public:
94 
95  inline
97  {
98  return myRadius - (aPoint - myCenter ).norm();
99  }
100 
101  inline
103  {
104  if (this->operator()(aPoint) > 0.0)
105  return INSIDE;
106  else
107  if (this->operator()(aPoint) < 0.0)
108  return OUTSIDE;
109  else
110  return ON;
111  }
112 
113  inline
115  {
117  }
118 
119  inline
121  {
123  }
124 
129  {
130  return myCenter;
131  }
132 
137  inline
138  void moveTo( const RealPoint& newCenter )
139  {
140  myCenter = newCenter;
141  }
142 
143  // ----------------------- Interface --------------------------------------
144  public:
145 
150  void selfDisplay ( std::ostream & out ) const;
151 
156  bool isValid() const;
157 
158  // ------------------------- Protected Datas ------------------------------
159  private:
160  // ------------------------- Private Datas --------------------------------
161  private:
162 
165 
167  double myRadius;
168 
169  // ------------------------- Hidden services ------------------------------
170  protected:
171 
177 
178  private:
179 
187 
188 
189  }; // end of class ImplicitBall
190 
191 
198  template <typename T>
199  std::ostream&
200  operator<< ( std::ostream & out, const ImplicitBall<T> & object );
201 
202 } // namespace DGtal
203 
204 
206 // Includes inline functions.
207 #include "DGtal/shapes/implicit/ImplicitBall.ih"
208 
209 // //
211 
212 #endif // !defined ImplicitBall_h
213 
214 #undef ImplicitBall_RECURSES
215 #endif // else defined(ImplicitBall_RECURSES)
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition: ImplicitBall.h:65
double myRadius
Ball Radius.
Definition: ImplicitBall.h:167
Orientation orientation(const RealPoint &aPoint) const
Definition: ImplicitBall.h:102
Value operator()(const RealPoint &aPoint) const
Definition: ImplicitBall.h:96
ImplicitBall & operator=(const ImplicitBall &other)
RealPoint center() const
Definition: ImplicitBall.h:128
RealPoint getUpperBound() const
Definition: ImplicitBall.h:120
void selfDisplay(std::ostream &out) const
Space::RealPoint RealPoint
Definition: ImplicitBall.h:70
Space::Integer Integer
Definition: ImplicitBall.h:71
void moveTo(const RealPoint &newCenter)
Definition: ImplicitBall.h:138
RealPoint getLowerBound() const
Definition: ImplicitBall.h:114
RealPoint myCenter
Ball center.
Definition: ImplicitBall.h:164
bool isValid() const
ImplicitBall< TSpace > Self
Definition: ImplicitBall.h:68
ImplicitBall(const RealPoint &aCenter, const double &aRadius)
Definition: ImplicitBall.h:81
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
static Self diagonal(Component val=1)
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Definition: SpaceND.h:102
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:142
@ INSIDE
Definition: Common.h:142
@ OUTSIDE
Definition: Common.h:142
@ ON
Definition: Common.h:142
const Point aPoint(3, 4)