DGtal  1.5.beta
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)
35 #define SeparableMetricAdapter_RECURSES
36 
37 #if !defined SeparableMetricAdapter_h
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 
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Adapts any model of CMetric to construct a separable metric (model of CSeparableMetric).
Metric::RawValue RawValue
Type for raw values.
RawValue rawDistance(const Point &aP, const Point &aQ) const
SeparableMetricAdapter & operator=(const SeparableMetricAdapter &other)
Point::Coordinate Abscissa
Type for point abscissa.
BOOST_CONCEPT_ASSERT((concepts::CMetricSpace< TMetric >))
void selfDisplay(std::ostream &out) const
Metric::Space Space
Type for Space.
Metric::Value Value
Type for values.
Metric::Point Point
Type for points.
Metric::Vector Vector
Type for vectors.
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
TMetric Metric
Copy the space type.
Value operator()(const Point &aP, const Point &aQ) const
Abscissa binarySearchHidden(const Point &u, const Point &v, const typename Point::UnsignedComponent dim, const Point &lower, const Point &upper) const
SeparableMetricAdapter(ConstAlias< Metric > aMetric)
SeparableMetricAdapter(const SeparableMetricAdapter &other)
DigitalPlane::Point Vector
DGtal is the top-level namespace which contains all DGtal functions and types.
Closest
Definition: Common.h:146
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Aim: defines the concept of metric spaces.
Definition: CMetricSpace.h:125
MyPointD Point
Definition: testClone2.cpp:383
unsigned int dim(const Vector &z)
Vector lower(const Vector &z, unsigned int k)
Vector upper(const Vector &z, unsigned int k)