ITK  5.3.0
Insight Toolkit
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
itk::IndexRange< VDimension, VBeginAtZero > Class Template Referencefinal

#include <itkIndexRange.h>

Classes

class  const_iterator
 

Public Types

using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using IndexType = Index< VDimension >
 
using iterator = const_iterator
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using SizeType = Size< VDimension >
 

Public Member Functions

 IndexRange ()=default
 
 IndexRange (const SizeType &gridSize)
 

Static Public Attributes

constexpr static unsigned Dimension = VDimension
 
using MinIndexType = typename iterator::MinIndexType
 
MinIndexType m_MinIndex = MinIndexType()
 
IndexType m_MaxIndex = IndexType::Filled(-1)
 
template<bool VIsSubstitutionFailure = VBeginAtZero, typename TVoid = std::enable_if_t<!VIsSubstitutionFailure>>
 IndexRange (const ImageRegion< VDimension > &imageRegion)
 
iterator begin () const noexcept
 
iterator end () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () const noexcept
 
reverse_iterator rend () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 
std::vcl_size_t size () const noexcept
 
bool empty () const noexcept
 
static IndexType CalculateMaxIndex (const MinIndexType &minIndex, const SizeType &size)
 

Detailed Description

template<unsigned VDimension, bool VBeginAtZero>
class itk::IndexRange< VDimension, VBeginAtZero >

Modern C++11 range, supporting efficient iteration over the indices of an image grid space.

The following example prints all indices of an 2-D grid space of size 2x3.

constexpr unsigned Dimension = 2;
const Size<Dimension> size = { {2, 3} };
const ZeroBasedIndexRange<Dimension> indexRange{ size };
for (const Index<Dimension> index : indexRange)
{
std::cout << index;
}
// Output: "[0, 0][1, 0][0, 1][1, 1][0, 2][1, 2]"

The indices from IndexRange can also be used as consecutive locations of a ShapedImageNeighborhoodRange, for example:

for (const auto index : indexRange)
{
shapedImageNeighborhoodRange.SetLocation(index);
for (const PixelType neighborPixel : shapedImageNeighborhoodRange)
{
// Process neighbor pixel...
}
}

IndexRange is designed to conform to Standard C++ Iterator requirements, so that it can be used in range-based for loop, and its iterators can be passed to Standard C++ algorithms.

Author
Niels Dekker, LKEB, Leiden University Medical Center
See also
ShapedImageNeighborhoodRange

Definition at line 78 of file itkIndexRange.h.

Member Typedef Documentation

◆ const_reverse_iterator

template<unsigned VDimension, bool VBeginAtZero>
using itk::IndexRange< VDimension, VBeginAtZero >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 292 of file itkIndexRange.h.

◆ IndexType

template<unsigned VDimension, bool VBeginAtZero>
using itk::IndexRange< VDimension, VBeginAtZero >::IndexType = Index<VDimension>

Definition at line 83 of file itkIndexRange.h.

◆ iterator

template<unsigned VDimension, bool VBeginAtZero>
using itk::IndexRange< VDimension, VBeginAtZero >::iterator = const_iterator

Definition at line 290 of file itkIndexRange.h.

◆ MinIndexType

template<unsigned VDimension, bool VBeginAtZero>
using itk::IndexRange< VDimension, VBeginAtZero >::MinIndexType = typename iterator::MinIndexType
private

Constructs a range of indices for the specified image region.

Note
This function is unavailable when VBeginAtZero is true (in case there is a substitution failure, and C++ "SFINAE" kicks in).

Definition at line 422 of file itkIndexRange.h.

◆ reverse_iterator

template<unsigned VDimension, bool VBeginAtZero>
using itk::IndexRange< VDimension, VBeginAtZero >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 291 of file itkIndexRange.h.

◆ SizeType

template<unsigned VDimension, bool VBeginAtZero>
using itk::IndexRange< VDimension, VBeginAtZero >::SizeType = Size<VDimension>

Definition at line 82 of file itkIndexRange.h.

Constructor & Destructor Documentation

◆ IndexRange() [1/3]

template<unsigned VDimension, bool VBeginAtZero>
itk::IndexRange< VDimension, VBeginAtZero >::IndexRange ( )
default

Explicitly defaulted default-constructor. Constructs an empty range.

Note
The other five "special member functions" (copy-constructor, copy-assignment operator, move-constructor, move-assignment operator, and destructor) are implicitly defaulted, following the C++ "Rule of Zero".

◆ IndexRange() [2/3]

template<unsigned VDimension, bool VBeginAtZero>
itk::IndexRange< VDimension, VBeginAtZero >::IndexRange ( const SizeType gridSize)
inlineexplicit

Constructs a range of indices for the specified grid size.

Definition at line 304 of file itkIndexRange.h.

◆ IndexRange() [3/3]

template<unsigned VDimension, bool VBeginAtZero>
template<bool VIsSubstitutionFailure = VBeginAtZero, typename TVoid = std::enable_if_t<!VIsSubstitutionFailure>>
itk::IndexRange< VDimension, VBeginAtZero >::IndexRange ( const ImageRegion< VDimension > &  imageRegion)
inlineexplicit

Constructs a range of indices for the specified image region.

Note
This function is unavailable when VBeginAtZero is true (in case there is a substitution failure, and C++ "SFINAE" kicks in).

Definition at line 318 of file itkIndexRange.h.

Member Function Documentation

◆ begin()

template<unsigned VDimension, bool VBeginAtZero>
iterator itk::IndexRange< VDimension, VBeginAtZero >::begin ( ) const
inlinenoexcept

◆ CalculateMaxIndex()

template<unsigned VDimension, bool VBeginAtZero>
static IndexType itk::IndexRange< VDimension, VBeginAtZero >::CalculateMaxIndex ( const MinIndexType minIndex,
const SizeType size 
)
inlinestaticprivate

Constructs a range of indices for the specified image region.

Note
This function is unavailable when VBeginAtZero is true (in case there is a substitution failure, and C++ "SFINAE" kicks in).

Definition at line 425 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::size().

◆ cbegin()

template<unsigned VDimension, bool VBeginAtZero>
const_iterator itk::IndexRange< VDimension, VBeginAtZero >::cbegin ( ) const
inlinenoexcept

Returns a const iterator to the first index. Provides only read-only access to the index data.

Definition at line 354 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::begin().

◆ cend()

template<unsigned VDimension, bool VBeginAtZero>
const_iterator itk::IndexRange< VDimension, VBeginAtZero >::cend ( ) const
inlinenoexcept

Returns a const 'end iterator' for this range.

Definition at line 361 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::end().

◆ crbegin()

template<unsigned VDimension, bool VBeginAtZero>
const_reverse_iterator itk::IndexRange< VDimension, VBeginAtZero >::crbegin ( ) const
inlinenoexcept

Returns a const reverse 'begin iterator' for this range.

Definition at line 382 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::rbegin().

◆ crend()

template<unsigned VDimension, bool VBeginAtZero>
const_reverse_iterator itk::IndexRange< VDimension, VBeginAtZero >::crend ( ) const
inlinenoexcept

Returns a const reverse 'end iterator' for this range.

Definition at line 389 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::rend().

◆ empty()

template<unsigned VDimension, bool VBeginAtZero>
bool itk::IndexRange< VDimension, VBeginAtZero >::empty ( ) const
inlinenoexcept

◆ end()

template<unsigned VDimension, bool VBeginAtZero>
iterator itk::IndexRange< VDimension, VBeginAtZero >::end ( ) const
inlinenoexcept

◆ rbegin()

template<unsigned VDimension, bool VBeginAtZero>
reverse_iterator itk::IndexRange< VDimension, VBeginAtZero >::rbegin ( ) const
inlinenoexcept

Returns a reverse 'begin iterator' for this range.

Definition at line 368 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::end().

Referenced by itk::IndexRange< VDimension, VBeginAtZero >::crbegin().

◆ rend()

template<unsigned VDimension, bool VBeginAtZero>
reverse_iterator itk::IndexRange< VDimension, VBeginAtZero >::rend ( ) const
inlinenoexcept

Returns a reverse 'end iterator' for this range.

Definition at line 375 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::begin().

Referenced by itk::IndexRange< VDimension, VBeginAtZero >::crend().

◆ size()

template<unsigned VDimension, bool VBeginAtZero>
std::vcl_size_t itk::IndexRange< VDimension, VBeginAtZero >::size ( ) const
inlinenoexcept

Returns the size of the range, that is the number of indices.

Definition at line 397 of file itkIndexRange.h.

References itk::IndexRange< VDimension, VBeginAtZero >::m_MaxIndex, and itk::IndexRange< VDimension, VBeginAtZero >::m_MinIndex.

Referenced by itk::IndexRange< VDimension, VBeginAtZero >::CalculateMaxIndex().

Member Data Documentation

◆ Dimension

template<unsigned VDimension, bool VBeginAtZero>
constexpr static unsigned itk::IndexRange< VDimension, VBeginAtZero >::Dimension = VDimension
staticconstexpr

Definition at line 81 of file itkIndexRange.h.

◆ m_MaxIndex

template<unsigned VDimension, bool VBeginAtZero>
IndexType itk::IndexRange< VDimension, VBeginAtZero >::m_MaxIndex = IndexType::Filled(-1)
private

Constructs a range of indices for the specified image region.

Note
This function is unavailable when VBeginAtZero is true (in case there is a substitution failure, and C++ "SFINAE" kicks in).

Definition at line 457 of file itkIndexRange.h.

Referenced by itk::IndexRange< VDimension, VBeginAtZero >::begin(), itk::IndexRange< VDimension, VBeginAtZero >::empty(), itk::IndexRange< VDimension, VBeginAtZero >::end(), and itk::IndexRange< VDimension, VBeginAtZero >::size().

◆ m_MinIndex

template<unsigned VDimension, bool VBeginAtZero>
MinIndexType itk::IndexRange< VDimension, VBeginAtZero >::m_MinIndex = MinIndexType()
private

Constructs a range of indices for the specified image region.

Note
This function is unavailable when VBeginAtZero is true (in case there is a substitution failure, and C++ "SFINAE" kicks in).

Definition at line 454 of file itkIndexRange.h.

Referenced by itk::IndexRange< VDimension, VBeginAtZero >::begin(), itk::IndexRange< VDimension, VBeginAtZero >::empty(), itk::IndexRange< VDimension, VBeginAtZero >::end(), and itk::IndexRange< VDimension, VBeginAtZero >::size().


The documentation for this class was generated from the following file:
itk::IndexRange::Dimension
constexpr static unsigned Dimension
Definition: itkIndexRange.h:81
itk::IndexRange::size
std::vcl_size_t size() const noexcept
Definition: itkIndexRange.h:397