ITK  6.0.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 69 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
 
constexpr reference back ()
 
constexpr 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)
 
constexpr reference front ()
 
constexpr 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 257 of file itkSize.h.

◆ const_reference

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

Definition at line 255 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 261 of file itkSize.h.

◆ difference_type

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

Definition at line 259 of file itkSize.h.

◆ iterator

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

Definition at line 256 of file itkSize.h.

◆ reference

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

Definition at line 254 of file itkSize.h.

◆ reverse_iterator

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

Definition at line 260 of file itkSize.h.

◆ Self

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

Standard class type aliases.

Definition at line 76 of file itkSize.h.

◆ size_type

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

Definition at line 258 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 79 of file itkSize.h.

◆ SizeValueType

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

Definition at line 80 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 253 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 268 of file itkSize.h.

◆ at() [1/2]

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

Definition at line 362 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 369 of file itkSize.h.

◆ back() [1/2]

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

Definition at line 388 of file itkSize.h.

◆ back() [2/2]

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

Definition at line 394 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 292 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 218 of file itkSize.h.

◆ cbegin()

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

Definition at line 280 of file itkSize.h.

◆ cend()

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

Definition at line 298 of file itkSize.h.

◆ data() [1/2]

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

Definition at line 400 of file itkSize.h.

◆ data() [2/2]

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

Definition at line 406 of file itkSize.h.

◆ empty()

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

Definition at line 352 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 310 of file itkSize.h.

◆ ExceptionThrowingBoundsCheck()

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

Definition at line 413 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 211 of file itkSize.h.

◆ 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 425 of file itkSize.h.

◆ front() [1/2]

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

Definition at line 376 of file itkSize.h.

◆ front() [2/2]

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

Definition at line 382 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 203 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 169 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 87 of file itkSize.h.

◆ max_size()

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

Definition at line 346 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 143 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 156 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 94 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 107 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 119 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 132 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 357 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 359 of file itkSize.h.

◆ rbegin() [1/2]

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

Definition at line 316 of file itkSize.h.

◆ rbegin() [2/2]

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

Definition at line 322 of file itkSize.h.

◆ rend() [1/2]

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

Definition at line 328 of file itkSize.h.

◆ rend() [2/2]

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

Definition at line 334 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 191 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 179 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 340 of file itkSize.h.

◆ swap()

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

Definition at line 274 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 83 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: