DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::DigitalMetricAdapter< TMetric, TInteger > Class Template Reference

Aim: simple adapter class which adapts any models of concepts::CMetricSpace to a model of concepts::CDigitalMetricSpace. More...

#include <DGtal/geometry/volumes/distance/DigitalMetricAdapter.h>

Public Types

typedef TMetric Metric
 Input metric type.
 
typedef TInteger Value
 Values are integer numbers.
 
typedef Metric::Point Point
 Point type.
 
typedef Metric::Space Space
 Space type.
 
typedef Value RawValue
 RawValue type.
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CMetricSpace< Metric >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CInteger< Value >))
 
 DigitalMetricAdapter (ConstAlias< Metric > aMetric)
 
 DigitalMetricAdapter (const DigitalMetricAdapter &anotherMetric)
 
 ~DigitalMetricAdapter ()
 
DigitalMetricAdapteroperator= (const DigitalMetricAdapter &other)
 
Value operator() (const Point &p, const Point &q) const
 
Value rawDistance (const Point &p, const Point &q) const
 
DGtal::Closest closest (const Point &a, const Point &p, const Point &q) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Protected Member Functions

 DigitalMetricAdapter ()
 

Private Attributes

const MetricmyMetric
 

Detailed Description

template<typename TMetric, typename TInteger = typename TMetric::Space::Integer>
class DGtal::DigitalMetricAdapter< TMetric, TInteger >

Aim: simple adapter class which adapts any models of concepts::CMetricSpace to a model of concepts::CDigitalMetricSpace.

Description of template class 'DigitalMetricAdapter'

This class uses the ceil function to perform the adaptation. This class is thus a model of CDigitalMetricSpace

Template Parameters
TMetricany model of concepts::CMetricSpace.
TIntegerany model of concepts::CInteger to be used as value type. By default, it corresponds to the Integer type of the digital space in which the TMetric is defined.

Definition at line 71 of file DigitalMetricAdapter.h.

Member Typedef Documentation

◆ Metric

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
typedef TMetric DGtal::DigitalMetricAdapter< TMetric, TInteger >::Metric

Input metric type.

Definition at line 77 of file DigitalMetricAdapter.h.

◆ Point

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
typedef Metric::Point DGtal::DigitalMetricAdapter< TMetric, TInteger >::Point

Point type.

Definition at line 86 of file DigitalMetricAdapter.h.

◆ RawValue

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
typedef Value DGtal::DigitalMetricAdapter< TMetric, TInteger >::RawValue

RawValue type.

Definition at line 92 of file DigitalMetricAdapter.h.

◆ Space

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
typedef Metric::Space DGtal::DigitalMetricAdapter< TMetric, TInteger >::Space

Space type.

Definition at line 89 of file DigitalMetricAdapter.h.

◆ Value

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
typedef TInteger DGtal::DigitalMetricAdapter< TMetric, TInteger >::Value

Values are integer numbers.

Definition at line 81 of file DigitalMetricAdapter.h.

Constructor & Destructor Documentation

◆ DigitalMetricAdapter() [1/3]

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::DigitalMetricAdapter ( ConstAlias< Metric > aMetric)
inline

Constructor from a CMetricSpace model.

Parameters
aMetricthe metric to adapt.

Definition at line 100 of file DigitalMetricAdapter.h.

100 :
101 myMetric(&aMetric) {}

◆ DigitalMetricAdapter() [2/3]

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::DigitalMetricAdapter ( const DigitalMetricAdapter< TMetric, TInteger > & anotherMetric)
inline

Copy Constructor

Parameters
anotherMetricthe digital metric adapter to copy.

Definition at line 109 of file DigitalMetricAdapter.h.

110 {
111 if (this != &anotherMetric)
112 this->myMetric = anotherMetric.myMetric;
113 }

References DGtal::DigitalMetricAdapter< TMetric, TInteger >::myMetric.

◆ ~DigitalMetricAdapter()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::~DigitalMetricAdapter ( )
inline

Destructor.

Definition at line 119 of file DigitalMetricAdapter.h.

119{}

◆ DigitalMetricAdapter() [3/3]

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::DigitalMetricAdapter ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< Value >) )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CMetricSpace< Metric >) )

◆ closest()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::Closest DGtal::DigitalMetricAdapter< TMetric, TInteger >::closest ( const Point & a,
const Point & p,
const Point & q ) const
inline

closest operator.

Parameters
[in]athe origin point.
[in]pa first point.
[in]qa second point.
Returns
decides which point from p and q is closer to a.

Definition at line 169 of file DigitalMetricAdapter.h.

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 }
@ ClosestBOTH
Definition Common.h:146
@ ClosestSECOND
Definition Common.h:146
@ ClosestFIRST
Definition Common.h:146

References DGtal::ClosestBOTH, DGtal::ClosestFIRST, and DGtal::ClosestSECOND.

◆ isValid()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
bool DGtal::DigitalMetricAdapter< TMetric, TInteger >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 195 of file DigitalMetricAdapter.h.

195{ return (myMetric != NULL); }

References DGtal::DigitalMetricAdapter< TMetric, TInteger >::myMetric.

◆ operator()()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
Value DGtal::DigitalMetricAdapter< TMetric, TInteger >::operator() ( const Point & p,
const Point & q ) const
inline

Distance operator.

Parameters
[in]pa first point.
[in]qa second point.
Returns
the casted distance from p to q

Definition at line 144 of file DigitalMetricAdapter.h.

145 {
146 return static_cast<Value>( std::ceil ( NumberTraits<typename Metric::Value>::castToDouble( myMetric->operator()(p,q))));
147 }

References DGtal::DigitalMetricAdapter< TMetric, TInteger >::myMetric.

Referenced by DGtal::DigitalMetricAdapter< TMetric, TInteger >::rawDistance().

◆ operator=()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DigitalMetricAdapter & DGtal::DigitalMetricAdapter< TMetric, TInteger >::operator= ( const DigitalMetricAdapter< TMetric, TInteger > & other)
inline

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

Definition at line 131 of file DigitalMetricAdapter.h.

132 {
133 myMetric = other.myMetric;
134 return *this;
135 }

References DGtal::DigitalMetricAdapter< TMetric, TInteger >::myMetric.

◆ rawDistance()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
Value DGtal::DigitalMetricAdapter< TMetric, TInteger >::rawDistance ( const Point & p,
const Point & q ) const
inline

RawDistance operator.

Parameters
[in]pa first point.
[in]qa second point.
Returns
the casted distance from p to q

Definition at line 156 of file DigitalMetricAdapter.h.

157 {
158 return this->operator()(p,q);
159 }
Value operator()(const Point &p, const Point &q) const

References DGtal::DigitalMetricAdapter< TMetric, TInteger >::operator()().

◆ selfDisplay()

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
void DGtal::DigitalMetricAdapter< TMetric, TInteger >::selfDisplay ( std::ostream & out) const
inline

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Definition at line 186 of file DigitalMetricAdapter.h.

187 {
188 out << "[DigitalMetricAdapter] adapted from "<< *myMetric;
189 }

References DGtal::DigitalMetricAdapter< TMetric, TInteger >::myMetric.

Field Documentation

◆ myMetric


The documentation for this class was generated from the following file: