32 #if defined(HyperRectDomain_Iterator_RECURSES)
33 #error Recursive header files inclusion detected in HyperRectDomain_Iterator.h
34 #else // defined(HyperRectDomain_Iterator_RECURSES)
36 #define HyperRectDomain_Iterator_RECURSES
38 #if !defined HyperRectDomain_Iterator_h
40 #define HyperRectDomain_Iterator_h
47 #include <type_traits>
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
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."
505 #endif // !defined HyperRectDomain_Iterator_h
507 #undef HyperRectDomain_Iterator_RECURSES
508 #endif // else defined(HyperRectDomain_Iterator_RECURSES)
void advance(DifferenceType const &n)
Advances the iterator in order to scan the domain points dimension by dimension (by using the subDoma...
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.
Reverse iterator for HyperRectDomain.
Vector lower(const Vector &z, unsigned int k)
HyperRectDomain_subIterator(const TPoint &p, const TPoint &lower, const TPoint &upper, const std::vector< Dimension > &subDomain)
void increment()
Increments the iterator in order to scan the domain points dimension by dimension (by using the subDo...
friend class boost::iterator_core_access
bool equal(const Self &other) const
Compare iterators.
TPoint myPoint
Current Point in the domain.
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).
std::vector< Dimension > mySubDomain
const Point & dereference() const
Dereference.
void decrement()
Decrements the iterator in order to scan the domain points dimension by dimension (lexicographic orde...
DGtal is the top-level namespace which contains all DGtal functions and types.
void advance(DifferenceType const &n)
Advance iterator by given steps.
TPoint mylower
Copies of the Domain limits.
typename Point::Dimension Dimension
void increment()
Increments the iterator in order to scan the domain points dimension by dimension (lexicographic orde...
void increment()
Increment iterator.
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).
DifferenceType distance_to(const Self &other) const
Distance between two iterators on the same domain (lexicographic order).
HyperRectDomain_Iterator(const Point &p, const Point &lower, const Point &upper)
HyperRectDomain iterator constructor.
void decrement()
Decrement iterator.
Iterator for HyperRectDomain.
Vector upper(const Vector &z, unsigned int k)
const Point & dereference() const
Dereference.
HyperRectDomain_ReverseIterator(Iterator it)
Constructor from a HyperRectDomain iterator.
typename Point::Dimension Dimension
TPoint myPoint
Current Point in the domain.
friend class boost::iterator_core_access
typename Point::Dimension Dimension
void advance(DifferenceType const &n)
Advances the iterator in order to scan the domain points dimension by dimension (lexicographic order)...
const Point & dereference() const
Dereference.
DifferenceType pos
Iterator position in the current sequence.
DifferenceType pos
Iterator position in the current sequence.
void decrement()
Decrements the iterator in order to scan the domain points dimension by dimension (by using the subDo...
TPoint mylower
Copies of the Domain limits.
typename Iterator::Point Point
DifferenceType distance_to(const Self &other) const
Distance between two iterators on the same domain (by using the subDomain order given by the user).