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

#include <KhalimskySpaceND.h>

Collaboration diagram for DGtal::CellDirectionIterator< dim, TInteger >:
Collaboration graph
[legend]

Public Types

typedef TInteger Integer
typedef KhalimskyCell< dim,
Integer
Cell
typedef SignedKhalimskyCell
< dim, Integer
SCell

Public Member Functions

 CellDirectionIterator (Cell cell, bool open=true)
 CellDirectionIterator (SCell scell, bool open=true)
Dimension operator* () const
CellDirectionIteratoroperator++ ()
bool operator!= (const Integer) const
bool end () const
bool operator!= (const CellDirectionIterator &other) const
bool operator== (const CellDirectionIterator &other) const

Private Member Functions

void find ()

Private Attributes

Dimension myDir
Cell myCell
bool myOpen

Detailed Description

template<Dimension dim, typename TInteger = DGtal::int32_t>
class DGtal::CellDirectionIterator< dim, TInteger >

This class is useful for looping on all "interesting" coordinates of a cell. For instance, surfels in Z3 have two interesting coordinates (the ones spanned by the surfel).

KSpace::Cell p;
KnSpace::DirIterator q;
for ( q = ks.uDirs( p ); q != 0; ++q )
{
KSpace::Dimension dir = *q;
...
}

Definition at line 266 of file KhalimskySpaceND.h.


Member Typedef Documentation

template<Dimension dim, typename TInteger = DGtal::int32_t>
typedef KhalimskyCell< dim, Integer > DGtal::CellDirectionIterator< dim, TInteger >::Cell

Definition at line 271 of file KhalimskySpaceND.h.

template<Dimension dim, typename TInteger = DGtal::int32_t>
typedef TInteger DGtal::CellDirectionIterator< dim, TInteger >::Integer

Definition at line 269 of file KhalimskySpaceND.h.

template<Dimension dim, typename TInteger = DGtal::int32_t>
typedef SignedKhalimskyCell< dim, Integer > DGtal::CellDirectionIterator< dim, TInteger >::SCell

Definition at line 272 of file KhalimskySpaceND.h.


Constructor & Destructor Documentation

template<Dimension dim, typename TInteger >
DGtal::CellDirectionIterator< dim, TInteger >::CellDirectionIterator ( Cell  cell,
bool  open = true 
)
inline

Constructor from cell.

Parameters:
cellany unsigned cell

Definition at line 250 of file KhalimskySpaceND.ih.

References DGtal::CellDirectionIterator< dim, TInteger >::find().

: myDir( 0 ), myCell( cell ), myOpen( open )
{
find();
}
template<Dimension dim, typename TInteger >
DGtal::CellDirectionIterator< dim, TInteger >::CellDirectionIterator ( SCell  scell,
bool  open = true 
)
inline

Constructor from signed cell.

Parameters:
scellany signed cell

Definition at line 259 of file KhalimskySpaceND.ih.

References DGtal::CellDirectionIterator< dim, TInteger >::find().

: myDir( 0 ), myCell( scell.myCoordinates ), myOpen( open )
{
find();
}

Member Function Documentation

template<Dimension dim, typename TInteger >
bool DGtal::CellDirectionIterator< dim, TInteger >::end ( ) const
inline
Returns:
'true' if the iteration is ended.

Definition at line 298 of file KhalimskySpaceND.ih.

Referenced by DGtal::KhalimskySpaceND< dim, TInteger >::sOrthDir(), and DGtal::KhalimskySpaceND< dim, TInteger >::uOrthDir().

{
return myDir >= dim;
}
template<Dimension dim, typename TInteger >
void DGtal::CellDirectionIterator< dim, TInteger >::find ( )
inlineprivate

Look for next valid coordinate.

Definition at line 325 of file KhalimskySpaceND.ih.

Referenced by DGtal::CellDirectionIterator< dim, TInteger >::CellDirectionIterator().

{
if ( myOpen ) // loop on open coordinates
while ( ( myDir != dim )
&& ( ( myCell.myCoordinates[ myDir ] & 0x1 ) == 0 ) )
++myDir;
else // myOpen is false, loop on closed coordinates
while ( ( myDir != dim )
&& ( myCell.myCoordinates[ myDir ] & 0x1 ) )
++myDir;
}
template<Dimension dim, typename TInteger >
bool DGtal::CellDirectionIterator< dim, TInteger >::operator!= ( const Integer  ) const
inline

Fast comparison with unsigned integer (unused parameter). Comparison is 'false' at the end of the iteration.

Returns:
'true' if the iterator is finished.

Definition at line 289 of file KhalimskySpaceND.ih.

{
return myDir < dim;
}
template<Dimension dim, typename TInteger >
bool DGtal::CellDirectionIterator< dim, TInteger >::operator!= ( const CellDirectionIterator< dim, TInteger > &  other) const
inline

Slow comparison with other iterator. Useful to check for end of loop.

Parameters:
otherany direction iterator.

Definition at line 307 of file KhalimskySpaceND.ih.

References DGtal::CellDirectionIterator< dim, TInteger >::myDir.

{
return myDir != other.myDir;
}
template<Dimension dim, typename TInteger >
DGtal::Dimension DGtal::CellDirectionIterator< dim, TInteger >::operator* ( ) const
inline
Returns:
the current direction.

Definition at line 269 of file KhalimskySpaceND.ih.

{
return myDir;
}
template<Dimension dim, typename TInteger >
DGtal::CellDirectionIterator< dim, TInteger > & DGtal::CellDirectionIterator< dim, TInteger >::operator++ ( )
inline

Pre-increment. Go to next direction.

Definition at line 278 of file KhalimskySpaceND.ih.

{
++myDir;
find();
return *this;
}
template<Dimension dim, typename TInteger >
bool DGtal::CellDirectionIterator< dim, TInteger >::operator== ( const CellDirectionIterator< dim, TInteger > &  other) const
inline

Slow comparison with other iterator.

Parameters:
otherany direction iterator.

Definition at line 316 of file KhalimskySpaceND.ih.

References DGtal::CellDirectionIterator< dim, TInteger >::myDir.

{
return myDir == other.myDir;
}

Field Documentation

template<Dimension dim, typename TInteger = DGtal::int32_t>
Cell DGtal::CellDirectionIterator< dim, TInteger >::myCell
private

the cell.

Definition at line 326 of file KhalimskySpaceND.h.

template<Dimension dim, typename TInteger = DGtal::int32_t>
Dimension DGtal::CellDirectionIterator< dim, TInteger >::myDir
private
template<Dimension dim, typename TInteger = DGtal::int32_t>
bool DGtal::CellDirectionIterator< dim, TInteger >::myOpen
private

If 'true', returns open coordinates, otherwise returns closed coordinates.

Definition at line 329 of file KhalimskySpaceND.h.


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