DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Private Attributes
DGtal::FreemanChain< TInteger >::ConstIterator Class Reference

#include <FreemanChain.h>

Collaboration diagram for DGtal::FreemanChain< TInteger >::ConstIterator:
Collaboration graph
[legend]

Public Member Functions

 ConstIterator ()
 ConstIterator (const FreemanChain &aChain, Index n=0)
 ConstIterator (const FreemanChain &aChain, Index n, const Point &XY)
 ConstIterator (const ConstIterator &aOther)
ConstIteratoroperator= (const ConstIterator &other)
 ~ConstIterator ()
const Pointoperator* () const
const Pointget () const
ConstIteratoroperator++ ()
ConstIterator operator++ (int)
void next ()
void nextInLoop ()
Index getPosition () const
const FreemanChaingetChain () const
char getCode () const
ConstIteratoroperator-- ()
ConstIterator operator-- (int)
void previous ()
void previousInLoop ()
bool operator== (const ConstIterator &aOther) const
bool operator!= (const ConstIterator &aOther) const
bool operator< (const ConstIterator &aOther) const

Private Attributes

const FreemanChainmyFc
Index myPos
Point myXY

Detailed Description

template<typename TInteger>
class DGtal::FreemanChain< TInteger >::ConstIterator

This class represents an iterator on points defined by freeman chain, storing the current coordinate.

Definition at line 138 of file FreemanChain.h.


Constructor & Destructor Documentation

template<typename TInteger>
DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator ( )
inline

Default Constructor. The object is not valid.

Definition at line 162 of file FreemanChain.h.

: myFc( NULL ), myPos( 0 )
{ }
template<typename TInteger >
DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator ( const FreemanChain aChain,
Index  n = 0 
)
inline
template<typename TInteger>
DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator ( const FreemanChain aChain,
Index  n,
const Point XY 
)
inline

Constructor. It is the user's responsability to make sure that the data's are consistent. No verification is performed.

Nb: complexity in O(1).

Parameters:
chaina Freeman chain,
nthe position in chain).
XYthe point corresponding to the 'n'-th position of 'chain'.

Definition at line 187 of file FreemanChain.h.

: myFc( &aChain ), myPos( n ), myXY ( XY )
{ }
template<typename TInteger>
DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator ( const ConstIterator aOther)
inline

Copy constructor.

Parameters:
otherthe iterator to clone.

Definition at line 195 of file FreemanChain.h.

: myFc( aOther.myFc ), myPos( aOther.myPos ), myXY( aOther.myXY )
{ }
template<typename TInteger>
DGtal::FreemanChain< TInteger >::ConstIterator::~ConstIterator ( )
inline

Destructor. Does nothing.

Definition at line 209 of file FreemanChain.h.

{ }

Member Function Documentation

template<typename TInteger>
const Point& DGtal::FreemanChain< TInteger >::ConstIterator::get ( ) const
inline
Returns:
the current coordinates.

Definition at line 227 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::myXY.

{
return myXY;
}
template<typename TInteger>
const FreemanChain* DGtal::FreemanChain< TInteger >::ConstIterator::getChain ( ) const
inline
Returns:
the associated Freeman chain.

Definition at line 276 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::myFc.

Referenced by DGtal::CombinatorialDSS< TConstIterator, TInteger >::init().

{
return myFc;
}
template<typename TInteger>
char DGtal::FreemanChain< TInteger >::ConstIterator::getCode ( ) const
inline
template<typename TInteger>
Index DGtal::FreemanChain< TInteger >::ConstIterator::getPosition ( ) const
inline
template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::next ( )
inline

Goes to the next point on the chain.

Definition at line 90 of file FreemanChain.ih.

References DGtal::FreemanChain< TInteger >::chain.

Referenced by DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator(), DGtal::FreemanChain< TInteger >::findQuadrantChange(), DGtal::FreemanChain< TInteger >::findQuadrantChange4(), DGtal::FreemanChain< TInteger >::innerContour(), and DGtal::FreemanChain< TInteger >::ConstIterator::operator++().

{
if ( myPos < myFc->chain.size() )
{
switch ( myFc->code( myPos ) )
{
case '0': (myXY.at(0))++; break;
case '1': (myXY.at(1))++; break;
case '2': (myXY.at(0))--; break;
case '3': (myXY.at(1))--; break;
}
++myPos;
} else ++myPos;
}
template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::nextInLoop ( )
inline

Goes to the next point on the chain as if on a loop.

Definition at line 110 of file FreemanChain.ih.

References DGtal::FreemanChain< TInteger >::chain.

Referenced by DGtal::FreemanChain< TInteger >::ccwLoops(), and DGtal::FreemanChain< TInteger >::cleanOuterSpikes().

{
if ( myPos < myFc->chain.size() )
{
switch ( myFc->code( myPos ) )
{
case '0': (myXY.at(0))++; break;
case '1': (myXY.at(1))++; break;
case '2': (myXY.at(0))--; break;
case '3': (myXY.at(1))--; break;
}
myPos = ( myPos + 1 ) % myFc->chain.size();
}
}
template<typename TInteger>
bool DGtal::FreemanChain< TInteger >::ConstIterator::operator!= ( const ConstIterator aOther) const
inline

Inequality operator.

Parameters:
aOtherthe iterator to compare with (must be defined on the same chain).
Returns:
'true' if their current positions differs.

Definition at line 350 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::myFc, and DGtal::FreemanChain< TInteger >::ConstIterator::myPos.

{
ASSERT( myFc == aOther.myFc );
return myPos != aOther.myPos;
}
template<typename TInteger>
const Point& DGtal::FreemanChain< TInteger >::ConstIterator::operator* ( ) const
inline
Returns:
the current coordinates.

Definition at line 219 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::myXY.

{
return myXY;
}
template<typename TInteger>
ConstIterator& DGtal::FreemanChain< TInteger >::ConstIterator::operator++ ( )
inline

Pre-increment. Goes to the next point on the chain.

Definition at line 236 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::next().

{
this->next();
return *this;
}
template<typename TInteger>
ConstIterator DGtal::FreemanChain< TInteger >::ConstIterator::operator++ ( int  )
inline

Post-increment. Goes to the next point on the chain.

Definition at line 246 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::next().

{
ConstIterator tmp(*this);
this->next();
return tmp;
}
template<typename TInteger>
ConstIterator& DGtal::FreemanChain< TInteger >::ConstIterator::operator-- ( )
inline

Pre-decrement. Goes to the previous point on the chain.

Definition at line 297 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::previous().

{
this->previous();
return *this;
}
template<typename TInteger>
ConstIterator DGtal::FreemanChain< TInteger >::ConstIterator::operator-- ( int  )
inline

Post-decrement. Goes to the previous point on the chain.

Definition at line 307 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::previous().

{
ConstIterator tmp(*this);
this->previous();
return tmp;
}
template<typename TInteger>
bool DGtal::FreemanChain< TInteger >::ConstIterator::operator< ( const ConstIterator aOther) const
inline

Inferior operator.

Parameters:
aOtherthe iterator to compare with (must be defined on the same chain).
Returns:
'true' if the current position of 'this' is before the current position of [aOther].

Definition at line 365 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::myFc, and DGtal::FreemanChain< TInteger >::ConstIterator::myPos.

{
ASSERT( myFc == aOther.myFc );
return myPos < aOther.myPos;
}
template<typename TInteger >
DGtal::FreemanChain< TInteger >::ConstIterator & DGtal::FreemanChain< TInteger >::ConstIterator::operator= ( const ConstIterator other)
inline

Assignment.

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

Definition at line 76 of file FreemanChain.ih.

References DGtal::FreemanChain< TInteger >::ConstIterator::myFc, DGtal::FreemanChain< TInteger >::ConstIterator::myPos, and DGtal::FreemanChain< TInteger >::ConstIterator::myXY.

{
if ( this != &other )
{
myFc = other.myFc;
myPos = other.myPos;
myXY = other.myXY;
}
return *this;
}
template<typename TInteger>
bool DGtal::FreemanChain< TInteger >::ConstIterator::operator== ( const ConstIterator aOther) const
inline

Equality operator.

Parameters:
aOtherthe iterator to compare with (must be defined on the same chain).
Returns:
'true' if their current positions coincide.

Definition at line 335 of file FreemanChain.h.

References DGtal::FreemanChain< TInteger >::ConstIterator::myFc, and DGtal::FreemanChain< TInteger >::ConstIterator::myPos.

{
ASSERT( myFc == aOther.myFc );
return myPos == aOther.myPos;
}
template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::previous ( )
inline

Goes to the previous point on the chain if possible.

Definition at line 128 of file FreemanChain.ih.

References DGtal::FreemanChain< TInteger >::chain.

Referenced by DGtal::FreemanChain< TInteger >::findQuadrantChange(), DGtal::FreemanChain< TInteger >::findQuadrantChange4(), and DGtal::FreemanChain< TInteger >::ConstIterator::operator--().

{
if ( myPos == myFc->chain.size() + 1 )
{
--myPos;
}
else
{
if ( myPos >= 1 )
--myPos;
if ( myPos < myFc->chain.size() )
{
switch ( myFc->code( myPos ) )
{
case '0': (myXY.at(0))--; break;
case '1': (myXY.at(1))--; break;
case '2': (myXY.at(0))++; break;
case '3': (myXY.at(1))++; break;
}
}
}
}
template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::previousInLoop ( )
inline

Goes to the previous point on the chain as if on a loop.

Definition at line 155 of file FreemanChain.ih.

Referenced by DGtal::FreemanChain< TInteger >::cleanOuterSpikes().

{
if ( myPos == 0 ) myPos = (typename DGtal::FreemanChain<TInteger>::Index)(myFc->chain.size() - 1);
else --myPos;
switch ( myFc->code( myPos ) )
{
case '0': (myXY.at(0))--; break;
case '1': (myXY.at(1))--; break;
case '2': (myXY.at(0))++; break;
case '3': (myXY.at(1))++; break;
}
}

Field Documentation

template<typename TInteger>
const FreemanChain* DGtal::FreemanChain< TInteger >::ConstIterator::myFc
private
template<typename TInteger>
Index DGtal::FreemanChain< TInteger >::ConstIterator::myPos
private
template<typename TInteger>
Point DGtal::FreemanChain< TInteger >::ConstIterator::myXY
private

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