DGtal  1.5.beta
ImplicitHyperCube.h
1 
17 #pragma once
18 
31 #if defined(ImplicitHyperCube_RECURSES)
32 #error Recursive header files inclusion detected in ImplicitHyperCube.h
33 #else // defined(ImplicitHyperCube_RECURSES)
35 #define ImplicitHyperCube_RECURSES
36 
37 #if !defined ImplicitHyperCube_h
39 #define ImplicitHyperCube_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal
48 {
49 
51 
58  template <typename TSpace>
60  {
61 
62  public:
64  typedef TSpace Space;
65  typedef typename Space::RealPoint RealPoint;
66  typedef double Value;
67 
75  ImplicitHyperCube(const RealPoint &aCenter, const double &aHalfWidth):
76  myCenter(aCenter),
77  myHalfWidth(aHalfWidth)
78  {};
79 
85 
86 
87  // ----------------------- Interface --------------------------------------
88  public:
89 
98  inline
99  double operator()(const RealPoint &aPoint) const
100  {
101  return myHalfWidth - (aPoint - myCenter ).norm(RealPoint::L_infty);
102  }
103 
104 
111  inline
112  bool isInside(const RealPoint &aPoint) const
113  {
114  return this->operator()(aPoint) >0.0;
115  }
116 
117 
118  inline
120  {
121  if (this->operator()(aPoint) > 0.0)
122  return INSIDE;
123  else
124  if (this->operator()(aPoint) < 0.0)
125  return OUTSIDE;
126  else
127  return ON;
128  }
129 
136  inline
138  {
140  }
141 
148  inline
150  {
152  }
153 
158  {
159  return myCenter;
160  }
161 
166  inline
167  void moveTo( const RealPoint& newCenter )
168  {
169  myCenter = newCenter;
170  }
171 
172  // ----------------------- Interface --------------------------------------
173  public:
174 
179  void selfDisplay ( std::ostream & out ) const;
180 
185  bool isValid() const;
186 
187  // ------------------------- Protected Datas ------------------------------
188  private:
189  // ------------------------- Private Datas --------------------------------
190  private:
191 
194 
196  double myHalfWidth;
197 
198  // ------------------------- Hidden services ------------------------------
199  protected:
200 
206 
207  private:
208 
216 
217 
218  }; // end of class ImplicitHyperCube
219 
220 
227  template <typename T>
228  std::ostream&
229  operator<< ( std::ostream & out, const ImplicitHyperCube<T> & object );
230 
231 } // namespace DGtal
232 
233 
235 // Includes inline functions.
236 #include "DGtal/shapes/implicit/ImplicitHyperCube.ih"
237 
238 // //
240 
241 #endif // !defined ImplicitHyperCube_h
242 
243 #undef ImplicitHyperCube_RECURSES
244 #endif // else defined(ImplicitHyperCube_RECURSES)
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
void selfDisplay(std::ostream &out) const
Orientation orientation(const RealPoint &aPoint) const
ImplicitHyperCube< TSpace > Self
ImplicitHyperCube(const RealPoint &aCenter, const double &aHalfWidth)
RealPoint getLowerBound() const
void moveTo(const RealPoint &newCenter)
double operator()(const RealPoint &aPoint) const
bool isInside(const RealPoint &aPoint) const
ImplicitHyperCube & operator=(const ImplicitHyperCube &other)
Space::RealPoint RealPoint
RealPoint myCenter
Ball center.
RealPoint getUpperBound() const
double myHalfWidth
Ball HalfWidth.
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
static Self diagonal(Component val=1)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Orientation
Definition: Common.h:141
@ INSIDE
Definition: Common.h:141
@ OUTSIDE
Definition: Common.h:141
@ ON
Definition: Common.h:141
const Point aPoint(3, 4)