DGtal  0.9.2
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 
79  ImplicitRoundedHyperCube(const RealPoint &aCenter,
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
136  Orientation orientation(const RealPoint &aPoint) const
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
155  RealPoint getLowerBound() const
156  {
158  }
159 
166  inline
167  RealPoint getUpperBound() const
168  {
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 
193  RealPoint myCenter;
194 
196  double myHalfWidth;
197 
199  double myPower;
200 
201  // ------------------------- Hidden services ------------------------------
202  protected:
203 
209 
210  private:
211 
219 
220 
221  }; // end of class ImplicitRoundedHyperCube
222 
223 
230  template <typename T>
231  std::ostream&
232  operator<< ( std::ostream & out, const ImplicitRoundedHyperCube<T> & object );
233 
234 } // namespace DGtal
235 
236 
238 // Includes inline functions.
239 #include "DGtal/shapes/implicit/ImplicitRoundedHyperCube.ih"
240 
241 // //
243 
244 #endif // !defined ImplicitRoundedHyperCube_h
245 
246 #undef ImplicitRoundedHyperCube_RECURSES
247 #endif // else defined(ImplicitRoundedHyperCube_RECURSES)
ImplicitRoundedHyperCube(const RealPoint &aCenter, const double &aHalfWidth, const double aPower)
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Definition: PointVector.h:167
static Self diagonal(Component val=1)
DGtal::uint32_t Dimension
Definition: Common.h:113
void selfDisplay(std::ostream &out) const
bool isInside(const RealPoint &aPoint) const
ImplicitRoundedHyperCube & operator=(const ImplicitRoundedHyperCube &other)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
Orientation
Definition: Common.h:118
ImplicitRoundedHyperCube< TSpace > Self
Orientation orientation(const RealPoint &aPoint) const
DGtal is the top-level namespace which contains all DGtal functions and types.
double operator()(const RealPoint &aPoint) const