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 typename std::conditional<std::is_same<typename TPoint::Component, BigInteger>::value, BigInteger, std::ptrdiff_t>::type
172 "The lower bound must be lower than the upper bound or, for an empty domain, be equal to the upper bound + diagonal(1)."
177 "The point must be inside the domain or be equal to one of his bound."
183 for (
Dimension i = 0; i < Point::dimension; ++i )
198 "The iterator points outside the domain."
213 "The compared iterators iterate on different domains."
262 typename Point::Component
const length =
myupper[i] -
mylower[i] + 1;
263 myPoint[i+1] += shift / length;
273 typename Point::Component
const length =
myupper[i] -
mylower[i] + 1;
274 myPoint[i+1] -= shift / length;
287 "The compared iterators iterate on different domains."
311 template<
typename TPo
int>
313 :
public boost::iterator_facade <
314 HyperRectDomain_subIterator<TPoint>,
316 std::random_access_iterator_tag,
318 typename std::conditional<std::is_same<typename TPoint::Component, BigInteger>::value, BigInteger, std::ptrdiff_t>::type
329 const std::vector<Dimension> &subDomain)
333 lower.isLower(
upper) ||
lower ==
upper + TPoint::diagonal(0).partialCopy( TPoint::diagonal(1), subDomain ),
334 "The lower bound must be lower than the upper bound or, for an empty domain, be equal to the upper bound + diagonal(1)."
339 "The point must be inside the domain or be equal to one of his bound."
343 subDomain.size() <= TPoint::dimension,
344 "The sub-range cannot have more dimensions than the ambiant space."
348 for (
typename std::vector<Dimension>::const_iterator it = subDomain.begin();
349 it != subDomain.end(); ++it )
352 *it <= TPoint::dimension,
353 "Invalid dimension in the sub-range."
377 "The iterator points outside the domain."
392 "The compared iterators iterate on different domains or different dimensions."
442 typename Point::Component
const shift =
myPoint[ii] -
mylower[ii];
443 typename Point::Component
const length =
myupper[ii] -
mylower[ii] + 1;
454 typename Point::Component
const shift =
myupper[ii] -
myPoint[ii];
455 typename Point::Component
const length =
myupper[ii] -
mylower[ii] + 1;
470 "The compared iterators iterate on different domains or different dimensions."
499#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)