19 #ifndef itkIndexRange_h
20 #define itkIndexRange_h
25 #include <type_traits>
33 namespace Experimental
79 template<
unsigned VDimension,
bool VBeginAtZero>
122 for (
unsigned i = 0; i < (VDimension - 1); ++i)
155 for (
unsigned i = 0; i < (VDimension - 1); ++i)
189 assert(lhs.m_MaxIndex == rhs.m_MaxIndex);
191 return lhs.m_Index == rhs.m_Index;
199 return !(lhs == rhs);
206 for (
unsigned i = VDimension; i > 0; --i)
208 const auto difference = lhs.m_Index[i - 1] - rhs.m_Index[i - 1];
270 using MinIndexType =
typename std::conditional<VBeginAtZero, ZeroIndex, IndexType>::type;
315 m_MaxIndex.
back() = -1;
335 template <
bool VIsSubstitutionFailure = VBeginAtZero,
336 typename TVoid =
typename std::enable_if<!VIsSubstitutionFailure>::type>
345 static_assert(!VIsSubstitutionFailure,
346 "This template should (of course) be instantiated without substitution failure.");
347 static_assert(std::is_same<TVoid, void>::value,
348 "std::enable_if<!VIsSubstitutionFailure> should yield void, by definition.");
349 static_assert(!VBeginAtZero,
350 "This constructor should only be is available when VBeginAtZero is false.");
374 return this->
begin();
409 std::size_t
size() const ITK_NOEXCEPT
411 std::size_t result = 1;
413 for (
unsigned i = 0; i < VDimension; ++i)
424 for (
unsigned i = 0; i < VDimension; ++i)
444 for (
unsigned i = 0; i < VDimension; ++i)
446 index[i] = minIndex[i] +
static_cast<IndexValueType>(size[i]) - 1;
462 template<
unsigned VDimension>
465 template<
unsigned VDimension>
std::reverse_iterator< const_iterator > const_reverse_iterator
reference operator*() const noexcept
IndexRange(const SizeType &gridSize)
std::ptrdiff_t difference_type
constexpr IndexValueType operator[](unsigned) const
Represent a n-dimensional index in a n-dimensional image.
const_iterator cend() const noexcept
const_iterator(const IndexType &index, const MinIndexType &minIndex, const IndexType &maxIndex) noexcept
friend bool operator==(const const_iterator &lhs, const const_iterator &rhs) noexcept
const_iterator & operator--() noexcept
reverse_iterator rend() const noexcept
bool empty() const noexcept
friend bool operator!=(const const_iterator &lhs, const const_iterator &rhs) noexcept
typename std::conditional< VBeginAtZero, ZeroIndex, IndexType >::type MinIndexType
iterator end() const noexcept
Index< VDimension > IndexType
const_reverse_iterator crbegin() const noexcept
friend bool operator<(const const_iterator &lhs, const const_iterator &rhs) noexcept
iterator begin() const noexcept
const_iterator cbegin() const noexcept
std::reverse_iterator< iterator > reverse_iterator
friend bool operator>(const const_iterator &lhs, const const_iterator &rhs) noexcept
std::bidirectional_iterator_tag iterator_category
signed long IndexValueType
Represent a n-dimensional size (bounds) of a n-dimensional image.
typename iterator::MinIndexType MinIndexType
pointer operator->() const noexcept
const_iterator operator++(int) noexcept
std::vcl_size_t size() const noexcept
friend bool operator>=(const const_iterator &lhs, const const_iterator &rhs) noexcept
const_iterator & operator++() noexcept
reverse_iterator rbegin() const noexcept
static IndexType CalculateMaxIndex(const MinIndexType &minIndex, const SizeType &size)
IndexRange(const ImageRegion< VDimension > &imageRegion)
friend bool operator<=(const const_iterator &lhs, const const_iterator &rhs) noexcept
const_iterator operator--(int) noexcept
const_reverse_iterator crend() const noexcept
static constexpr unsigned Dimension