ITK  5.4.0
Insight Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
itk::Size< VDimension > Struct Template Referencefinal

#include <itkSize.h>

Detailed Description

template<unsigned int VDimension = 2>
struct itk::Size< VDimension >

Represent a n-dimensional size (bounds) of a n-dimensional image.

Size is a templated class to represent multi-dimensional array bounds, i.e. (I,J,K,...). Size is templated over the dimension of the bounds. ITK assumes the first element of a size (bounds) is the fastest moving index.

For efficiency, Size does not define a default constructor, a copy constructor, or an operator=. We rely on the compiler to provide efficient bitwise copies.

Size is an "aggregate" class. Its data is public (m_InternalArray) allowing for fast and convenient instantiations/assignments.

The following syntax for assigning an aggregate type like this is allowed/suggested:

Size<3> var{{ 256, 256, 20 }}; // Also prevent narrowing conversions Size<3> var = {{ 256, 256, 20 }};

The doubled braces {{ and }} are required to prevent ‘gcc -Wall’ (and perhaps other compilers) from complaining about a partly bracketed initializer.

As an aggregate type that is intended to provide highest performance characteristics, this class is not appropriate to inherit from, so setting this struct as final.

See also
Index
ITK Sphinx Examples:
Examples
SphinxExamples/src/Core/Common/CreateABackwardDifferenceOperator/Code.cxx, SphinxExamples/src/Core/Common/CreateASize/Code.cxx, and SphinxExamples/src/Core/Common/GenerateOffsetsShapedImageNeighborhood/Code.cxx.

Definition at line 71 of file itkSize.h.

Public Types

using const_iterator = const value_type *
 
using const_reference = const value_type &
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using difference_type = ptrdiff_t
 
using iterator = value_type *
 
using reference = value_type &
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using Self = Size
 
using size_type = unsigned int
 
using SizeType = Size< VDimension >
 
using SizeValueType = itk::SizeValueType
 
using value_type = itk::SizeValueType
 

Public Member Functions

void assign (const value_type &newValue)
 
reference at (size_type pos)
 
const_reference at (size_type pos) const
 
reference back ()
 
const_reference back () const
 
constexpr iterator begin ()
 
constexpr const_iterator begin () const
 
constexpr SizeValueType CalculateProductOfElements () const
 
constexpr const_iterator cbegin () const
 
constexpr const_iterator cend () const
 
SizeValueTypedata ()
 
const SizeValueTypedata () const
 
constexpr bool empty () const
 
constexpr iterator end ()
 
constexpr const_iterator end () const
 
void Fill (SizeValueType value)
 
reference front ()
 
const_reference front () const
 
SizeValueType GetElement (unsigned long element) const
 
const SizeValueTypeGetSize () const
 
constexpr size_type max_size () const
 
const Self operator* (const Self &vec) const
 
const Self operator+ (const Self &vec) const
 
const Self operator- (const Self &vec) const
 
constexpr reference operator[] (size_type pos)
 
constexpr const_reference operator[] (size_type pos) const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
void SetElement (unsigned long element, SizeValueType val)
 
void SetSize (const SizeValueType val[VDimension])
 
constexpr size_type size () const
 
void swap (Size &other)
 
const Selfoperator+= (const Self &vec)
 
const Selfoperator-= (const Self &vec)
 
const Selfoperator*= (const Self &vec)
 

Static Public Member Functions

static constexpr Self Filled (const SizeValueType value)
 
static constexpr unsigned int GetSizeDimension ()
 

Public Attributes

SizeValueType m_InternalArray [VDimension]
 

Static Public Attributes

static constexpr unsigned int Dimension = VDimension
 

Private Member Functions

void ExceptionThrowingBoundsCheck (size_type pos) const
 

Member Typedef Documentation

◆ const_iterator

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::const_iterator = const value_type *

Definition at line 259 of file itkSize.h.

◆ const_reference

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::const_reference = const value_type &

Definition at line 257 of file itkSize.h.

◆ const_reverse_iterator

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 263 of file itkSize.h.

◆ difference_type

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::difference_type = ptrdiff_t

Definition at line 261 of file itkSize.h.

◆ iterator

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::iterator = value_type *

Definition at line 258 of file itkSize.h.

◆ reference

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::reference = value_type &

Definition at line 256 of file itkSize.h.

◆ reverse_iterator

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 262 of file itkSize.h.

◆ Self

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::Self = Size

Standard class type aliases.

Definition at line 78 of file itkSize.h.

◆ size_type

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::size_type = unsigned int

Definition at line 260 of file itkSize.h.

◆ SizeType

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::SizeType = Size<VDimension>

Compatible Size and value type alias

Definition at line 81 of file itkSize.h.

◆ SizeValueType

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::SizeValueType = itk::SizeValueType

Definition at line 82 of file itkSize.h.

◆ value_type

template<unsigned int VDimension = 2>
using itk::Size< VDimension >::value_type = itk::SizeValueType

Mirror the std::array type aliases and member function so that the Size class can be treated as a container class in a way that is similar to the std::array.

Definition at line 255 of file itkSize.h.

Member Function Documentation

◆ assign()

template<unsigned int VDimension = 2>
void itk::Size< VDimension >::assign ( const value_type newValue)
inline

Mirror behavior of the std::array manipulations See std::array for documentation on these methods

Definition at line 270 of file itkSize.h.

◆ at() [1/2]

template<unsigned int VDimension = 2>
reference itk::Size< VDimension >::at ( size_type  pos)
inline

Definition at line 364 of file itkSize.h.

◆ at() [2/2]

template<unsigned int VDimension = 2>
const_reference itk::Size< VDimension >::at ( size_type  pos) const
inline

Definition at line 371 of file itkSize.h.

◆ back() [1/2]

template<unsigned int VDimension = 2>
reference itk::Size< VDimension >::back ( )
inline

Definition at line 390 of file itkSize.h.

◆ back() [2/2]

template<unsigned int VDimension = 2>
const_reference itk::Size< VDimension >::back ( ) const
inline

Definition at line 396 of file itkSize.h.

◆ begin() [1/2]

template<unsigned int VDimension = 2>
constexpr iterator itk::Size< VDimension >::begin ( )
inlineconstexpr

◆ begin() [2/2]

template<unsigned int VDimension = 2>
constexpr const_iterator itk::Size< VDimension >::begin ( ) const
inlineconstexpr

Definition at line 294 of file itkSize.h.

◆ CalculateProductOfElements()

template<unsigned int VDimension = 2>
constexpr SizeValueType itk::Size< VDimension >::CalculateProductOfElements ( ) const
inlineconstexpr

Multiplies all elements. Yields the number of pixels of an image of this size.

Definition at line 220 of file itkSize.h.

◆ cbegin()

template<unsigned int VDimension = 2>
constexpr const_iterator itk::Size< VDimension >::cbegin ( ) const
inlineconstexpr

Definition at line 282 of file itkSize.h.

◆ cend()

template<unsigned int VDimension = 2>
constexpr const_iterator itk::Size< VDimension >::cend ( ) const
inlineconstexpr

Definition at line 300 of file itkSize.h.

◆ data() [1/2]

template<unsigned int VDimension = 2>
SizeValueType* itk::Size< VDimension >::data ( )
inline

Definition at line 402 of file itkSize.h.

◆ data() [2/2]

template<unsigned int VDimension = 2>
const SizeValueType* itk::Size< VDimension >::data ( ) const
inline

Definition at line 408 of file itkSize.h.

◆ empty()

template<unsigned int VDimension = 2>
constexpr bool itk::Size< VDimension >::empty ( ) const
inlineconstexpr

Definition at line 354 of file itkSize.h.

◆ end() [1/2]

template<unsigned int VDimension = 2>
constexpr iterator itk::Size< VDimension >::end ( )
inlineconstexpr

◆ end() [2/2]

template<unsigned int VDimension = 2>
constexpr const_iterator itk::Size< VDimension >::end ( ) const
inlineconstexpr

Definition at line 312 of file itkSize.h.

◆ ExceptionThrowingBoundsCheck()

template<unsigned int VDimension = 2>
void itk::Size< VDimension >::ExceptionThrowingBoundsCheck ( size_type  pos) const
inlineprivate

Definition at line 415 of file itkSize.h.

◆ Fill()

template<unsigned int VDimension = 2>
void itk::Size< VDimension >::Fill ( SizeValueType  value)
inline

Set one value for the index in all dimensions. Useful for initializing an offset to zero.

Definition at line 213 of file itkSize.h.

Referenced by itk::BinaryCrossStructuringElement< TPixel, VDimension, TAllocator >::BinaryCrossStructuringElement(), itk::BoxAccumulateFunction(), itk::BoxSquareAccumulateFunction(), and itk::CornerOffsets().

◆ Filled()

template<unsigned int VDimension = 2>
static constexpr Self itk::Size< VDimension >::Filled ( const SizeValueType  value)
inlinestaticconstexpr

Returns a Size object, filled with the specified value for each element.

Definition at line 427 of file itkSize.h.

◆ front() [1/2]

template<unsigned int VDimension = 2>
reference itk::Size< VDimension >::front ( )
inline

Definition at line 378 of file itkSize.h.

◆ front() [2/2]

template<unsigned int VDimension = 2>
const_reference itk::Size< VDimension >::front ( ) const
inline

Definition at line 384 of file itkSize.h.

◆ GetElement()

template<unsigned int VDimension = 2>
SizeValueType itk::Size< VDimension >::GetElement ( unsigned long  element) const
inline

Gets the value of one of the elements. This method is mainly intended to facilitate the access to elements from Tcl and Python where C++ notation is not very convenient.

Warning
No bound checking is performed
See also
GetSize()
SetElement()

Definition at line 205 of file itkSize.h.

◆ GetSize()

template<unsigned int VDimension = 2>
const SizeValueType* itk::Size< VDimension >::GetSize ( ) const
inline

Get the size. This provides a read only pointer to the size.

See also
SetSize

Definition at line 171 of file itkSize.h.

◆ GetSizeDimension()

template<unsigned int VDimension = 2>
static constexpr unsigned int itk::Size< VDimension >::GetSizeDimension ( )
inlinestaticconstexpr

Get the dimension.

Definition at line 89 of file itkSize.h.

◆ max_size()

template<unsigned int VDimension = 2>
constexpr size_type itk::Size< VDimension >::max_size ( ) const
inlineconstexpr

Definition at line 348 of file itkSize.h.

◆ operator*()

template<unsigned int VDimension = 2>
const Self itk::Size< VDimension >::operator* ( const Self vec) const
inline

Multiply two sizes (elementwise product).

Definition at line 145 of file itkSize.h.

◆ operator*=()

template<unsigned int VDimension = 2>
const Self& itk::Size< VDimension >::operator*= ( const Self vec)
inline

Multiply two sizes (elementwise product).

Definition at line 158 of file itkSize.h.

◆ operator+()

template<unsigned int VDimension = 2>
const Self itk::Size< VDimension >::operator+ ( const Self vec) const
inline

Add two sizes.

Definition at line 96 of file itkSize.h.

◆ operator+=()

template<unsigned int VDimension = 2>
const Self& itk::Size< VDimension >::operator+= ( const Self vec)
inline

Increment size by a size.

Definition at line 109 of file itkSize.h.

◆ operator-()

template<unsigned int VDimension = 2>
const Self itk::Size< VDimension >::operator- ( const Self vec) const
inline

Subtract two sizes.

Definition at line 121 of file itkSize.h.

◆ operator-=()

template<unsigned int VDimension = 2>
const Self& itk::Size< VDimension >::operator-= ( const Self vec)
inline

Decrement size by a size.

Definition at line 134 of file itkSize.h.

◆ operator[]() [1/2]

template<unsigned int VDimension = 2>
constexpr reference itk::Size< VDimension >::operator[] ( size_type  pos)
inlineconstexpr

Definition at line 359 of file itkSize.h.

◆ operator[]() [2/2]

template<unsigned int VDimension = 2>
constexpr const_reference itk::Size< VDimension >::operator[] ( size_type  pos) const
inlineconstexpr

Definition at line 361 of file itkSize.h.

◆ rbegin() [1/2]

template<unsigned int VDimension = 2>
reverse_iterator itk::Size< VDimension >::rbegin ( )
inline

Definition at line 318 of file itkSize.h.

◆ rbegin() [2/2]

template<unsigned int VDimension = 2>
const_reverse_iterator itk::Size< VDimension >::rbegin ( ) const
inline

Definition at line 324 of file itkSize.h.

◆ rend() [1/2]

template<unsigned int VDimension = 2>
reverse_iterator itk::Size< VDimension >::rend ( )
inline

Definition at line 330 of file itkSize.h.

◆ rend() [2/2]

template<unsigned int VDimension = 2>
const_reverse_iterator itk::Size< VDimension >::rend ( ) const
inline

Definition at line 336 of file itkSize.h.

◆ SetElement()

template<unsigned int VDimension = 2>
void itk::Size< VDimension >::SetElement ( unsigned long  element,
SizeValueType  val 
)
inline

Sets the value of one of the elements. This method is mainly intended to facilitate the access to elements from Tcl and Python where C++ notation is not very convenient.

Warning
No bound checking is performed.
See also
SetSize()
GetElement()

Definition at line 193 of file itkSize.h.

◆ SetSize()

template<unsigned int VDimension = 2>
void itk::Size< VDimension >::SetSize ( const SizeValueType  val[VDimension])
inline

Set the size. Try to prototype this function so that val has to point to a block of memory that is the appropriate size.

See also
GetSize

Definition at line 181 of file itkSize.h.

Referenced by itk::ScanlineFilterCommon< TInputImage, TOutputImage >::SetupLineOffsets().

◆ size()

template<unsigned int VDimension = 2>
constexpr size_type itk::Size< VDimension >::size ( ) const
inlineconstexpr

Definition at line 342 of file itkSize.h.

◆ swap()

template<unsigned int VDimension = 2>
void itk::Size< VDimension >::swap ( Size< VDimension > &  other)
inline

Definition at line 276 of file itkSize.h.

Member Data Documentation

◆ Dimension

template<unsigned int VDimension = 2>
constexpr unsigned int itk::Size< VDimension >::Dimension = VDimension
staticconstexpr

Dimension constant

Definition at line 85 of file itkSize.h.

◆ m_InternalArray

template<unsigned int VDimension = 2>
SizeValueType itk::Size< VDimension >::m_InternalArray[VDimension]

The documentation for this struct was generated from the following file: