DGtal 2.1.0
Loading...
Searching...
No Matches
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.
 
Index myPos
 The current position in the word.
 
Point myXY
 The current coordinates of the iterator.
 

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.

Examples
geometry/curves/exampleAlphaThickSegment.cpp.

Definition at line 143 of file FreemanChain.h.

Member Typedef Documentation

◆ difference_type

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

Definition at line 149 of file FreemanChain.h.

◆ iterator_category

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

Definition at line 147 of file FreemanChain.h.

◆ pointer

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

Definition at line 150 of file FreemanChain.h.

◆ reference

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

Definition at line 151 of file FreemanChain.h.

◆ value_type

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

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

174 : myFc( NULL ), myPos( 0 )
175 { }
Index myPos
The current position in the word.
const FreemanChain * myFc
The Freeman chain visited by the iterator.

◆ 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] (within 0 and chain.size()).

◆ 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] (within 0 and chain.size()).
XYthe point corresponding to the 'n'-th position of 'chain'.

Definition at line 198 of file FreemanChain.h.

199 : myFc( &aChain ), myPos( n ), myXY ( XY )
200 { }
Point myXY
The current coordinates of the iterator.

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

207 : myFc( aOther.myFc ), myPos( aOther.myPos ), myXY( aOther.myXY )
208 { }

◆ ~ConstIterator()

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

Destructor. Does nothing.

Definition at line 220 of file FreemanChain.h.

221 { }

Member Function Documentation

◆ get()

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

Definition at line 238 of file FreemanChain.h.

239 {
240 return myXY;
241 }

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

288 {
289 return myFc;
290 }

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

298 {
299 ASSERT( myFc != 0 );
300 return myFc->code( myPos );
301 }
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 ( )

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

362 {
363 ASSERT( myFc == aOther.myFc );
364 return myPos != aOther.myPos;
365 }

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

231 {
232 return myXY;
233 }

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

248 {
249 this->next();
250 return *this;
251 }

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

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

309 {
310 this->previous();
311 return *this;
312 }

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

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

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

377 {
378 ASSERT( myFc == aOther.myFc );
379 return myPos < aOther.myPos;
380 }

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

347 {
348 ASSERT( myFc == aOther.myFc );
349 return myPos == aOther.myPos;
350 }

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

279 {
280 return myPos;
281 }

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

◆ previous()

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

◆ 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 164 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: