DGtal  0.9.4beta
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
DGtal::DigitalMetricAdapter< TMetric, TInteger > Class Template Reference

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

Public Types

typedef TMetric Metric
 
typedef TInteger Value
 
typedef Metric::Point Point
 
typedef Metric::Space Space
 
typedef Value RawValue
 

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

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.

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.

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.

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.

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

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) {}
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.

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

110  {
111  if (this != &anotherMetric)
112  this->myMetric = anotherMetric.myMetric;
113  }
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 {}
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

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CMetricSpace< Metric >)  )
template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
DGtal::DigitalMetricAdapter< TMetric, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< Value >)  )
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.

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

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))
176  return DGtal::ClosestSECOND;
177  return DGtal::ClosestBOTH;
178  }
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.

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

195 { return (myMetric != NULL); }
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.

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

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

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

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

132  {
133  myMetric = other.myMetric;
134  return *this;
135  }
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.

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

157  {
158  return this->operator()(p,q);
159  }
Value operator()(const Point &p, const Point &q) const
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.

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

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

Field Documentation

template<typename TMetric , typename TInteger = typename TMetric::Space::Integer>
const Metric* DGtal::DigitalMetricAdapter< TMetric, TInteger >::myMetric
private

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