DGtal  1.3.beta
ImplicitRoundedHyperCube.h
1 
17 #pragma once
18 
31 #if defined(ImplicitRoundedHyperCube_RECURSES)
32 #error Recursive header files inclusion detected in ImplicitRoundedHyperCube.h
33 #else // defined(ImplicitRoundedHyperCube_RECURSES)
34 
35 #define ImplicitRoundedHyperCube_RECURSES
36 
37 #if !defined ImplicitRoundedHyperCube_h
38 
39 #define ImplicitRoundedHyperCube_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal
48 {
49 
52 
61  template <typename TSpace>
63  {
64 
65  public:
67  typedef TSpace Space;
68  typedef typename Space::RealPoint RealPoint;
69  typedef double Value;
70 
80  const double &aHalfWidth,
81  const double aPower):
82  myCenter(aCenter),
83  myHalfWidth(aHalfWidth),
84  myPower(aPower)
85  {};
86 
92 
93 
94  // ----------------------- Interface --------------------------------------
95  public:
96 
105  inline
106  double operator()(const RealPoint &aPoint) const
107  {
108  RealPoint dec = (aPoint - myCenter);
109  double partialpower=0;
110  for(Dimension i = 0; i < RealPoint::dimension; ++i)
111  partialpower += std::pow(std::abs((double)dec[i]), myPower);
112 
113  return std::pow(myHalfWidth, myPower) - partialpower;
114  }
115 
122  inline
123  bool isInside(const RealPoint &aPoint) const
124  {
125  return this->operator()(aPoint) >0.0;
126  }
127 
135  inline
137  {
138  if (this->operator()(aPoint) > 0.0)
139  return INSIDE;
140  else
141  if (this->operator()(aPoint) < 0.0)
142  return OUTSIDE;
143  else
144  return ON;
145  }
146 
147 
154  inline
156  {
158  }
159 
166  inline
168  {
170  }
171 
176  {
177  return myCenter;
178  }
179 
184  inline
185  void moveTo( const RealPoint& newCenter )
186  {
187  myCenter = newCenter;
188  }
189 
190  // ----------------------- Interface --------------------------------------
191  public:
192 
197  void selfDisplay ( std::ostream & out ) const;
198 
203  bool isValid() const;
204 
205  // ------------------------- Protected Datas ------------------------------
206  private:
207  // ------------------------- Private Datas --------------------------------
208  private:
209 
212 
214  double myHalfWidth;
215 
217  double myPower;
218 
219  // ------------------------- Hidden services ------------------------------
220  protected:
221 
227 
228  private:
229 
237 
238 
239  }; // end of class ImplicitRoundedHyperCube
240 
241 
248  template <typename T>
249  std::ostream&
250  operator<< ( std::ostream & out, const ImplicitRoundedHyperCube<T> & object );
251 
252 } // namespace DGtal
253 
254 
256 // Includes inline functions.
257 #include "DGtal/shapes/implicit/ImplicitRoundedHyperCube.ih"
258 
259 // //
261 
262 #endif // !defined ImplicitRoundedHyperCube_h
263 
264 #undef ImplicitRoundedHyperCube_RECURSES
265 #endif // else defined(ImplicitRoundedHyperCube_RECURSES)
DGtal::ImplicitRoundedHyperCube::RealPoint
Space::RealPoint RealPoint
Definition: ImplicitRoundedHyperCube.h:68
DGtal::ImplicitRoundedHyperCube::orientation
Orientation orientation(const RealPoint &aPoint) const
Definition: ImplicitRoundedHyperCube.h:136
DGtal::ImplicitRoundedHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
Definition: ImplicitRoundedHyperCube.h:62
DGtal::ImplicitRoundedHyperCube::operator()
double operator()(const RealPoint &aPoint) const
Definition: ImplicitRoundedHyperCube.h:106
DGtal::ImplicitRoundedHyperCube::Space
TSpace Space
Definition: ImplicitRoundedHyperCube.h:67
DGtal::ImplicitRoundedHyperCube::myCenter
RealPoint myCenter
Cube center.
Definition: ImplicitRoundedHyperCube.h:211
DGtal::ON
@ ON
Definition: Common.h:142
DGtal::ImplicitRoundedHyperCube::~ImplicitRoundedHyperCube
~ImplicitRoundedHyperCube()
aPoint
const Point aPoint(3, 4)
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::ImplicitRoundedHyperCube::operator=
ImplicitRoundedHyperCube & operator=(const ImplicitRoundedHyperCube &other)
DGtal::PointVector::diagonal
static Self diagonal(Component val=1)
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::Orientation
Orientation
Definition: Common.h:142
DGtal::ImplicitRoundedHyperCube::center
RealPoint center() const
Definition: ImplicitRoundedHyperCube.h:175
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::ImplicitRoundedHyperCube::ImplicitRoundedHyperCube
ImplicitRoundedHyperCube()
DGtal::ImplicitRoundedHyperCube::Self
ImplicitRoundedHyperCube< TSpace > Self
Definition: ImplicitRoundedHyperCube.h:66
DGtal::PointVector::dimension
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Definition: PointVector.h:626
DGtal::ImplicitRoundedHyperCube::ImplicitRoundedHyperCube
ImplicitRoundedHyperCube(const RealPoint &aCenter, const double &aHalfWidth, const double aPower)
Definition: ImplicitRoundedHyperCube.h:79
DGtal::ImplicitRoundedHyperCube::moveTo
void moveTo(const RealPoint &newCenter)
Definition: ImplicitRoundedHyperCube.h:185
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::ImplicitRoundedHyperCube::getLowerBound
RealPoint getLowerBound() const
Definition: ImplicitRoundedHyperCube.h:155
DGtal::ImplicitRoundedHyperCube::isValid
bool isValid() const
DGtal::ImplicitRoundedHyperCube::getUpperBound
RealPoint getUpperBound() const
Definition: ImplicitRoundedHyperCube.h:167
DGtal::OUTSIDE
@ OUTSIDE
Definition: Common.h:142
DGtal::ImplicitRoundedHyperCube::myHalfWidth
double myHalfWidth
Cube HalfWidth.
Definition: ImplicitRoundedHyperCube.h:214
DGtal::ImplicitRoundedHyperCube::isInside
bool isInside(const RealPoint &aPoint) const
Definition: ImplicitRoundedHyperCube.h:123
DGtal::INSIDE
@ INSIDE
Definition: Common.h:142
DGtal::ImplicitRoundedHyperCube::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::ImplicitRoundedHyperCube::myPower
double myPower
Cube Power.
Definition: ImplicitRoundedHyperCube.h:217
DGtal::ImplicitRoundedHyperCube::Value
double Value
Definition: ImplicitRoundedHyperCube.h:69