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

#include <DGtal/geometry/curves/StabbingLineComputer.h>

Collaboration diagram for DGtal::StabbingLineComputer< TConstIterator >:
[legend]

Public Types

typedef TConstIterator ConstIterator
 
typedef StabbingLineComputer< ConstIteratorSelf
 
typedef StabbingLineComputer< ReverseIterator< ConstIterator > > Reverse
 
typedef IteratorCirculatorTraits< ConstIterator >::Value Pair
 
typedef Pair::first_type Point
 
typedef StraightLineFrom2Points< PointStraightLine
 
typedef Preimage2D< StraightLinePreimage
 
typedef CowPtr< PreimagePreimagePtr
 

Public Member Functions

 BOOST_STATIC_ASSERT ((concepts::ConceptUtils::SameType < typename Pair::first_type, typename Pair::second_type > ::value))
 
 StabbingLineComputer ()
 
 StabbingLineComputer (const Self &other)
 
Selfoperator= (const Self &other)
 
 ~StabbingLineComputer ()
 
bool operator== (const Self &other) const
 
bool operator!= (const Self &other) const
 
Self getSelf () const
 
Reverse getReverse () const
 
bool isValid () const
 
ConstIterator begin () const
 
ConstIterator end () const
 
Point Uf () const
 
Point Ul () const
 
Point Lf () const
 
Point Ll () const
 
PreimagePtr getPreimage () const
 
bool isClockwiseOriented () const
 
void getParameters (double &alpha, double &beta, double &gamma) const
 
void projects (double &x, double &y, const double &alpha, const double &beta, const double &gamma) const
 
void init (const ConstIterator &anIt)
 
bool extendFront ()
 
bool isExtendableFront ()
 
bool isConcave ()
 
bool isConvex ()
 
bool extendBack ()
 
bool isExtendableBack ()
 
bool isOppositeEndConcave ()
 
bool isOppositeEndConvex ()
 
void selfDisplay (std::ostream &out) const
 
std::string className () const
 

Private Attributes

ConstIterator myBegin
 
ConstIterator myEnd
 
PreimagePtr myPreimagePtr
 
bool myFlagIsInit
 
bool myFlagIsCW
 

Detailed Description

template<typename TConstIterator>
class DGtal::StabbingLineComputer< TConstIterator >

Aim: On-line recognition of a digital straight segment (DSS) defined as a sequence of connected grid edges such that there is at least one straight line that separates the centers of the two incident pixels of each grid edge.

Note
On either side, the pixels centers are included. The class of segments considered here is thus larger than the one considered in ArithmeticalDSSComputer (the equivalence would be true if the pixels centers were included on one side but excluded on the other side)

The algorithm computes and maintains the preimage of the whole set of separating straight lines in linear time using Preimage2D and the algorithm of O'Rourke (1981).

Note
Joseph O'Rourke, An on-line algorithm for fitting straight lines between data ranges, Communications of the ACM, Volume 24, Issue 9, September 1981, 574–578.

This class is a model of the concept CBidirectionalSegmentComputer.

It should be used with the Curve object (defined in StdDefs.h) and its IncidentPointsRange as follows:

Curve::IncidentPointsRange r = c.getIncidentPointsRange();
Curve::IncidentPointsRange::ConstIterator itEnd (r.end());
StabbingLineComputer<Curve::IncidentPointsRange::ConstIterator> s;
//extension
s.init( r.begin() );
while ( ( s.end() != itEnd )
&&( s.extendFront() ) ) {}
Template Parameters
TConstIteratorConstIterator type on STL pairs of 2D points
See also
testStabbingLineComputer.cpp exampleStabbingLineComputer.cpp Preimage2D ArithmeticalDSSComputer

Definition at line 92 of file StabbingLineComputer.h.

Member Typedef Documentation

template<typename TConstIterator>
typedef TConstIterator DGtal::StabbingLineComputer< TConstIterator >::ConstIterator

Definition at line 98 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef IteratorCirculatorTraits<ConstIterator>::Value DGtal::StabbingLineComputer< TConstIterator >::Pair

Definition at line 103 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef Pair::first_type DGtal::StabbingLineComputer< TConstIterator >::Point

Definition at line 104 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef Preimage2D<StraightLine> DGtal::StabbingLineComputer< TConstIterator >::Preimage

Definition at line 113 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef CowPtr<Preimage> DGtal::StabbingLineComputer< TConstIterator >::PreimagePtr

Definition at line 114 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef StabbingLineComputer<ReverseIterator<ConstIterator> > DGtal::StabbingLineComputer< TConstIterator >::Reverse

Definition at line 100 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef StabbingLineComputer<ConstIterator> DGtal::StabbingLineComputer< TConstIterator >::Self

Definition at line 99 of file StabbingLineComputer.h.

template<typename TConstIterator>
typedef StraightLineFrom2Points<Point> DGtal::StabbingLineComputer< TConstIterator >::StraightLine

Definition at line 112 of file StabbingLineComputer.h.

Constructor & Destructor Documentation

template<typename TConstIterator>
DGtal::StabbingLineComputer< TConstIterator >::StabbingLineComputer ( )

Constructor.

template<typename TConstIterator>
DGtal::StabbingLineComputer< TConstIterator >::StabbingLineComputer ( const Self other)

Copy constructor.

Parameters
otherthe object to clone.
template<typename TConstIterator>
DGtal::StabbingLineComputer< TConstIterator >::~StabbingLineComputer ( )

Destructor.

Member Function Documentation

template<typename TConstIterator>
ConstIterator DGtal::StabbingLineComputer< TConstIterator >::begin ( ) const
Returns
segment begin iterator.
template<typename TConstIterator>
DGtal::StabbingLineComputer< TConstIterator >::BOOST_STATIC_ASSERT ( (concepts::ConceptUtils::SameType < typename Pair::first_type, typename Pair::second_type > ::value)  )
template<typename TConstIterator>
std::string DGtal::StabbingLineComputer< TConstIterator >::className ( ) const

Default drawing style object.

Returns
the dyn. alloc. default style for this object.
the style name used for drawing this object.
template<typename TConstIterator>
ConstIterator DGtal::StabbingLineComputer< TConstIterator >::end ( ) const
Returns
segment end iterator.
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::extendBack ( )

Backward extension of the segment.

Returns
'true' if the segment is extended and 'false' otherwise.
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::extendFront ( )

Forward extension of the segment.

Returns
'true' if the segment is extended and 'false' otherwise.
template<typename TConstIterator>
void DGtal::StabbingLineComputer< TConstIterator >::getParameters ( double &  alpha,
double &  beta,
double &  gamma 
) const

Get the parameters of one separating straight line

Parameters
alpha(returned) x-component of the normal
beta(returned) y-component of the normal
gamma(returned) intercept
template<typename TConstIterator>
PreimagePtr DGtal::StabbingLineComputer< TConstIterator >::getPreimage ( ) const
Returns
the preimage
template<typename TConstIterator>
Reverse DGtal::StabbingLineComputer< TConstIterator >::getReverse ( ) const
Returns
a default-constructed instance of Reverse.
template<typename TConstIterator>
Self DGtal::StabbingLineComputer< TConstIterator >::getSelf ( ) const
Returns
a default-constructed instance of Self
template<typename TConstIterator>
void DGtal::StabbingLineComputer< TConstIterator >::init ( const ConstIterator anIt)

Segment initialization

Parameters
anItany iterator
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isClockwiseOriented ( ) const
Returns
'true' if CW, 'false' if CCW
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isConcave ( )

Decide whether the extension of the segment would result in a concave part or not.

Returns
'true' if the extension of the segment results in a concave part and 'false' otherwise.

NB: a true returned value implies that isExtendableFront() returns 'false'

template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isConvex ( )

Decide whether the extension of the segment would result in a convex part or not.

Returns
'true' if the extension of the segment results in a convex part and 'false' otherwise.

NB: a true returned value implies that isExtendableFront() returns 'false'

template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isExtendableBack ( )

Backward extension test.

Returns
'true' if the segment can be extended and 'false' otherwise.
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isExtendableFront ( )

Forward extension test.

Returns
'true' if the segment can be extended and 'false' otherwise.
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isOppositeEndConcave ( )

Decide whether the extension of the segment would result in a concave part or not.

Returns
'true' if the extension of the segment results in a concave part and 'false' otherwise.

NB: a true returned value implies that isExtendableBack() returns 'false'

template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isOppositeEndConvex ( )

Decide whether the extension of the segment would result in a convex part or not.

Returns
'true' if the extension of the segment results in a convex part and 'false' otherwise.

NB: a true returned value implies that isExtendableBack() returns 'false'

template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TConstIterator>
Point DGtal::StabbingLineComputer< TConstIterator >::Lf ( ) const
Returns
first lower leaning point.
template<typename TConstIterator>
Point DGtal::StabbingLineComputer< TConstIterator >::Ll ( ) const
Returns
last lower leaning point.
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::operator!= ( const Self other) const

Difference operator

Parameters
otherthe object to compare with.
Returns
'true' if not equal, 'false' otherwise.
template<typename TConstIterator>
Self& DGtal::StabbingLineComputer< TConstIterator >::operator= ( const Self other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.
template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::operator== ( const Self other) const

Equality operator

Parameters
otherthe object to compare with.
Returns
'true' if equal, 'false' otherwise
template<typename TConstIterator>
void DGtal::StabbingLineComputer< TConstIterator >::projects ( double &  x,
double &  y,
const double &  alpha,
const double &  beta,
const double &  gamma 
) const

Projects the point ( x , y ) onto the straight line of parameters ( alpha , beta , gamma )

Parameters
x(returned) x-coordinate of the point
y(returned) y-coordinate of the point
alphax-component of the direction vector
betay-component of the direction vector
gammaintercept
template<typename TConstIterator>
void DGtal::StabbingLineComputer< TConstIterator >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.
template<typename TConstIterator>
Point DGtal::StabbingLineComputer< TConstIterator >::Uf ( ) const
Returns
first upper leaning point.
template<typename TConstIterator>
Point DGtal::StabbingLineComputer< TConstIterator >::Ul ( ) const
Returns
last upper leaning point.

Field Documentation

template<typename TConstIterator>
ConstIterator DGtal::StabbingLineComputer< TConstIterator >::myBegin
private

segment begin iterator.

Definition at line 348 of file StabbingLineComputer.h.

template<typename TConstIterator>
ConstIterator DGtal::StabbingLineComputer< TConstIterator >::myEnd
private

segment end iterator.

Definition at line 352 of file StabbingLineComputer.h.

template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::myFlagIsCW
private

Flag equal to 'true' if the pairs of points are clockwise oriented, 'false' otherwise.

Definition at line 366 of file StabbingLineComputer.h.

template<typename TConstIterator>
bool DGtal::StabbingLineComputer< TConstIterator >::myFlagIsInit
private

Flag equal to 'true' if the segment contains at least two pairs (the orientation is known) and 'false' otherwise.

Definition at line 361 of file StabbingLineComputer.h.

template<typename TConstIterator>
PreimagePtr DGtal::StabbingLineComputer< TConstIterator >::myPreimagePtr
private

Pointer to the preimage.

Definition at line 356 of file StabbingLineComputer.h.


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