DGtal 1.4.0
Loading...
Searching...
No Matches
DigitalMetricAdapter.h
1
17#pragma once
18
31#if defined(DigitalMetricAdapter_RECURSES)
32#error Recursive header files inclusion detected in DigitalMetricAdapter.h
33#else // defined(DigitalMetricAdapter_RECURSES)
35#define DigitalMetricAdapter_RECURSES
36
37#if !defined DigitalMetricAdapter_h
39#define DigitalMetricAdapter_h
40
42// Inclusions
43#include <iostream>
44#include "DGtal/base/Common.h"
45#include "DGtal/geometry/volumes/distance/CMetricSpace.h"
46#include "DGtal/kernel/CInteger.h"
47#include "DGtal/base/ConstAlias.h"
48#include "DGtal/kernel/NumberTraits.h"
50
51namespace DGtal
52{
53
55 // template class DigitalMetricAdapter
70 template <typename TMetric, typename TInteger = typename TMetric::Space::Integer>
72 {
73 // ----------------------- Standard services ------------------------------
74 public:
75
77 typedef TMetric Metric;
79
81 typedef TInteger Value;
83
84 // ----------------------- CDigitalMetric------------------------------------
86 typedef typename Metric::Point Point;
87
89 typedef typename Metric::Space Space;
90
92 typedef Value RawValue;
93
94
102
103
110 {
111 if (this != &anotherMetric)
112 this->myMetric = anotherMetric.myMetric;
113 }
114
115
120
121 // ----------------------- Interface --------------------------------------
122 public:
123
124 // ----------------------- CDigitalMetricSpace --------------------------------------
125
132 {
133 myMetric = other.myMetric;
134 return *this;
135 }
136
144 Value operator() (const Point &p, const Point &q) const
145 {
146 return static_cast<Value>( std::ceil ( NumberTraits<typename Metric::Value>::castToDouble( myMetric->operator()(p,q))));
147 }
148
156 Value rawDistance(const Point &p, const Point &q) const
157 {
158 return this->operator()(p,q);
159 }
160
170 const Point &p,
171 const Point &q) const
172 {
173 if (this->operator()(a,p) < this->operator()(a,q))
174 return DGtal::ClosestFIRST;
175 if (this->operator()(a,p) > this->operator()(a,q))
177 return DGtal::ClosestBOTH;
178 }
179
180
181
186 void selfDisplay ( std::ostream & out ) const
187 {
188 out << "[DigitalMetricAdapter] adapted from "<< *myMetric;
189 }
190
195 bool isValid() const { return (myMetric != NULL); }
196
197 // ------------------------- Protected Datas ------------------------------
198 private:
199 // ------------------------- Private Datas --------------------------------
200 private:
201
203
204 // ------------------------- Hidden services ------------------------------
205 protected:
206
212
213 // ------------------------- Internals ------------------------------------
214 private:
215
216 }; // end of class DigitalMetricAdapter
217
218
225 template <typename T>
226 std::ostream&
227 operator<< ( std::ostream & out, const DigitalMetricAdapter<T> & object );
228
229} // namespace DGtal
230
231// //
233
234#endif // !defined DigitalMetricAdapter_h
235
236#undef DigitalMetricAdapter_RECURSES
237#endif // else defined(DigitalMetricAdapter_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition ConstAlias.h:187
Aim: simple adapter class which adapts any models of concepts::CMetricSpace to a model of concepts::C...
TMetric Metric
Input metric type.
TInteger Value
Values are integer numbers.
DGtal::Closest closest(const Point &a, const Point &p, const Point &q) const
BOOST_CONCEPT_ASSERT((concepts::CMetricSpace< Metric >))
BOOST_CONCEPT_ASSERT((concepts::CInteger< Value >))
Value rawDistance(const Point &p, const Point &q) const
Metric::Space Space
Space type.
void selfDisplay(std::ostream &out) const
Metric::Point Point
Point type.
DigitalMetricAdapter & operator=(const DigitalMetricAdapter &other)
Value operator()(const Point &p, const Point &q) const
DigitalMetricAdapter(const DigitalMetricAdapter &anotherMetric)
DigitalMetricAdapter(ConstAlias< Metric > aMetric)
DGtal is the top-level namespace which contains all DGtal functions and types.
Closest
Definition Common.h:146
@ ClosestBOTH
Definition Common.h:146
@ ClosestSECOND
Definition Common.h:146
@ ClosestFIRST
Definition Common.h:146
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: The traits class for all models of Cinteger.
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition CInteger.h:88
Aim: defines the concept of metric spaces.