DGtal  0.9.2
SeparableMetricAdapter.h
1 
17 #pragma once
18 
31 #if defined(SeparableMetricAdapter_RECURSES)
32 #error Recursive header files inclusion detected in SeparableMetricAdapter.h
33 #else // defined(SeparableMetricAdapter_RECURSES)
34 
35 #define SeparableMetricAdapter_RECURSES
36 
37 #if !defined SeparableMetricAdapter_h
38 
39 #define SeparableMetricAdapter_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <cmath>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/geometry/volumes/distance/CMetricSpace.h"
47 #include "DGtal/base/ConstAlias.h"
49 
50 namespace DGtal
51 {
52 
54  // template class SeparableMetricAdapter
78  template <typename TMetric>
80  {
81  // ----------------------- Standard services ------------------------------
82  public:
83 
84 
86  typedef TMetric Metric;
88 
90  typedef typename Metric::Point Point;
92  typedef typename Point::Coordinate Abscissa;
94  typedef typename Metric::Value Value;
96  typedef typename Metric::RawValue RawValue;
98  typedef typename Metric::Vector Vector;
100  typedef typename Metric::Space Space;
101 
109  {}
110 
115 
121 
128  {
129  myMetric = other.myMetric;
130  return *this;
131  }
132 
133  // ----------------------- Interface --------------------------------------
134  public:
135 
136  // ----------------------- CMetric --------------------------------------
145  Value operator()(const Point & aP, const Point &aQ) const
146  {
147  return myMetric->operator()(aP,aQ);
148  }
149 
158  RawValue rawDistance(const Point & aP, const Point &aQ) const
159  {
160  return myMetric->rawDistance(aP,aQ);
161  }
173  Closest closest(const Point &origin,
174  const Point &first,
175  const Point &second) const
176  {
177  return myMetric->closest(origin,first,second);
178  }
179 
180  // ----------------------- CSeparableMetric --------------------------------------
201  bool hiddenBy(const Point &u,
202  const Point &v,
203  const Point &w,
204  const Point &startingPoint,
205  const Point &endPoint,
206  const typename Point::UnsignedComponent dim) const;
207 
208 
213  void selfDisplay ( std::ostream & out ) const;
214 
219  bool isValid() const
220  {
221  return myMetric->isValid();
222  }
223 
224 
239  Abscissa binarySearchHidden(const Point &u,
240  const Point &v,
241  const typename Point::UnsignedComponent dim,
242  const Point &lower,
243  const Point &upper) const;
244 
245  // ------------------------- Private methods ------------------------------
246  private:
247 
248  // ------------------------- Private members ------------------------------
249  private:
250  const Metric *myMetric;
251 
252  }; // end of class SeparableMetricAdapter
253 
254 
255 
262  template <typename TM>
263  std::ostream&
264  operator<< ( std::ostream & out, const SeparableMetricAdapter<TM> & object );
265 
266 } // namespace DGtal
267 
268 
270 // Includes inline functions.
271 #include "DGtal/geometry/volumes/distance/SeparableMetricAdapter.ih"
272 
273 // //
275 
276 #endif // !defined SeparableMetricAdapter_h
277 
278 #undef SeparableMetricAdapter_RECURSES
279 #endif // else defined(SeparableMetricAdapter_RECURSES)
Value operator()(const Point &aP, const Point &aQ) const
bool hiddenBy(const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
Metric::Space Space
Type for Space.
TMetric Metric
Copy the space type.
void selfDisplay(std::ostream &out) const
Metric::Vector Vector
Type for vectors.
Metric::Point Point
Type for points.
SeparableMetricAdapter & operator=(const SeparableMetricAdapter &other)
Aim: Adapts any model of CMetric to construct a separable metric (model of CSeparableMetric).
BOOST_CONCEPT_ASSERT((concepts::CMetricSpace< TMetric >))
RawValue rawDistance(const Point &aP, const Point &aQ) const
Point::Coordinate Abscissa
Type for point abscissa.
Abscissa binarySearchHidden(const Point &u, const Point &v, const typename Point::UnsignedComponent dim, const Point &lower, const Point &upper) const
SeparableMetricAdapter(ConstAlias< Metric > aMetric)
Closest closest(const Point &origin, const Point &first, const Point &second) const
DGtal is the top-level namespace which contains all DGtal functions and types.
SeparableMetricAdapter(const SeparableMetricAdapter &other)
Metric::RawValue RawValue
Type for raw values.
Aim: defines the concept of metric spaces.
Definition: CMetricSpace.h:124
Metric::Value Value
Type for values.
Closest
Definition: Common.h:123