DGtal  0.9.3beta
Public Types | Public Member Functions | Private Attributes
DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor > Class Template Reference

#include <DGtal/geometry/tools/MelkmanConvexHull.h>

Inheritance diagram for DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >:
[legend]
Collaboration diagram for DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >:
[legend]

Public Types

typedef MelkmanConvexHull< TPoint, TOrientationFunctor > Self
 
typedef TPoint Point
 
typedef TOrientationFunctor Functor
 
typedef PredicateFromOrientationFunctor2< Functor, false, false > BackwardPredicate
 
typedef PredicateFromOrientationFunctor2< Functor, true, false > ForwardPredicate
 
typedef std::deque< Point >::const_iterator ConstIterator
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::COrientationFunctor2< Functor >))
 
 BOOST_STATIC_ASSERT ((boost::is_same< Point, typename Functor::Point >::value))
 
 MelkmanConvexHull (Alias< Functor > aFunctor)
 
 MelkmanConvexHull ()
 
void add (const Point &aPoint)
 
ConstIterator begin () const
 
ConstIterator end () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
Selfoperator= (const Self &mch)
 
const Pointoperator[] (unsigned int i) const
 
unsigned int size () const
 
void clear ()
 
void reverse ()
 

Private Attributes

std::deque< PointmyContainer
 
BackwardPredicate myBackwardPredicate
 
ForwardPredicate myForwardPredicate
 
Functor myDefaultFunctor
 
Point myFirstPoint
 

Detailed Description

template<typename TPoint, typename TOrientationFunctor>
class DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >

Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of a simple polygonal line (without self-intersection) [Melkman, 1987: [47]].

This algorithm is based on a deque, which stores the vertices of the convex hull (for convenience, the first and last vertex contained in the deque are the same point). Since we assume that the input points form a simple polygonal line, a new point cannot be located in the cone formed by the first and last edges of the current convex hull. As a consequence, it is enough to update the convex hull by a Graham scan from the front and/or from the back of the deque; it is never required to remove/insert points in the middle of the container. See Convex hull and alpha-shape in the plane for more details.

See also
functions::Hull2D::updateHullWithAdaptedStack

Note that if the input points do not form a simple polygonal line, the behavior is not defined.

Template Parameters
TPointa model of point
TOrientationFunctora model of COrientationFunctor2 (whose inner type 'Point' match to 'TPoint')
Examples:
geometry/tools/exampleConvexHull2D.cpp.

Definition at line 89 of file MelkmanConvexHull.h.

Member Typedef Documentation

template<typename TPoint, typename TOrientationFunctor>
typedef PredicateFromOrientationFunctor2<Functor,false,false> DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::BackwardPredicate

Type of predicate devoted to the backward scan

Definition at line 114 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
typedef std::deque<Point>::const_iterator DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::ConstIterator

Type of iterator on the convex hull vertices

Definition at line 123 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
typedef PredicateFromOrientationFunctor2<Functor,true,false> DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::ForwardPredicate

Type of predicate devoted to the forward scan

Definition at line 118 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
typedef TOrientationFunctor DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::Functor

Type of orientation functor

Definition at line 106 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
typedef TPoint DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::Point

Type of point

Definition at line 102 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
typedef MelkmanConvexHull<TPoint, TOrientationFunctor> DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::Self

Self type

Definition at line 97 of file MelkmanConvexHull.h.

Constructor & Destructor Documentation

template<typename TPoint, typename TOrientationFunctor>
DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::MelkmanConvexHull ( Alias< Functor aFunctor)
template<typename TPoint, typename TOrientationFunctor>
DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::MelkmanConvexHull ( )

Member Function Documentation

template<typename TPoint, typename TOrientationFunctor>
void DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::add ( const Point aPoint)

Consider a new point and possibly update the convex hull.

Parameters
aPointan extra point
Postcondition
if aPoint lies outside the current convex hull, this hull is then updated with aPoint as a vertex.
template<typename TPoint, typename TOrientationFunctor>
ConstIterator DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::begin ( ) const

Begin iterator

Returns
either a const iterator pointing past-the-end if the container is empty or a const iterator pointing after the first point otherwise. Rationale: we do not want to iterate over the same point, duplicated at the begin and at the end of the container.
template<typename TPoint, typename TOrientationFunctor>
DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::BOOST_CONCEPT_ASSERT ( (concepts::COrientationFunctor2< Functor >)  )
template<typename TPoint, typename TOrientationFunctor>
DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::BOOST_STATIC_ASSERT ( (boost::is_same< Point, typename Functor::Point >::value)  )
template<typename TPoint, typename TOrientationFunctor>
void DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::clear ( )

clear the current content of the convex hull.

template<typename TPoint, typename TOrientationFunctor>
ConstIterator DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::end ( ) const

End iterator

Returns
a const iterator to the end of the container
template<typename TPoint, typename TOrientationFunctor>
bool DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TPoint, typename TOrientationFunctor>
Self& DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::operator= ( const Self mch)

Assignement Operator

Parameters
mchthe object to copy.
Returns
a reference on 'this'.
template<typename TPoint, typename TOrientationFunctor>
const Point& DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::operator[] ( unsigned int  i) const
Returns
the i-th point of the convex hull queue.
Parameters
ithe index of the considered point.
template<typename TPoint, typename TOrientationFunctor>
void DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::reverse ( )

Reverse the convex hull container allowing to change the order of adding points from the front or from the back in reference to an input contour. Such a reverse is important to avoid wrong convexhull and to allow convex hull extension from two directions.

template<typename TPoint, typename TOrientationFunctor>
void DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.
template<typename TPoint, typename TOrientationFunctor>
unsigned int DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::size ( ) const
Returns
the nomber of points constituing the convex hull.

Field Documentation

template<typename TPoint, typename TOrientationFunctor>
BackwardPredicate DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::myBackwardPredicate
private

Predicate devoted to the backward scan

Definition at line 213 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
std::deque<Point> DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::myContainer
private

Deque container, which stores the vertices of the convex hull NB: the first and last point is the same.

Definition at line 209 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
Functor DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::myDefaultFunctor
private

Used to define a default functor to allow default constructor

Definition at line 221 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
Point DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::myFirstPoint
private

first point used to reverse the convexhull container.

Definition at line 225 of file MelkmanConvexHull.h.

template<typename TPoint, typename TOrientationFunctor>
ForwardPredicate DGtal::MelkmanConvexHull< TPoint, TOrientationFunctor >::myForwardPredicate
private

Predicate devoted to the forward scan

Definition at line 217 of file MelkmanConvexHull.h.


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