DGtal  0.9.3beta
Public Types | Public Member Functions | Private Attributes
DGtal::SeparableMetricAdapter< TMetric > Class Template Reference

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

Public Types

typedef TMetric Metric
 
typedef Metric::Point Point
 
typedef Point::Coordinate Abscissa
 
typedef Metric::Value Value
 
typedef Metric::RawValue RawValue
 
typedef Metric::Vector Vector
 
typedef Metric::Space Space
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CMetricSpace< TMetric >))
 
 SeparableMetricAdapter (ConstAlias< Metric > aMetric)
 
 ~SeparableMetricAdapter ()
 
 SeparableMetricAdapter (const SeparableMetricAdapter &other)
 
SeparableMetricAdapteroperator= (const SeparableMetricAdapter &other)
 
Value operator() (const Point &aP, const Point &aQ) const
 
RawValue rawDistance (const Point &aP, const Point &aQ) const
 
Closest closest (const Point &origin, const Point &first, const Point &second) const
 
bool hiddenBy (const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
Abscissa binarySearchHidden (const Point &u, const Point &v, const typename Point::UnsignedComponent dim, const Point &lower, const Point &upper) const
 

Private Attributes

const MetricmyMetric
 

Detailed Description

template<typename TMetric>
class DGtal::SeparableMetricAdapter< TMetric >

Aim: Adapts any model of CMetric to construct a separable metric (model of CSeparableMetric).

Description of template class 'SeparableMetricAdapter'

The adapted metric can thus be used in separable algorithms such as VoronoiMap or PowerMap. The adapted metric makes sense only if the input metric as the monotinicity propertery (see [36] or [46]): In dimension 2, consider two points \( p(x,y)\), \(q(x',y')\) with \(x<x'\). Let \(r( x'',0)\) be a point on the x-axis such that \(d(p,r) = d(q,r)\) and \( s(u,0)\) be another point on the x-axis. A metric \( d\) is monotonic if

\[ u < x'' \implies d(p,s) \leq d(q,s) \]

and

\[ u > x'' \implies d(p,s) \geq d(q,s) \]

If the metric distance evaluation is in \(O(m)\), the hiddenBy() method is in \(O(m\log n)\).

Template Parameters
TMetricthe type of input metric (model of CMetric)

Definition at line 79 of file SeparableMetricAdapter.h.

Member Typedef Documentation

template<typename TMetric >
typedef Point::Coordinate DGtal::SeparableMetricAdapter< TMetric >::Abscissa

Type for point abscissa.

Definition at line 92 of file SeparableMetricAdapter.h.

template<typename TMetric >
typedef TMetric DGtal::SeparableMetricAdapter< TMetric >::Metric

Copy the space type.

Definition at line 86 of file SeparableMetricAdapter.h.

template<typename TMetric >
typedef Metric::Point DGtal::SeparableMetricAdapter< TMetric >::Point

Type for points.

Definition at line 90 of file SeparableMetricAdapter.h.

template<typename TMetric >
typedef Metric::RawValue DGtal::SeparableMetricAdapter< TMetric >::RawValue

Type for raw values.

Definition at line 96 of file SeparableMetricAdapter.h.

template<typename TMetric >
typedef Metric::Space DGtal::SeparableMetricAdapter< TMetric >::Space

Type for Space.

Definition at line 100 of file SeparableMetricAdapter.h.

template<typename TMetric >
typedef Metric::Value DGtal::SeparableMetricAdapter< TMetric >::Value

Type for values.

Definition at line 94 of file SeparableMetricAdapter.h.

template<typename TMetric >
typedef Metric::Vector DGtal::SeparableMetricAdapter< TMetric >::Vector

Type for vectors.

Definition at line 98 of file SeparableMetricAdapter.h.

Constructor & Destructor Documentation

template<typename TMetric >
DGtal::SeparableMetricAdapter< TMetric >::SeparableMetricAdapter ( ConstAlias< Metric aMetric)
inline

Constructor from a CMetric model instance. The metric is aliased in this class.

Parameters
[in]aMetricany model of CMetric which is monotonic.

Definition at line 108 of file SeparableMetricAdapter.h.

108  : myMetric(&aMetric)
109  {}
template<typename TMetric >
DGtal::SeparableMetricAdapter< TMetric >::~SeparableMetricAdapter ( )
inline

Destructor.

Definition at line 114 of file SeparableMetricAdapter.h.

114 {};
template<typename TMetric >
DGtal::SeparableMetricAdapter< TMetric >::SeparableMetricAdapter ( const SeparableMetricAdapter< TMetric > &  other)
inline

Copy constructor. (CopyConstruticle concept)

Parameters
otherthe object to clone.

Definition at line 120 of file SeparableMetricAdapter.h.

120 : myMetric(other.myMetric) {}

Member Function Documentation

template<typename TMetric >
Abscissa DGtal::SeparableMetricAdapter< TMetric >::binarySearchHidden ( const Point u,
const Point v,
const typename Point::UnsignedComponent  dim,
const Point lower,
const Point upper 
) const

Perform a binary search on the interval [lower,upper] to detect the mid-point between u and v .

Precondition
udim < vdim
Parameters
ua point
va point
dimdirection of the straight line
lowerstarting point of the segment
upperend point of the segment
Returns
the u Voronoi cell greatest point coordinates along dimension dim.
template<typename TMetric >
DGtal::SeparableMetricAdapter< TMetric >::BOOST_CONCEPT_ASSERT ( (concepts::CMetricSpace< TMetric >)  )
template<typename TMetric >
Closest DGtal::SeparableMetricAdapter< TMetric >::closest ( const Point origin,
const Point first,
const Point second 
) const
inline

Given an origin and two points, this method decides which one is closest to the origin. This method should be faster than comparing distance values.

Parameters
originthe origin
firstthe first point
secondthe second point
Returns
a Closest enum: ClosestFIRST, ClosestSECOND or ClosestBOTH.

Definition at line 173 of file SeparableMetricAdapter.h.

References DGtal::SeparableMetricAdapter< TMetric >::myMetric.

176  {
177  return myMetric->closest(origin,first,second);
178  }
template<typename TMetric >
bool DGtal::SeparableMetricAdapter< TMetric >::hiddenBy ( const Point u,
const Point v,
const Point w,
const Point startingPoint,
const Point endPoint,
const typename Point::UnsignedComponent  dim 
) const

Given three sites (u,v,w) and a straight segment [startingPoint,endPoint] along dimension dim, we detect if the voronoi cells of u and w strictly hide the voronoi cell of v on the straight line.

If operator()(p,q) of the underlying metric is in \( O(m)\), the cost of this method is \( O(mlog(n))\) (b being the number of points in [startingPoint,endPoint]).

Precondition
u,v and w must be such that u[dim] < v[dim] < w[dim]
Parameters
ua site
va site
wa site
startingPointstarting point of the segment
endPointend point of the segment
dimdirection of the straight line
Returns
true if (u,w) hides v (strictly).
template<typename TMetric >
bool DGtal::SeparableMetricAdapter< TMetric >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 219 of file SeparableMetricAdapter.h.

References DGtal::SeparableMetricAdapter< TMetric >::myMetric.

220  {
221  return myMetric->isValid();
222  }
template<typename TMetric >
Value DGtal::SeparableMetricAdapter< TMetric >::operator() ( const Point aP,
const Point aQ 
) const
inline

Compute the distance between aP and aQ.

Parameters
aPa first point.
aQa second point.
Returns
the distance between aP and aQ.

Definition at line 145 of file SeparableMetricAdapter.h.

References DGtal::SeparableMetricAdapter< TMetric >::myMetric.

146  {
147  return myMetric->operator()(aP,aQ);
148  }
template<typename TMetric >
SeparableMetricAdapter& DGtal::SeparableMetricAdapter< TMetric >::operator= ( const SeparableMetricAdapter< TMetric > &  other)
inline

Assignment. (Assignable concept)

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

Definition at line 127 of file SeparableMetricAdapter.h.

References DGtal::SeparableMetricAdapter< TMetric >::myMetric.

128  {
129  myMetric = other.myMetric;
130  return *this;
131  }
template<typename TMetric >
RawValue DGtal::SeparableMetricAdapter< TMetric >::rawDistance ( const Point aP,
const Point aQ 
) const
inline

Compute the raw distance between aP and aQ.

Parameters
aPa first point.
aQa second point.
Returns
the distance between aP and aQ.

Definition at line 158 of file SeparableMetricAdapter.h.

References DGtal::SeparableMetricAdapter< TMetric >::myMetric.

159  {
160  return myMetric->rawDistance(aP,aQ);
161  }
template<typename TMetric >
void DGtal::SeparableMetricAdapter< TMetric >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

template<typename TMetric >
const Metric* DGtal::SeparableMetricAdapter< TMetric >::myMetric
private

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