DGtal  1.2.0
Public Member Functions | Private Attributes
DGtal::FreemanChain< TInteger >::ConstIterator Class Reference

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

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

Public Member Functions

 ConstIterator ()
 
 ConstIterator (ConstAlias< FreemanChain > aChain, Index n=0)
 
 ConstIterator (ConstAlias< 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 position () 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
 The Freeman chain visited by the iterator. More...
 
Index myPos
 The current position in the word. More...
 
Point myXY
 The current coordinates of the iterator. More...
 

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 141 of file FreemanChain.h.

Constructor & Destructor Documentation

◆ ConstIterator() [1/4]

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

Default Constructor. The object is not valid.

Definition at line 165 of file FreemanChain.h.

166  : myFc( NULL ), myPos( 0 )
167  { }
Index myPos
The current position in the word.
Definition: FreemanChain.h:153
const FreemanChain * myFc
The Freeman chain visited by the iterator.
Definition: FreemanChain.h:150

◆ ConstIterator() [2/4]

template<typename TInteger >
DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator ( ConstAlias< FreemanChain aChain,
Index  n = 0 
)

Constructor. Nb: complexity in O(n).

Parameters
aChaina Freeman chain,
nthe position in chain.

◆ ConstIterator() [3/4]

template<typename TInteger >
DGtal::FreemanChain< TInteger >::ConstIterator::ConstIterator ( ConstAlias< 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
aChaina Freeman chain,
nthe position in chain.
XYthe point corresponding to the 'n'-th position of 'chain'.

Definition at line 190 of file FreemanChain.h.

191  : myFc( &aChain ), myPos( n ), myXY ( XY )
192  { }
Point myXY
The current coordinates of the iterator.
Definition: FreemanChain.h:156

◆ ConstIterator() [4/4]

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

Copy constructor.

Parameters
aOtherthe iterator to clone.

Definition at line 198 of file FreemanChain.h.

199  : myFc( aOther.myFc ), myPos( aOther.myPos ), myXY( aOther.myXY )
200  { }

◆ ~ConstIterator()

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

Destructor. Does nothing.

Definition at line 212 of file FreemanChain.h.

213  { }

Member Function Documentation

◆ get()

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

Definition at line 230 of file FreemanChain.h.

231  {
232  return myXY;
233  }

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

◆ getChain()

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

Definition at line 279 of file FreemanChain.h.

280  {
281  return myFc;
282  }

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

◆ getCode()

template<typename TInteger >
char DGtal::FreemanChain< TInteger >::ConstIterator::getCode ( ) const
inline
Returns
the current Freeman code (specifies the movement to the next point).

Definition at line 289 of file FreemanChain.h.

290  {
291  ASSERT( myFc != 0 );
292  return myFc->code( myPos );
293  }
char code(Index pos) const

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

◆ next()

template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::next ( )

Goes to the next point on the chain.

Referenced by DGtal::FreemanChain< TInteger >::ConstIterator::operator++().

◆ nextInLoop()

template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::nextInLoop ( )

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

◆ operator!=()

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 353 of file FreemanChain.h.

354  {
355  ASSERT( myFc == aOther.myFc );
356  return myPos != aOther.myPos;
357  }

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

◆ operator*()

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

Definition at line 222 of file FreemanChain.h.

223  {
224  return myXY;
225  }

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

◆ operator++() [1/2]

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

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

Definition at line 239 of file FreemanChain.h.

240  {
241  this->next();
242  return *this;
243  }

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

◆ operator++() [2/2]

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

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

Definition at line 249 of file FreemanChain.h.

250  {
251  ConstIterator tmp(*this);
252  this->next();
253  return tmp;
254  }
MyDigitalSurface::ConstIterator ConstIterator

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

◆ operator--() [1/2]

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

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

Definition at line 300 of file FreemanChain.h.

301  {
302  this->previous();
303  return *this;
304  }

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

◆ operator--() [2/2]

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

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

Definition at line 310 of file FreemanChain.h.

311  {
312  ConstIterator tmp(*this);
313  this->previous();
314  return tmp;
315  }

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

◆ operator<()

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 368 of file FreemanChain.h.

369  {
370  ASSERT( myFc == aOther.myFc );
371  return myPos < aOther.myPos;
372  }

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

◆ operator=()

template<typename TInteger >
ConstIterator& DGtal::FreemanChain< TInteger >::ConstIterator::operator= ( const ConstIterator other)

Assignment.

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

◆ operator==()

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 338 of file FreemanChain.h.

339  {
340  ASSERT( myFc == aOther.myFc );
341  return myPos == aOther.myPos;
342  }

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

◆ position()

template<typename TInteger >
Index DGtal::FreemanChain< TInteger >::ConstIterator::position ( ) const
inline
Returns
the current position (as an index in the Freeman chain).

Definition at line 270 of file FreemanChain.h.

271  {
272  return myPos;
273  }

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

◆ previous()

template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::previous ( )

Goes to the previous point on the chain if possible.

Referenced by DGtal::FreemanChain< TInteger >::ConstIterator::operator--().

◆ previousInLoop()

template<typename TInteger >
void DGtal::FreemanChain< TInteger >::ConstIterator::previousInLoop ( )

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

Field Documentation

◆ myFc

template<typename TInteger >
const FreemanChain* DGtal::FreemanChain< TInteger >::ConstIterator::myFc
private

◆ myPos

template<typename TInteger >
Index DGtal::FreemanChain< TInteger >::ConstIterator::myPos
private

◆ myXY

template<typename TInteger >
Point DGtal::FreemanChain< TInteger >::ConstIterator::myXY
private

The current coordinates of the iterator.

Definition at line 156 of file FreemanChain.h.

Referenced by DGtal::FreemanChain< TInteger >::ConstIterator::get(), and DGtal::FreemanChain< TInteger >::ConstIterator::operator*().


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