DGtal 1.4.0
|
Aim: Implementation of the linear in time Voronoi map construction. More...
#include <DGtal/geometry/volumes/distance/VoronoiMapComplete.h>
Public Types | |
typedef TSpace | Space |
Copy of the space type. | |
typedef TPointPredicate | PointPredicate |
Copy of the point predicate type. | |
typedef TImageContainer::Domain | Domain |
Definition of the underlying domain type. | |
typedef TSeparableMetric | SeparableMetric |
Definition of the separable metric type. | |
typedef DGtal::int64_t | IntegerLong |
Large integer type for SeparableMetricHelper construction. | |
typedef Space::Vector | Vector |
typedef Space::Point | Point |
typedef Space::Dimension | Dimension |
typedef Space::Size | Size |
typedef Space::Point::Coordinate | Abscissa |
typedef TImageContainer | OutputImage |
Type of resulting image. | |
typedef OutputImage::Value | Value |
Definition of the image value type. | |
typedef OutputImage::ConstRange | ConstRange |
Definition of the image value type. | |
typedef VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > | Self |
Self type. | |
typedef std::array< bool, Space::dimension > | PeriodicitySpec |
Periodicity specification type. | |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CPointPredicate< TPointPredicate >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CSeparableMetric< TSeparableMetric >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CImage< TImageContainer >)) | |
BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value)) | |
Both Space points and PointPredicate points must be the same. | |
BOOST_STATIC_ASSERT ((boost::is_same< TSpace, typename TImageContainer::Domain::Space >::value)) | |
BOOST_STATIC_ASSERT ((boost::is_same< std::set< typename TSpace::Vector >, typename TImageContainer::Value >::value)) | |
BOOST_STATIC_ASSERT ((boost::is_same< HyperRectDomain< TSpace >, typename TImageContainer::Domain >::value)) | |
VoronoiMapComplete (ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric) | |
VoronoiMapComplete (ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, PeriodicitySpec const &aPeriodicitySpec) | |
~VoronoiMapComplete ()=default | |
VoronoiMapComplete ()=delete | |
Self & | operator= (const Self &aOtherVoronoiMap)=default |
const Domain & | domain () const |
ConstRange | constRange () const |
Value | operator() (const Point &aPoint) const |
const SeparableMetric * | metric () const |
PeriodicitySpec const & | getPeriodicitySpec () const |
bool | isPeriodic (const Dimension n) const |
Point | projectPoint (Point aPoint) const |
void | selfDisplay (std::ostream &out) const |
Protected Attributes | |
const SeparableMetric * | myMetricPtr |
Pointer to the separable metric instance. | |
CountedPtr< OutputImage > | myImagePtr |
Voronoi map image. | |
PeriodicitySpec | myPeriodicitySpec |
Periodicity along each dimension. | |
Private Member Functions | |
void | compute () |
void | computeOtherSteps (const Dimension dim) const |
void | computeOtherStep1D (const Point &row, const Dimension dim) const |
Point::Coordinate | projectCoordinate (typename Point::Coordinate aCoordinate, const Dimension aDim) const |
Private Attributes | |
const Domain * | myDomainPtr |
Pointer to the computation domain. | |
const PointPredicate * | myPointPredicatePtr |
Pointer to the point predicate. | |
Point | myLowerBoundCopy |
Copy of the image lower bound. | |
Point | myUpperBoundCopy |
Copy of the image lower bound. | |
Point | myInfinity |
Value to act as a +infinity value. | |
std::vector< Dimension > | myPeriodicityIndex |
Index of the periodic dimensions. | |
Point | myDomainExtent |
Domain extent. | |
Aim: Implementation of the linear in time Voronoi map construction.
Description of template class 'VoronoiMapComplete'
The algorithm uses a seperable process to construct Voronoi maps which has been described in [85] [33]. Along periodic dimensions, the algorithm is adapted following [34], and uses the co-cyclic site approach from [40].
Given a domain and a point predicate, an instance returns, for each point in the domain, the collection of closest points for which the predicate is false. Following Computational Geometry terminology, points for which the predicate is false are "sites" for the Voronoi map construction.
If a point is equi-distant to several sites, all sites will be attached to that point (contrary to the class VoronoiMap that will only keep one of them). This implies a computational overhead:
See nD Volumetric Analysis using Separable Processes documnetation page.
By default, the domain is considered non-periodic but per-dimension periodicity can be specified in the constructor. When the domain has periodic dimensions, the closest point coordinates B
to a given point A
may not be between the lower and upper bounds of the domain, in such a way that the non-periodic distance between A
and B
is equal to their distance considering the periodicity.
The metric is specified by a model of concepts::CSeparableMetric (for instance, any instance of ExactPredicateLpSeparableMetric or InexactPredicateLpSeparableMetric). If the separable metric has a complexity of O(h) for its "hiddenBy" predicate, the overall Voronoi construction algorithm is in \( O(f.h.d.n^d)\) for \( n^d\) domains (see class constructor). For Euclidean the \( l_2\) metric, the overall computation is in \( O(f.d.n^d)\), which is optimal.
If DGtal has been built with OpenMP support (WITH_OPENMP flag set to "true"), the computation is done in parallel (multithreaded) in an optimal way: on p processors, expected runtime is in \( O(f.h.d.n^d / p)\).
This class is a model of concepts::CConstImage.
TSpace | type of Digital Space (model of concepts::CSpace). |
TPointPredicate | point predicate returning true for points from which we compute the distance (model of concepts::CPointPredicate) |
TSeparableMetric | a model of concepts::CSeparableMetric |
TImageContainer | any model of concepts::CImage to store the VoronoiMap (default: ImageContainerBySTLVector). The space of the image container and the TSpace should match. Furthermore the container value type must be a random access container on TSpace::Vector. Lastly, the domain of the container must be HyperRectDomain. |
Definition at line 135 of file VoronoiMapComplete.h.
typedef Space::Point::Coordinate DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Abscissa |
Definition at line 179 of file VoronoiMapComplete.h.
typedef OutputImage::ConstRange DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::ConstRange |
Definition of the image value type.
Definition at line 188 of file VoronoiMapComplete.h.
typedef Space::Dimension DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Dimension |
Definition at line 177 of file VoronoiMapComplete.h.
typedef TImageContainer::Domain DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Domain |
Definition of the underlying domain type.
Definition at line 167 of file VoronoiMapComplete.h.
typedef DGtal::int64_t DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::IntegerLong |
Large integer type for SeparableMetricHelper construction.
Definition at line 173 of file VoronoiMapComplete.h.
typedef TImageContainer DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::OutputImage |
Type of resulting image.
Definition at line 182 of file VoronoiMapComplete.h.
typedef std::array< bool, Space::dimension > DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::PeriodicitySpec |
Periodicity specification type.
Definition at line 196 of file VoronoiMapComplete.h.
typedef Space::Point DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Point |
Definition at line 176 of file VoronoiMapComplete.h.
typedef TPointPredicate DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::PointPredicate |
Copy of the point predicate type.
Definition at line 164 of file VoronoiMapComplete.h.
typedef VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric,TImageContainer > DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Self |
Self type.
Definition at line 192 of file VoronoiMapComplete.h.
typedef TSeparableMetric DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::SeparableMetric |
Definition of the separable metric type.
Definition at line 170 of file VoronoiMapComplete.h.
typedef Space::Size DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Size |
Definition at line 178 of file VoronoiMapComplete.h.
typedef TSpace DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Space |
Copy of the space type.
Definition at line 161 of file VoronoiMapComplete.h.
typedef OutputImage::Value DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Value |
Definition of the image value type.
Definition at line 185 of file VoronoiMapComplete.h.
typedef Space::Vector DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Vector |
Definition at line 175 of file VoronoiMapComplete.h.
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::VoronoiMapComplete | ( | ConstAlias< Domain > | aDomain, |
ConstAlias< PointPredicate > | predicate, | ||
ConstAlias< SeparableMetric > | aMetric ) |
Constructor in the non-periodic case.
This constructor computes the Voronoi Map of a set of point sites using a SeparableMetric metric, on a non-periodic domain.
The method associates to each point satisfying the foreground predicate, the closest site for which the predicate is false. This algorithm is \( O(h.d.|domain size|)\) if the separable metric "hiddenBy" predicate is in \( O(h)\).
aDomain | a pointer to the (hyper-rectangular) domain on which the computation is performed. |
predicate | a pointer to the point predicate to define the Voronoi sites (false points). |
aMetric | a pointer to the separable metric instance. |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::VoronoiMapComplete | ( | ConstAlias< Domain > | aDomain, |
ConstAlias< PointPredicate > | predicate, | ||
ConstAlias< SeparableMetric > | aMetric, | ||
PeriodicitySpec const & | aPeriodicitySpec ) |
Constructor with periodicity specification.
This constructor computes the Voronoi Map of a set of point sites using a SeparableMetric metric, on a domain with specified periodicity.
The method associates to each point satisfying the foreground predicate, the closest site for which the predicate is false. This algorithm is \( O(h.d.|domain size|)\) if the separable metric "hiddenBy" predicate is in \( O(h)\).
aDomain | a pointer to the (hyper-rectangular) domain on which the computation is performed. |
predicate | a pointer to the point predicate to define the Voronoi sites (false points). |
aMetric | a pointer to the separable metric instance. |
aPeriodicitySpec | an array of size equal to the space dimension where the i-th value is true if the i-th dimension of the space is periodic, false otherwise. |
|
default |
Default destructor
|
delete |
Disabling default constructor.
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CImage< TImageContainer >) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CPointPredicate< TPointPredicate >) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSeparableMetric< TSeparableMetric >) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< HyperRectDomain< TSpace >, typename TImageContainer::Domain >::value) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< std::set< typename TSpace::Vector >, typename TImageContainer::Value >::value) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< TSpace, typename TImageContainer::Domain::Space >::value) | ) |
DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value) | ) |
Both Space points and PointPredicate points must be the same.
|
private |
Compute the Voronoi Map of a set of point sites using a SeparableMetric metric. The method associates to each point satisfying the foreground predicate, the closest site for which the predicate is false. This algorithm is O(h.d.|domain size|).
|
private |
Given a voronoi map valid at dimension dim-1, this method updates the map to make it consistent at dimension dim along the 1D span starting at row along the dimension dim.
[in] | row | starting point of the 1D process. |
[in] | dim | dimension of the update. |
|
private |
Compute the other steps of the separable Voronoi map.
[in] | dim | the dimension to process |
|
inline |
Returns a const range on the Voronoi map values.
Definition at line 283 of file VoronoiMapComplete.h.
References DGtal::ImageContainerBySTLVector< TDomain, TValue >::constRange(), and DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myImagePtr.
Referenced by TEST_CASE().
|
inline |
Returns a reference (const) to the Voronoi map domain.
Definition at line 274 of file VoronoiMapComplete.h.
References DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myDomainPtr.
|
inline |
Periodicity specification.
Definition at line 311 of file VoronoiMapComplete.h.
References DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myPeriodicitySpec.
|
inline |
Periodicity specification along one dimensions.
[in] | n | the dimension index. |
true
if the n-th dimension is periodic, false
otherwise. Definition at line 321 of file VoronoiMapComplete.h.
References DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myPeriodicitySpec.
|
inline |
Definition at line 302 of file VoronoiMapComplete.h.
References DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myMetricPtr.
|
inline |
Access to a Voronoi value (a.k.a. vector to the closest site) at a point.
aPoint | the point to probe. |
Definition at line 294 of file VoronoiMapComplete.h.
References aPoint(), and DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myImagePtr.
|
default |
Assignment operator from another Voronoi map.
aOtherVoronoiMap | another instance of Self |
|
private |
Project a coordinate into the domain, taking into account the periodicity.
aCoordinate | the coordinate. |
aDim | dimension of the coordinate. |
Point DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::projectPoint | ( | Point | aPoint | ) | const |
Project point coordinates into the domain, taking into account the periodicity.
aPoint | the point to project |
void DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::selfDisplay | ( | std::ostream & | out | ) | const |
Self Display method.
out | output stream |
|
private |
Domain extent.
Definition at line 409 of file VoronoiMapComplete.h.
|
private |
Pointer to the computation domain.
Definition at line 391 of file VoronoiMapComplete.h.
Referenced by DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::domain().
|
protected |
Voronoi map image.
Definition at line 417 of file VoronoiMapComplete.h.
Referenced by DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::constRange(), and DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()().
|
private |
Value to act as a +infinity value.
Definition at line 403 of file VoronoiMapComplete.h.
|
private |
Copy of the image lower bound.
Definition at line 397 of file VoronoiMapComplete.h.
|
protected |
Pointer to the separable metric instance.
Definition at line 414 of file VoronoiMapComplete.h.
Referenced by DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::metric().
|
private |
Index of the periodic dimensions.
Definition at line 406 of file VoronoiMapComplete.h.
|
protected |
Periodicity along each dimension.
Definition at line 420 of file VoronoiMapComplete.h.
Referenced by DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::getPeriodicitySpec(), and DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::isPeriodic().
|
private |
Pointer to the point predicate.
Definition at line 394 of file VoronoiMapComplete.h.
|
private |
Copy of the image lower bound.
Definition at line 400 of file VoronoiMapComplete.h.