DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | Friends
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator Class Reference

#include <GreedyDecomposition.h>

Public Member Functions

 SegmentIterator (const GreedyDecomposition< TSegment > *aDec, const typename TSegment::ConstIterator &aBack, const TSegment &aSegment)
 SegmentIterator (const SegmentIterator &aOther)
SegmentIteratoroperator= (const SegmentIterator &aOther)
 ~SegmentIterator ()
Segment operator* () const
Segment get () const
SegmentIteratoroperator++ ()
void next ()
bool intersectNext () const
bool intersectPrevious () const
const Iterator getFront () const
const Iterator getBack () const
bool operator== (const SegmentIterator &aOther) const
bool operator!= (const SegmentIterator &aOther) const

Private Member Functions

void longestSegment ()
bool doesIntersectNext (const Iterator &it)

Private Attributes

const GreedyDecomposition
< TSegment > * 
myDec
Iterator myFront
Iterator myBack
Segment mySegment
bool myFlagIntersectNext
bool myFlagIntersectPrevious

Friends

class GreedyDecomposition< TSegment >

Detailed Description

template<typename TSegment>
class DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator

This class is an iterator on a digital curve storing the current segment.

Definition at line 142 of file GreedyDecomposition.h.


Constructor & Destructor Documentation

template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::SegmentIterator ( const GreedyDecomposition< TSegment > *  aDec,
const typename TSegment::ConstIterator &  aBack,
const TSegment &  aSegment 
)
inline

Constructor. Nb: complexity in O(n).

Parameters:
aDeca greedy decomposition of a digital curve
aBackan iterator at the back of the first segment

Constructor. Nb: complexity in O(n).

Parameters:
anIteratoran iterator on the digital curve to decompose

Definition at line 55 of file GreedyDecomposition.ih.

References DGtal::false, DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::longestSegment(), DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myBack, DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myDec, DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFlagIntersectPrevious, DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFront, and DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::mySegment.

: myDec( aDec ),
myFront( aBack ),
myBack( aBack ),
mySegment( aSegment ),
{
if (myBack != myDec->myEnd) { //if at least one element
if (myFront == myDec->myEnd) {//if only one element
mySegment.init(myBack);
} else { //if strictly more than one element
if (myDec->isClosed) { //if processed as closed
//check is the first and last element form a valid segment
Iterator tmpIt = myDec->myEnd; --tmpIt;
Segment tmpSegment; tmpSegment.init(tmpIt);
myFlagIntersectPrevious = tmpSegment.extendForward(myDec->myBegin);
} else { //if processed as open
}
//computation of the longest segment from myBack
this->longestSegment();
}
}
}
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::SegmentIterator ( const SegmentIterator aOther)
inline

Copy constructor.

Parameters:
otherthe iterator to clone.

Definition at line 100 of file GreedyDecomposition.ih.

: myDec( aOther.myDec ),
myFront( aOther.myFront ),
myBack( aOther.myBack ),
mySegment( aOther.mySegment ),
myFlagIntersectNext( aOther.myFlagIntersectNext ),
myFlagIntersectPrevious( aOther.myFlagIntersectPrevious )
{
}
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::~SegmentIterator ( )
inline

Destructor. Does nothing.

Destructor. Does nothing

Definition at line 139 of file GreedyDecomposition.ih.

{
}

Member Function Documentation

template<typename TSegment >
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::doesIntersectNext ( const Iterator it)
inlineprivate

Checks if the current segment intersects the next one (if exists).

Parameters:
ita given iterator

Checks if the current segment intersects the next one (if exists).

Definition at line 213 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::init().

{
Segment tmpSegment;
Iterator previousIt = it; --previousIt;
tmpSegment.init(previousIt);
return tmpSegment.extendForward(it);
}
template<typename TSegment >
TSegment DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::get ( ) const
inline
Returns:
the current segment.

Definition at line 164 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

{
return mySegment;
}
template<typename TSegment >
const TSegment::ConstIterator DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::getBack ( ) const
inline
Returns:
an iterator of a digital curve at the back of the segment.
an iterator of the digital curve at the back of the segment.

Definition at line 304 of file GreedyDecomposition.ih.

Referenced by DGtal::DSSLengthEstimator< TConstIterator >::init().

{
return myBack;
}
template<typename TSegment >
const TSegment::ConstIterator DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::getFront ( ) const
inline
Returns:
an iterator of a digital curve at the front of the segment.
an iterator of the digital curve at the front of the segment.

Definition at line 292 of file GreedyDecomposition.ih.

Referenced by DGtal::DSSLengthEstimator< TConstIterator >::init().

{
return myFront;
}
template<typename TSegment >
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::intersectNext ( ) const
inline
Returns:
TRUE if the current segment intersects the next one, FALSE otherwise.

Definition at line 190 of file GreedyDecomposition.ih.

{
}
template<typename TSegment >
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::intersectPrevious ( ) const
inline
Returns:
TRUE if the current segment intersects the previous one, FALSE otherwise.

Definition at line 202 of file GreedyDecomposition.ih.

template<typename TSegment >
void DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::longestSegment ( )
inlineprivate

Computes the longest possible segment from two consecutive points. Nb: complexity in O(n).

Computes the longest possible segment from two consecutive points.

Definition at line 228 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

Referenced by DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::SegmentIterator().

{
//while my segment can be extended at the front
while ( (myFront != myDec->myEnd) &&
(mySegment.extendForward(myFront)) ) {
}
//if the end of the sequence is reached
if (myFront == myDec->myEnd) {
//if the sequence is processed as a closed one
//the first element of the sequence is added if possible
if (myDec->isClosed) {
myFlagIntersectNext = mySegment.extendForward(myDec->myBegin);
} else {
}
} else {
//otherwise
}
}
template<typename TSegment >
void DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::next ( )
inline

Goes to the next segment on the contour (if possible). Nb: complexity in O(n).

Goes to the next segment on a digital curve.

Definition at line 262 of file GreedyDecomposition.ih.

References DGtal::longestSegment().

{
if (myFront != myDec->myEnd) { //if not the end
--myBack;
} else {
}
this->longestSegment();
} else { //if the front of the segment is at the end of the sequence
myBack = myDec->myEnd;
}
}
template<typename TSegment >
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::operator!= ( const SegmentIterator aOther) const
inline

Inequality operator.

Parameters:
aOtherthe iterator to compare with
Returns:
'true' if their current positions differs. (different front and back iterators)

Inequality operator.

Parameters:
aOtherthe iterator to compare with
Returns:
'true' if their current positions differs.

Definition at line 337 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myBack, and DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFront.

{
return ( (myFront != aOther.myFront)||(myBack != aOther.myBack) );
}
template<typename TSegment >
TSegment DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::operator* ( ) const
inline
Returns:
the current segment
the current segment.

Definition at line 153 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

{
return mySegment;
}
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator & DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::operator++ ( )
inline

Pre-increment. Goes to the next segment on the contour (if possible). Nb: complexity in O(n).

Pre-increment. Goes to the next segment on a digital curve.

Definition at line 177 of file GreedyDecomposition.ih.

{
this->next();
return *this;
}
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator & DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::operator= ( const SegmentIterator other)
inline

Assignment.

Parameters:
aOtherthe iterator to copy.
Returns:
a reference on 'this'.

Assignment.

Parameters:
otherthe iterator to copy.
Returns:
a reference on 'this'.

Definition at line 119 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

{
if ( this != &other )
{
myDec = other.myDec;
myFront = other.myFront;
myBack = other.myBack;
mySegment = other.mySegment;
myFlagIntersectNext = other.myFlagIntersectNext;
myFlagIntersectPrevious = other.myFlagIntersectPrevious;
}
return *this;
}
template<typename TSegment >
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::operator== ( const SegmentIterator aOther) const
inline

Equality operator.

Parameters:
aOtherthe iterator to compare with
Returns:
'true' if their current positions coincide. (same front and back iterators)

Equality operator.

Parameters:
aOtherthe iterator to compare with
Returns:
'true' if their current positions coincide.

Definition at line 321 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myBack, and DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFront.

{
return ( (myFront == aOther.myFront)&&(myBack == aOther.myBack) );
}

Friends And Related Function Documentation

template<typename TSegment>
friend class GreedyDecomposition< TSegment >
friend

Definition at line 191 of file GreedyDecomposition.h.


Field Documentation

template<typename TSegment>
Iterator DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myBack
private
template<typename TSegment>
const GreedyDecomposition<TSegment>* DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myDec
private

Pointer to the decomposition

Definition at line 151 of file GreedyDecomposition.h.

Referenced by DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::SegmentIterator().

template<typename TSegment>
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFlagIntersectNext
private

A flag equal to TRUE if the current segment intersects the next one, FALSE otherwise (and FALSE if the current segment is the last one)

Definition at line 178 of file GreedyDecomposition.h.

template<typename TSegment>
bool DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFlagIntersectPrevious
private

A flag equal to TRUE if the current segment intersects the previous one, FALSE otherwise (and FALSE if the current segment is the first one)

Definition at line 185 of file GreedyDecomposition.h.

Referenced by DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::SegmentIterator().

template<typename TSegment>
Iterator DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::myFront
private
template<typename TSegment>
Segment DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::mySegment
private

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