DGtal  1.5.beta
DGtal::FreemanChain< TInteger >::ConstIterator Class Reference

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

Public Types

using iterator_category = std::bidirectional_iterator_tag
 
using value_type = Point
 
using difference_type = int
 
using pointer = Point *
 
using reference = Point
 

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.

Member Typedef Documentation

◆ difference_type

template<typename TInteger >
using DGtal::FreemanChain< TInteger >::ConstIterator::difference_type = int

Definition at line 147 of file FreemanChain.h.

◆ iterator_category

template<typename TInteger >
using DGtal::FreemanChain< TInteger >::ConstIterator::iterator_category = std::bidirectional_iterator_tag

Definition at line 145 of file FreemanChain.h.

◆ pointer

template<typename TInteger >
using DGtal::FreemanChain< TInteger >::ConstIterator::pointer = Point*

Definition at line 148 of file FreemanChain.h.

◆ reference

template<typename TInteger >
using DGtal::FreemanChain< TInteger >::ConstIterator::reference = Point

Definition at line 149 of file FreemanChain.h.

◆ value_type

template<typename TInteger >
using DGtal::FreemanChain< TInteger >::ConstIterator::value_type = Point

Definition at line 146 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 171 of file FreemanChain.h.

172  : myFc( NULL ), myPos( 0 )
173  { }
Index myPos
The current position in the word.
Definition: FreemanChain.h:159
const FreemanChain * myFc
The Freeman chain visited by the iterator.
Definition: FreemanChain.h:156

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

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

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

205  : myFc( aOther.myFc ), myPos( aOther.myPos ), myXY( aOther.myXY )
206  { }

◆ ~ConstIterator()

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

Destructor. Does nothing.

Definition at line 218 of file FreemanChain.h.

219  { }

Member Function Documentation

◆ get()

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

Definition at line 236 of file FreemanChain.h.

237  {
238  return myXY;
239  }

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

286  {
287  return myFc;
288  }

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

296  {
297  ASSERT( myFc != 0 );
298  return myFc->code( myPos );
299  }
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 359 of file FreemanChain.h.

360  {
361  ASSERT( myFc == aOther.myFc );
362  return myPos != aOther.myPos;
363  }

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

229  {
230  return myXY;
231  }

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

246  {
247  this->next();
248  return *this;
249  }

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

256  {
257  ConstIterator tmp(*this);
258  this->next();
259  return tmp;
260  }
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 306 of file FreemanChain.h.

307  {
308  this->previous();
309  return *this;
310  }

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

317  {
318  ConstIterator tmp(*this);
319  this->previous();
320  return tmp;
321  }

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

375  {
376  ASSERT( myFc == aOther.myFc );
377  return myPos < aOther.myPos;
378  }

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

345  {
346  ASSERT( myFc == aOther.myFc );
347  return myPos == aOther.myPos;
348  }

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

277  {
278  return myPos;
279  }

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

◆ myPos

◆ myXY

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

The current coordinates of the iterator.

Definition at line 162 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: