DGtal  0.9.3beta
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
DGtal::ArrayImageIterator< TIterableClass > Class Template Reference

#include <DGtal/images/ArrayImageIterator.h>

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

Public Types

using Self = ArrayImageIterator< TIterableClass >
 
using IterableClass = TIterableClass
 
using Domain = typename IterableClass::Domain
 
using Point = typename Domain::Point
 
using Linearizer = DGtal::Linearizer< Domain, ColMajorStorage >
 
using Reference = decltype(((IterableClass *) nullptr) ->dereference(Point::diagonal(0), typename Point::Coordinate(0)))
 

Public Member Functions

 ArrayImageIterator ()
 
 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 ()
 
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 ()
 
void decrement ()
 
bool equal (Self const &other) const
 
Reference dereference () const
 
std::ptrdiff_t distance_to (Self const &other) const
 
void advance (std::ptrdiff_t n)
 

Private Attributes

IterableClassmyIterableClassPtr
 
Domain myFullDomain
 
Domain myViewDomain
 
Point myFullExtent
 
Point myViewExtent
 
Point myPoint
 
Point::Coordinate myFullIndex
 

Friends

template<class >
class ArrayImageIterator
 
class boost::iterator_core_access
 

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:

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

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.

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

Iterable class type.

Definition at line 88 of file ArrayImageIterator.h.

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.

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

Point type.

Definition at line 90 of file ArrayImageIterator.h.

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

Return type when dereferencing this iterator.

Definition at line 92 of file ArrayImageIterator.h.

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

Self type.

Definition at line 87 of file ArrayImageIterator.h.

Constructor & Destructor Documentation

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

Default constructor.

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.
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.
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.
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.
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.
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.
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.
template<typename TIterableClass>
DGtal::ArrayImageIterator< TIterableClass >::~ArrayImageIterator ( )

Destructor.

Member Function Documentation

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 ...
template<typename TIterableClass>
void DGtal::ArrayImageIterator< TIterableClass >::decrement ( )
private

Decrement of one step.

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

Dereference.

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.
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.
template<typename TIterableClass>
bool DGtal::ArrayImageIterator< TIterableClass >::equal ( Self const &  other) const
inlineprivate

Test equality with other iterator.

Parameters
otherThe other iterator.
template<typename TIterableClass>
Point const& DGtal::ArrayImageIterator< TIterableClass >::getPoint ( ) const
inlinenoexcept
Returns
the point behind this iterator.
template<typename TIterableClass>
void DGtal::ArrayImageIterator< TIterableClass >::increment ( )
private

Increment of one step.

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.
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.
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.
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

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.

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

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

Full domain of the image.

Definition at line 218 of file ArrayImageIterator.h.

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

Extent of the full domain.

Definition at line 220 of file ArrayImageIterator.h.

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

Linearized index of the current point.

Definition at line 223 of file ArrayImageIterator.h.

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

Pointer to the iterable class.

Definition at line 217 of file ArrayImageIterator.h.

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

Current point where the iterator point to.

Definition at line 222 of file ArrayImageIterator.h.

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

Iterable (viewable) domain of the image.

Definition at line 219 of file ArrayImageIterator.h.

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: