DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes
DGtal::SeparableMetricAdapter< TMetric > Class Template Reference

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

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

Public Types

typedef TMetric Metric
 Copy the space type. More...
 
typedef Metric::Point Point
 Type for points. More...
 
typedef Point::Coordinate Abscissa
 Type for point abscissa. More...
 
typedef Metric::Value Value
 Type for values. More...
 
typedef Metric::RawValue RawValue
 Type for raw values. More...
 
typedef Metric::Vector Vector
 Type for vectors. More...
 
typedef Metric::Space Space
 Type for Space. More...
 

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 [60] or ␓[83]): 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

◆ Abscissa

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

Type for point abscissa.

Definition at line 92 of file SeparableMetricAdapter.h.

◆ Metric

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

Copy the space type.

Definition at line 86 of file SeparableMetricAdapter.h.

◆ Point

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

Type for points.

Definition at line 90 of file SeparableMetricAdapter.h.

◆ RawValue

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

Type for raw values.

Definition at line 96 of file SeparableMetricAdapter.h.

◆ Space

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

Type for Space.

Definition at line 100 of file SeparableMetricAdapter.h.

◆ Value

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

Type for values.

Definition at line 94 of file SeparableMetricAdapter.h.

◆ Vector

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

Type for vectors.

Definition at line 98 of file SeparableMetricAdapter.h.

Constructor & Destructor Documentation

◆ SeparableMetricAdapter() [1/2]

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

◆ ~SeparableMetricAdapter()

template<typename TMetric >
DGtal::SeparableMetricAdapter< TMetric >::~SeparableMetricAdapter ( )
inline

Destructor.

Definition at line 114 of file SeparableMetricAdapter.h.

114{};

◆ SeparableMetricAdapter() [2/2]

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

◆ binarySearchHidden()

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.

◆ BOOST_CONCEPT_ASSERT()

template<typename TMetric >
DGtal::SeparableMetricAdapter< TMetric >::BOOST_CONCEPT_ASSERT ( (concepts::CMetricSpace< TMetric >)  )

◆ closest()

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.

176 {
177 return myMetric->closest(origin,first,second);
178 }

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

◆ hiddenBy()

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

◆ isValid()

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.

220 {
221 return myMetric->isValid();
222 }

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

◆ operator()()

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.

146 {
147 return myMetric->operator()(aP,aQ);
148 }

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

◆ operator=()

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.

128 {
129 myMetric = other.myMetric;
130 return *this;
131 }

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

◆ rawDistance()

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.

159 {
160 return myMetric->rawDistance(aP,aQ);
161 }

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

◆ selfDisplay()

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

◆ myMetric

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

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