DGtal  1.1.0
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)
34 
35 #define ImplicitHyperCube_RECURSES
36 
37 #if !defined ImplicitHyperCube_h
38 
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)
DGtal::ImplicitHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
Definition: ImplicitHyperCube.h:60
DGtal::ImplicitHyperCube::~ImplicitHyperCube
~ImplicitHyperCube()
DGtal::ImplicitHyperCube::isValid
bool isValid() const
DGtal::PointVector::L_infty
@ L_infty
Definition: PointVector.h:1488
DGtal::ON
@ ON
Definition: Common.h:138
aPoint
const Point aPoint(3, 4)
DGtal::ImplicitHyperCube::center
RealPoint center() const
Definition: ImplicitHyperCube.h:157
DGtal::ImplicitHyperCube::Space
TSpace Space
Definition: ImplicitHyperCube.h:64
DGtal::ImplicitHyperCube::RealPoint
Space::RealPoint RealPoint
Definition: ImplicitHyperCube.h:65
DGtal::ImplicitHyperCube::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::ImplicitHyperCube::myHalfWidth
double myHalfWidth
Ball HalfWidth.
Definition: ImplicitHyperCube.h:196
DGtal::PointVector::diagonal
static Self diagonal(Component val=1)
DGtal::ImplicitHyperCube::Value
double Value
Definition: ImplicitHyperCube.h:66
DGtal::ImplicitHyperCube::ImplicitHyperCube
ImplicitHyperCube()
DGtal::Orientation
Orientation
Definition: Common.h:138
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::ImplicitHyperCube::ImplicitHyperCube
ImplicitHyperCube(const RealPoint &aCenter, const double &aHalfWidth)
Definition: ImplicitHyperCube.h:75
DGtal::ImplicitHyperCube::isInside
bool isInside(const RealPoint &aPoint) const
Definition: ImplicitHyperCube.h:112
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::ImplicitHyperCube::operator=
ImplicitHyperCube & operator=(const ImplicitHyperCube &other)
DGtal::ImplicitHyperCube::orientation
Orientation orientation(const RealPoint &aPoint) const
Definition: ImplicitHyperCube.h:119
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal::OUTSIDE
@ OUTSIDE
Definition: Common.h:138
DGtal::ImplicitHyperCube::getUpperBound
RealPoint getUpperBound() const
Definition: ImplicitHyperCube.h:149
DGtal::ImplicitHyperCube::myCenter
RealPoint myCenter
Ball center.
Definition: ImplicitHyperCube.h:193
DGtal::ImplicitHyperCube::moveTo
void moveTo(const RealPoint &newCenter)
Definition: ImplicitHyperCube.h:167
DGtal::ImplicitHyperCube::operator()
double operator()(const RealPoint &aPoint) const
Definition: ImplicitHyperCube.h:99
DGtal::ImplicitHyperCube::Self
ImplicitHyperCube< TSpace > Self
Definition: ImplicitHyperCube.h:63
DGtal::ImplicitHyperCube::getLowerBound
RealPoint getLowerBound() const
Definition: ImplicitHyperCube.h:137
DGtal::INSIDE
@ INSIDE
Definition: Common.h:138