DGtal  1.5.beta
DGtal::StabbingLineComputer< TConstIterator > Class Template Reference

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

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

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();
StabbingLineComputer<Curve::IncidentPointsRange::ConstIterator> s;
//extension
s.init( r.begin() );
while ( ( s.end() != itEnd )
&&( s.extendFront() ) ) {}
MyDigitalSurface::ConstIterator ConstIterator
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

◆ ConstIterator

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

Definition at line 98 of file StabbingLineComputer.h.

◆ Pair

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

Definition at line 103 of file StabbingLineComputer.h.

◆ Point

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

Definition at line 104 of file StabbingLineComputer.h.

◆ Preimage

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

Definition at line 113 of file StabbingLineComputer.h.

◆ PreimagePtr

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

Definition at line 114 of file StabbingLineComputer.h.

◆ Reverse

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

Definition at line 100 of file StabbingLineComputer.h.

◆ Self

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

Definition at line 99 of file StabbingLineComputer.h.

◆ StraightLine

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

Definition at line 112 of file StabbingLineComputer.h.

Constructor & Destructor Documentation

◆ StabbingLineComputer() [1/2]

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

Constructor.

◆ StabbingLineComputer() [2/2]

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

Copy constructor.

Parameters
otherthe object to clone.

◆ ~StabbingLineComputer()

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

Destructor.

Member Function Documentation

◆ begin()

template<typename TConstIterator >
ConstIterator DGtal::StabbingLineComputer< TConstIterator >::begin ( ) const
Returns
segment begin iterator.

Referenced by testStabbingLineComputer().

◆ BOOST_STATIC_ASSERT()

template<typename TConstIterator >
DGtal::StabbingLineComputer< TConstIterator >::BOOST_STATIC_ASSERT ( (concepts::ConceptUtils::SameType< typename Pair::first_type, typename Pair::second_type > ::value)  )

◆ className()

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.

◆ end()

template<typename TConstIterator >
ConstIterator DGtal::StabbingLineComputer< TConstIterator >::end ( ) const
Returns
segment end iterator.

Referenced by testStabbingLineComputer().

◆ extendBack()

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

Backward extension of the segment.

Returns
'true' if the segment is extended and 'false' otherwise.

Referenced by testStabbingLineComputer().

◆ extendFront()

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

Forward extension of the segment.

Returns
'true' if the segment is extended and 'false' otherwise.

Referenced by testStabbingLineComputer().

◆ getParameters()

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

Referenced by testStabbingLineComputer().

◆ getPreimage()

template<typename TConstIterator >
PreimagePtr DGtal::StabbingLineComputer< TConstIterator >::getPreimage ( ) const
Returns
the preimage

◆ getReverse()

template<typename TConstIterator >
Reverse DGtal::StabbingLineComputer< TConstIterator >::getReverse ( ) const
Returns
a default-constructed instance of Reverse.

Referenced by testStabbingLineComputer().

◆ getSelf()

template<typename TConstIterator >
Self DGtal::StabbingLineComputer< TConstIterator >::getSelf ( ) const
Returns
a default-constructed instance of Self

◆ init()

template<typename TConstIterator >
void DGtal::StabbingLineComputer< TConstIterator >::init ( const ConstIterator anIt)

Segment initialization

Parameters
anItany iterator

Referenced by main(), and testStabbingLineComputer().

◆ isClockwiseOriented()

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

◆ isConcave()

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'

◆ isConvex()

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'

◆ isExtendableBack()

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

Backward extension test.

Returns
'true' if the segment can be extended and 'false' otherwise.

◆ isExtendableFront()

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

Forward extension test.

Returns
'true' if the segment can be extended and 'false' otherwise.

Referenced by testStabbingLineComputer().

◆ isOppositeEndConcave()

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'

◆ isOppositeEndConvex()

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'

◆ isValid()

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.

Referenced by testStabbingLineComputer().

◆ Lf()

template<typename TConstIterator >
Point DGtal::StabbingLineComputer< TConstIterator >::Lf ( ) const
Returns
first lower leaning point.

Referenced by testStabbingLineComputer().

◆ Ll()

template<typename TConstIterator >
Point DGtal::StabbingLineComputer< TConstIterator >::Ll ( ) const
Returns
last lower leaning point.

Referenced by testStabbingLineComputer().

◆ operator!=()

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.

◆ operator=()

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

Assignment.

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

◆ operator==()

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

◆ projects()

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

◆ selfDisplay()

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.

◆ Uf()

template<typename TConstIterator >
Point DGtal::StabbingLineComputer< TConstIterator >::Uf ( ) const
Returns
first upper leaning point.

Referenced by testStabbingLineComputer().

◆ Ul()

template<typename TConstIterator >
Point DGtal::StabbingLineComputer< TConstIterator >::Ul ( ) const
Returns
last upper leaning point.

Referenced by testStabbingLineComputer().

Field Documentation

◆ myBegin

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

segment begin iterator.

Definition at line 348 of file StabbingLineComputer.h.

◆ myEnd

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

segment end iterator.

Definition at line 352 of file StabbingLineComputer.h.

◆ myFlagIsCW

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.

◆ myFlagIsInit

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.

◆ myPreimagePtr

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: