DGtal  0.9.2
InexactPredicateLpSeparableMetric.h
1 
17 #pragma once
18 
31 #if defined(InexactPredicateLpSeparableMetric_RECURSES)
32 #error Recursive header files inclusion detected in InexactPredicateLpSeparableMetric.h
33 #else // defined(InexactPredicateLpSeparableMetric_RECURSES)
34 
35 #define InexactPredicateLpSeparableMetric_RECURSES
36 
37 #if !defined InexactPredicateLpSeparableMetric_h
38 
39 #define InexactPredicateLpSeparableMetric_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <cmath>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/kernel/CSpace.h"
47 #include "DGtal/kernel/CEuclideanRing.h"
49 
50 namespace DGtal
51 {
52 
54 // template class InexactPredicateLpSeparableMetric
80  template <typename TSpace, typename TValue = double>
82  : public std::binary_function< typename TSpace::Point, typename TSpace::Point, TValue >
83  {
84  // ----------------------- Standard services ------------------------------
85  public:
86 
88  typedef TSpace Space;
89 
92 
94  typedef typename Space::Point Point;
96  typedef typename Point::Coordinate Abscissa;
98  typedef typename Space::Vector Vector;
100  typedef TValue Value;
102  typedef TValue RawValue;
103 
107  InexactPredicateLpSeparableMetric( const double anExponent );
108 
109 
114 
120  {
121  myExponent = other.myExponent;
122  }
123 
130  {
131  myExponent = other.myExponent;
132  return *this;
133  }
134 
135  // ----------------------- Interface --------------------------------------
136  public:
137 
138  // ----------------------- CMetric --------------------------------------
147  Value operator()(const Point & aP, const Point &aQ) const;
148 
157  RawValue rawDistance(const Point & aP, const Point &aQ) const;
158 
170  Closest closest(const Point &origin,
171  const Point &first,
172  const Point &second) const;
173 
174  // ----------------------- CSeparableMetric --------------------------------------
195  bool hiddenBy(const Point &u,
196  const Point &v,
197  const Point &w,
198  const Point &startingPoint,
199  const Point &endPoint,
200  const typename Point::UnsignedComponent dim) const;
201 
202 
207  void selfDisplay ( std::ostream & out ) const;
208 
213  bool isValid() const;
214 
215  // ------------------------- Protected Datas ------------------------------
216  private:
217 
227  Value distanceLp(const Point &aP, const Point &aQ) const;
228 
229 
249  Abscissa binarySearchHidden(const Abscissa &udim,
250  const Abscissa &vdim,
251  const Value &nu,
252  const Value &nv,
253  const Abscissa &lower,
254  const Abscissa &upper) const;
255 
256 
257  // ------------------------- Private Datas --------------------------------
258  private:
259 
261  Value myExponent;
262 
263  }; // end of class InexactPredicateLpSeparableMetric
264 
271  template <typename T, typename V>
272  std::ostream&
273  operator<< ( std::ostream & out, const InexactPredicateLpSeparableMetric<T,V> & object );
274 
275 } // namespace DGtal
276 
277 
279 // Includes inline functions.
280 #include "DGtal/geometry/volumes/distance/InexactPredicateLpSeparableMetric.ih"
281 
282 // //
284 
285 #endif // !defined InexactPredicateLpSeparableMetric_h
286 
287 #undef InexactPredicateLpSeparableMetric_RECURSES
288 #endif // else defined(InexactPredicateLpSeparableMetric_RECURSES)
Abscissa binarySearchHidden(const Abscissa &udim, const Abscissa &vdim, const Value &nu, const Value &nv, const Abscissa &lower, const Abscissa &upper) const
Component Coordinate
Type for Point elements.
Definition: PointVector.h:158
Aim: implements separable l_p metrics with approximated predicates.
void selfDisplay(std::ostream &out) const
InexactPredicateLpSeparableMetric(const double anExponent)
Value operator()(const Point &aP, const Point &aQ) const
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...
bool hiddenBy(const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
Closest closest(const Point &origin, const Point &first, const Point &second) const
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines...
Definition: CSpace.h:105
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
RawValue rawDistance(const Point &aP, const Point &aQ) const
NumberTraits< Component >::UnsignedVersion UnsignedComponent
Unsigned version of the components.
Definition: PointVector.h:161
DGtal is the top-level namespace which contains all DGtal functions and types.
InexactPredicateLpSeparableMetric & operator=(const InexactPredicateLpSeparableMetric &other)
Value distanceLp(const Point &aP, const Point &aQ) const
InexactPredicateLpSeparableMetric(const InexactPredicateLpSeparableMetric &other)
Closest
Definition: Common.h:123