DGtal  1.5.beta
DGtal::ArrayImageIterator< TIterableClass > Class Template Reference

Aim: Random access iterator over an image given his definition domain and viewable domain. More...

#include <DGtal/images/ArrayImageIterator.h>

Inheritance diagram for DGtal::ArrayImageIterator< TIterableClass >:
[legend]

Public Types

using Self = ArrayImageIterator< TIterableClass >
 Self type. More...
 
using IterableClass = TIterableClass
 Iterable class type. More...
 
using Domain = typename IterableClass::Domain
 Domain type. More...
 
using Point = typename Domain::Point
 Point type. More...
 
using Linearizer = DGtal::Linearizer< Domain, ColMajorStorage >
 Linearizer type. More...
 
using Reference = decltype(((new IterableClass) ->dereference(Point::diagonal(0), typename Point::Coordinate(0))))
 Return type when dereferencing this iterator. More...
 

Public Member Functions

 ArrayImageIterator ()
 Default constructor. More...
 
 ArrayImageIterator (IterableClass *anIterableClassPtr, Domain const &aFullDomain, Domain const &aViewDomain, Point const &aPoint)
 
 ArrayImageIterator (IterableClass *anIterableClassPtr, Domain const &aFullDomain, Domain const &aViewDomain)
 
 ArrayImageIterator (IterableClass *anIterableClassPtr, Domain const &aFullDomain)
 
 ArrayImageIterator (IterableClass *anIterableClassPtr, Domain const &aFullDomain, Domain const &aViewDomain, bool)
 
 ArrayImageIterator (IterableClass *anIterableClassPtr, Domain const &aFullDomain, bool)
 
template<typename TOtherIterableClass >
 ArrayImageIterator (ArrayImageIterator< TOtherIterableClass > const &other, typename std::enable_if< std::is_convertible< TOtherIterableClass *, IterableClass * >::value >::type *=0)
 
template<typename TOtherIterableClass >
 ArrayImageIterator (ArrayImageIterator< TOtherIterableClass > &&other, typename std::enable_if< std::is_convertible< TOtherIterableClass *, IterableClass * >::value >::type *=0) noexcept
 
 ~ArrayImageIterator ()
 Destructor. More...
 
template<typename TOtherIterableClass >
std::enable_if< std::is_convertible< TOtherIterableClass *, IterableClass * >::value, Self & >::type operator= (ArrayImageIterator< TOtherIterableClass > const &other)
 
template<typename TOtherIterableClass >
std::enable_if< std::is_convertible< TOtherIterableClass *, IterableClass * >::value, Self & >::type operator= (ArrayImageIterator< TOtherIterableClass > &&other)
 
Point const & getPoint () const noexcept
 
std::ptrdiff_t distance_to (Point const &aPoint) const noexcept
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

void increment ()
 Increment of one step. More...
 
void decrement ()
 Decrement of one step. More...
 
bool equal (Self const &other) const
 
Reference dereference () const
 Dereference. More...
 
std::ptrdiff_t distance_to (Self const &other) const
 
void advance (std::ptrdiff_t n)
 

Private Attributes

IterableClassmyIterableClassPtr
 Pointer to the iterable class. More...
 
Domain myFullDomain
 Full domain of the image. More...
 
Domain myViewDomain
 Iterable (viewable) domain of the image. More...
 
Point myFullExtent
 Extent of the full domain. More...
 
Point myViewExtent
 Extent of the viewable domain. More...
 
Point myPoint
 Current point where the iterator point to. More...
 
Point::Coordinate myFullIndex
 Linearized index of the current point. More...
 

Friends

template<class >
class ArrayImageIterator
 Friendship of interoperability. More...
 
class boost::iterator_core_access
 Friendship of interoperability. More...
 

Detailed Description

template<typename TIterableClass>
class DGtal::ArrayImageIterator< TIterableClass >

Aim: Random access iterator over an image given his definition domain and viewable domain.

Description of template class 'ArrayImageIterator'

This iterator spans a viewable domain given an iterable image-like class (see below) defined on a specified full domain. This iterator provides access to the iterable class through classical iterator syntax and, in addition, exposes current point to which the iterator point to. Thus, when it is needed to iterate over an image while knowing the current point ( for example, when filling an image with a formulae that depends on the point), it is faster to use this iterator instead of a classical domain iterator and the use of operator() and setValue.

In order to work, the iterable class must expose a dereference method that, given a point and his linearized index (column-major ordered), returns:

  • a mutable reference to the corresponding value for a mutable iterator.
  • a copy or a constant reference to the corresponding value for a constant iterator.

In addition, the iterable class must have Domain typedef.

For an usage example, see ArrayImageAdapter.h .

Template Parameters
TIterableClassType of the iterable class.
See also
ArrayImageAdapter.h

Definition at line 75 of file ArrayImageIterator.h.

Member Typedef Documentation

◆ Domain

template<typename TIterableClass >
using DGtal::ArrayImageIterator< TIterableClass >::Domain = typename IterableClass::Domain

Domain type.

Todo:
or in template with default value ?

Definition at line 89 of file ArrayImageIterator.h.

◆ IterableClass

template<typename TIterableClass >
using DGtal::ArrayImageIterator< TIterableClass >::IterableClass = TIterableClass

Iterable class type.

Definition at line 88 of file ArrayImageIterator.h.

◆ Linearizer

template<typename TIterableClass >
using DGtal::ArrayImageIterator< TIterableClass >::Linearizer = DGtal::Linearizer<Domain, ColMajorStorage>

Linearizer type.

Todo:
hard-coded, but must be later set as template.

Definition at line 91 of file ArrayImageIterator.h.

◆ Point

template<typename TIterableClass >
using DGtal::ArrayImageIterator< TIterableClass >::Point = typename Domain::Point

Point type.

Definition at line 90 of file ArrayImageIterator.h.

◆ Reference

template<typename TIterableClass >
using DGtal::ArrayImageIterator< TIterableClass >::Reference = decltype( ((new IterableClass)->dereference( Point::diagonal(0), typename Point::Coordinate(0) ) ))

Return type when dereferencing this iterator.

Definition at line 92 of file ArrayImageIterator.h.

◆ Self

template<typename TIterableClass >
using DGtal::ArrayImageIterator< TIterableClass >::Self = ArrayImageIterator<TIterableClass>

Self type.

Definition at line 87 of file ArrayImageIterator.h.

Constructor & Destructor Documentation

◆ ArrayImageIterator() [1/8]

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( )

Default constructor.

◆ ArrayImageIterator() [2/8]

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( IterableClass anIterableClassPtr,
Domain const &  aFullDomain,
Domain const &  aViewDomain,
Point const &  aPoint 
)

Iterator from a point.

Parameters
anIterableClassPtrPointer to the iterable class instance.
aFullDomainFull domain of the image.
aViewDomainViewable domain that the iterator will span.
aPointPoint to which the iterator will point.

◆ ArrayImageIterator() [3/8]

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( IterableClass anIterableClassPtr,
Domain const &  aFullDomain,
Domain const &  aViewDomain 
)

Iterator pointing to the first value.

Parameters
anIterableClassPtrPointer to the iterable class instance.
aFullDomainFull domain of the image.
aViewDomainViewable domain that the iterator will span.

◆ ArrayImageIterator() [4/8]

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( IterableClass anIterableClassPtr,
Domain const &  aFullDomain 
)

Iterator pointing to the first value and spanning the whole domain.

Parameters
anIterableClassPtrPointer to the iterable class instance.
aFullDomainFull domain of the image.

◆ ArrayImageIterator() [5/8]

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( IterableClass anIterableClassPtr,
Domain const &  aFullDomain,
Domain const &  aViewDomain,
bool   
)

Iterator pointing after the last value of the viewable domain.

Parameters
anIterableClassPtrPointer to the iterable class instance.
aFullDomainFull domain of the image.
aViewDomainViewable domain that the iterator will span.

◆ ArrayImageIterator() [6/8]

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( IterableClass anIterableClassPtr,
Domain const &  aFullDomain,
bool   
)

Iterator pointing after the last value of the whole domain.

Parameters
anIterableClassPtrPointer to the iterable class instance.
aFullDomainFull domain of the image.

◆ ArrayImageIterator() [7/8]

template<typename TIterableClass >
template<typename TOtherIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( ArrayImageIterator< TOtherIterableClass > const &  other,
typename std::enable_if< std::is_convertible< TOtherIterableClass *, IterableClass * >::value >::type *  = 0 
)

Copy constructor with type interoperability.

Parameters
otherAn another iterator whose iterable class pointer is convertible to the current iterable class pointer type.

◆ ArrayImageIterator() [8/8]

template<typename TIterableClass >
template<typename TOtherIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::ArrayImageIterator ( ArrayImageIterator< TOtherIterableClass > &&  other,
typename std::enable_if< std::is_convertible< TOtherIterableClass *, IterableClass * >::value >::type *  = 0 
)
noexcept

Move constructor with type interoperability.

Parameters
otherAn another iterator whose iterable class pointer is convertible to the current iterable class pointer type.

◆ ~ArrayImageIterator()

template<typename TIterableClass >
DGtal::ArrayImageIterator< TIterableClass >::~ArrayImageIterator ( )

Destructor.

Member Function Documentation

◆ advance()

template<typename TIterableClass >
void DGtal::ArrayImageIterator< TIterableClass >::advance ( std::ptrdiff_t  n)
private

Advance by n steps.

Parameters
nThe number of steps.
Todo:
Find a more efficient implementation ...

◆ decrement()

template<typename TIterableClass >
void DGtal::ArrayImageIterator< TIterableClass >::decrement ( )
private

Decrement of one step.

◆ dereference()

template<typename TIterableClass >
Reference DGtal::ArrayImageIterator< TIterableClass >::dereference ( ) const
inlineprivate

Dereference.

◆ distance_to() [1/2]

template<typename TIterableClass >
std::ptrdiff_t DGtal::ArrayImageIterator< TIterableClass >::distance_to ( Point const &  aPoint) const
inlinenoexcept
Returns
the distance from this iterator to a given point.
Parameters
aPointThe point.

◆ distance_to() [2/2]

template<typename TIterableClass >
std::ptrdiff_t DGtal::ArrayImageIterator< TIterableClass >::distance_to ( Self const &  other) const
inlineprivate

Calculate the distance to other iterator.

Parameters
otherThe other iterator.
Returns
the distance.

◆ equal()

template<typename TIterableClass >
bool DGtal::ArrayImageIterator< TIterableClass >::equal ( Self const &  other) const
inlineprivate

Test equality with other iterator.

Parameters
otherThe other iterator.

◆ getPoint()

template<typename TIterableClass >
Point const& DGtal::ArrayImageIterator< TIterableClass >::getPoint ( ) const
inlinenoexcept
Returns
the point behind this iterator.

◆ increment()

template<typename TIterableClass >
void DGtal::ArrayImageIterator< TIterableClass >::increment ( )
private

Increment of one step.

◆ isValid()

template<typename TIterableClass >
bool DGtal::ArrayImageIterator< TIterableClass >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator=() [1/2]

template<typename TIterableClass >
template<typename TOtherIterableClass >
std::enable_if< std::is_convertible<TOtherIterableClass*, IterableClass*>::value, Self& >::type DGtal::ArrayImageIterator< TIterableClass >::operator= ( ArrayImageIterator< TOtherIterableClass > &&  other)

Move assignment constructor with type interoperability.

Template Parameters
TOtherIterableClassThe type of the other iteratable class (auto-deduced).
Parameters
otherAn another iterator whose iterable class pointer is convertible to the current iterable class pointer type.
Returns
a reference to this class instance.

◆ operator=() [2/2]

template<typename TIterableClass >
template<typename TOtherIterableClass >
std::enable_if< std::is_convertible<TOtherIterableClass*, IterableClass*>::value, Self& >::type DGtal::ArrayImageIterator< TIterableClass >::operator= ( ArrayImageIterator< TOtherIterableClass > const &  other)

Copy assignment with type interoperability.

Template Parameters
TOtherIterableClassThe type of the other iterable class (auto-deduced).
Parameters
otherAn another iterator whose iterable class pointer is convertible to the current iterable class pointer type.
Returns
a reference to this class instance.

◆ selfDisplay()

template<typename TIterableClass >
void DGtal::ArrayImageIterator< TIterableClass >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Friends And Related Function Documentation

◆ ArrayImageIterator

template<typename TIterableClass >
template<class >
friend class ArrayImageIterator
friend

Friendship of interoperability.

See also
http://www.boost.org/doc/libs/1_58_0/libs/iterator/doc/iterator_facade.html

Definition at line 229 of file ArrayImageIterator.h.

◆ boost::iterator_core_access

template<typename TIterableClass >
friend class boost::iterator_core_access
friend

Friendship of interoperability.

See also
http://www.boost.org/doc/libs/1_58_0/libs/iterator/doc/iterator_facade.html

Definition at line 230 of file ArrayImageIterator.h.

Field Documentation

◆ myFullDomain

template<typename TIterableClass >
Domain DGtal::ArrayImageIterator< TIterableClass >::myFullDomain
private

Full domain of the image.

Definition at line 218 of file ArrayImageIterator.h.

◆ myFullExtent

template<typename TIterableClass >
Point DGtal::ArrayImageIterator< TIterableClass >::myFullExtent
private

Extent of the full domain.

Definition at line 220 of file ArrayImageIterator.h.

◆ myFullIndex

template<typename TIterableClass >
Point::Coordinate DGtal::ArrayImageIterator< TIterableClass >::myFullIndex
private

Linearized index of the current point.

Definition at line 223 of file ArrayImageIterator.h.

◆ myIterableClassPtr

template<typename TIterableClass >
IterableClass* DGtal::ArrayImageIterator< TIterableClass >::myIterableClassPtr
private

Pointer to the iterable class.

Definition at line 217 of file ArrayImageIterator.h.

◆ myPoint

template<typename TIterableClass >
Point DGtal::ArrayImageIterator< TIterableClass >::myPoint
private

Current point where the iterator point to.

Definition at line 222 of file ArrayImageIterator.h.

◆ myViewDomain

template<typename TIterableClass >
Domain DGtal::ArrayImageIterator< TIterableClass >::myViewDomain
private

Iterable (viewable) domain of the image.

Definition at line 219 of file ArrayImageIterator.h.

◆ myViewExtent

template<typename TIterableClass >
Point DGtal::ArrayImageIterator< TIterableClass >::myViewExtent
private

Extent of the viewable domain.

Definition at line 221 of file ArrayImageIterator.h.


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