32#if defined(HyperRectDomain_Iterator_RECURSES)
33#error Recursive header files inclusion detected in HyperRectDomain_Iterator.h
36#define HyperRectDomain_Iterator_RECURSES
38#if !defined HyperRectDomain_Iterator_h
40#define HyperRectDomain_Iterator_h
49#include <boost/iterator/iterator_facade.hpp>
51#include "DGtal/base/Common.h"
65 template <
typename TIterator>
67 :
public boost::iterator_facade <
68 HyperRectDomain_ReverseIterator<TIterator>,
69 typename TIterator::Point const,
70 std::random_access_iterator_tag,
71 typename TIterator::Point const&,
72 typename std::iterator_traits<TIterator>::difference_type
78 using Point =
typename Iterator::Point;
141 template <
typename TPo
int>
143 :
public boost::iterator_facade <
144 HyperRectDomain_Iterator<TPoint>,
146 std::random_access_iterator_tag,
148#ifdef WITH_BIGINTEGER
149 typename std::conditional<std::is_same<typename TPoint::Component, BigInteger>::value, BigInteger, std::ptrdiff_t>::type
176 "The lower bound must be lower than the upper bound or, for an empty domain, be equal to the upper bound + diagonal(1)."
181 "The point must be inside the domain or be equal to one of his bound."
187 for (
Dimension i = 0; i < Point::dimension; ++i )
202 "The iterator points outside the domain."
217 "The compared iterators iterate on different domains."
266 typename Point::Component
const length =
myupper[i] -
mylower[i] + 1;
267 myPoint[i+1] += shift / length;
277 typename Point::Component
const length =
myupper[i] -
mylower[i] + 1;
278 myPoint[i+1] -= shift / length;
291 "The compared iterators iterate on different domains."
315 template<
typename TPo
int>
317 :
public boost::iterator_facade <
318 HyperRectDomain_subIterator<TPoint>,
320 std::random_access_iterator_tag,
322#ifdef WITH_BIGINTEGER
323 typename std::conditional<std::is_same<typename TPoint::Component, BigInteger>::value, BigInteger, std::ptrdiff_t>::type
337 const std::vector<Dimension> &subDomain)
341 lower.isLower(
upper) ||
lower ==
upper + TPoint::diagonal(0).partialCopy( TPoint::diagonal(1), subDomain ),
342 "The lower bound must be lower than the upper bound or, for an empty domain, be equal to the upper bound + diagonal(1)."
347 "The point must be inside the domain or be equal to one of his bound."
351 subDomain.size() <= TPoint::dimension,
352 "The sub-range cannot have more dimensions than the ambiant space."
356 for (
typename std::vector<Dimension>::const_iterator it = subDomain.begin();
357 it != subDomain.end(); ++it )
360 *it <= TPoint::dimension,
361 "Invalid dimension in the sub-range."
385 "The iterator points outside the domain."
400 "The compared iterators iterate on different domains or different dimensions."
450 typename Point::Component
const shift =
myPoint[ii] -
mylower[ii];
451 typename Point::Component
const length =
myupper[ii] -
mylower[ii] + 1;
462 typename Point::Component
const shift =
myupper[ii] -
myPoint[ii];
463 typename Point::Component
const length =
myupper[ii] -
mylower[ii] + 1;
478 "The compared iterators iterate on different domains or different dimensions."
507#undef HyperRectDomain_Iterator_RECURSES
Iterator for HyperRectDomain.
HyperRectDomain_Iterator(const Point &p, const Point &lower, const Point &upper)
HyperRectDomain iterator constructor.
DifferenceType pos
Iterator position in the current sequence.
TPoint mylower
Copies of the Domain limits.
bool equal(const Self &other) const
Compare iterators.
typename std::iterator_traits< Self >::difference_type DifferenceType
Type of the difference between two iterators (usually std::ptrdiff_t except for BigInteger).
void decrement()
Decrements the iterator in order to scan the domain points dimension by dimension (lexicographic orde...
const Point & dereference() const
Dereference.
DifferenceType distance_to(const Self &other) const
Distance between two iterators on the same domain (lexicographic order).
TPoint myPoint
Current Point in the domain.
friend class boost::iterator_core_access
void increment()
Increments the iterator in order to scan the domain points dimension by dimension (lexicographic orde...
void advance(DifferenceType const &n)
Advances the iterator in order to scan the domain points dimension by dimension (lexicographic order)...
typename Point::Dimension Dimension
Reverse iterator for HyperRectDomain.
typename std::iterator_traits< Self >::difference_type DifferenceType
Type of the difference between two iterators (usually std::ptrdiff_t except for BigInteger).
DifferenceType distance_to(const Self &other) const
Distance between two iterators on the same domain.
const Point & dereference() const
Dereference.
typename Point::Dimension Dimension
typename Iterator::Point Point
void increment()
Increment iterator.
void decrement()
Decrement iterator.
HyperRectDomain_ReverseIterator(Iterator it)
Constructor from a HyperRectDomain iterator.
void advance(DifferenceType const &n)
Advance iterator by given steps.
bool equal(const Self &other) const
Compare iterators.
TPoint mylower
Copies of the Domain limits.
bool equal(const Self &other) const
Compare iterators.
DifferenceType distance_to(const Self &other) const
Distance between two iterators on the same domain (by using the subDomain order given by the user).
void decrement()
Decrements the iterator in order to scan the domain points dimension by dimension (by using the subDo...
void advance(DifferenceType const &n)
Advances the iterator in order to scan the domain points dimension by dimension (by using the subDoma...
DifferenceType pos
Iterator position in the current sequence.
void increment()
Increments the iterator in order to scan the domain points dimension by dimension (by using the subDo...
const Point & dereference() const
Dereference.
typename Point::Dimension Dimension
typename std::iterator_traits< Self >::difference_type DifferenceType
Type of the difference between two iterators (usually std::ptrdiff_t except for BigInteger).
friend class boost::iterator_core_access
std::vector< Dimension > mySubDomain
HyperRectDomain_subIterator(const TPoint &p, const TPoint &lower, const TPoint &upper, const std::vector< Dimension > &subDomain)
TPoint myPoint
Current Point in the domain.
DGtal is the top-level namespace which contains all DGtal functions and types.
Vector lower(const Vector &z, unsigned int k)
Vector upper(const Vector &z, unsigned int k)