67template <
unsigned int VDimension = 2>
68struct ITK_TEMPLATE_EXPORT
Index final
89 static constexpr unsigned int Dimension = VDimension;
92 static constexpr unsigned int
105 for (
unsigned int i = 0; i < VDimension; ++i)
107 result[i] = m_InternalArray[i] +
static_cast<IndexValueType>(sz[i]);
116 for (
unsigned int i = 0; i < VDimension; ++i)
131 for (
unsigned int i = 0; i < VDimension; ++i)
133 result[i] = m_InternalArray[i] -
static_cast<IndexValueType>(sz[i]);
142 for (
unsigned int i = 0; i < VDimension; ++i)
156 for (
unsigned int i = 0; i < VDimension; ++i)
158 result[i] = m_InternalArray[i] + offset[i];
167 for (
unsigned int i = 0; i < VDimension; ++i)
169 m_InternalArray[i] += offset[i];
179 for (
unsigned int i = 0; i < VDimension; ++i)
181 m_InternalArray[i] -= offset[i];
193 for (
unsigned int i = 0; i < VDimension; ++i)
206 for (
unsigned int i = 0; i < VDimension; ++i)
221 for (
unsigned int i = 0; i < VDimension; ++i)
233 return m_InternalArray;
243 std::copy_n(val, VDimension, m_InternalArray);
255 m_InternalArray[element] = val;
267 return m_InternalArray[element];
275 std::fill_n(begin(), size(), value);
292 static_assert(VDimension > 0,
"Error: Only positive value sized VDimension allowed");
297 template <
typename TCoordinate>
301 for (
unsigned int i = 0; i < VDimension; ++i)
303 m_InternalArray[i] = Math::Round<IndexValueType>(
point[i]);
309 template <
typename TCoordinate>
313 for (
unsigned int i = 0; i < VDimension; ++i)
350 std::fill_n(begin(), size(), newValue);
356 std::swap(m_InternalArray, other.m_InternalArray);
359 constexpr const_iterator
362 return &m_InternalArray[0];
368 return &m_InternalArray[0];
371 constexpr const_iterator
374 return &m_InternalArray[0];
377 constexpr const_iterator
380 return &m_InternalArray[VDimension];
386 return &m_InternalArray[VDimension];
389 constexpr const_iterator
392 return &m_InternalArray[VDimension];
401 const_reverse_iterator
413 const_reverse_iterator
440 return m_InternalArray[pos];
443 constexpr const_reference
446 return m_InternalArray[pos];
452 ExceptionThrowingBoundsCheck(pos);
453 return m_InternalArray[pos];
459 ExceptionThrowingBoundsCheck(pos);
460 return m_InternalArray[pos];
469 constexpr const_reference
478 return VDimension ? *(end() - 1) : *end();
481 constexpr const_reference
484 return VDimension ? *(end() - 1) : *end();
490 return &m_InternalArray[0];
496 return &m_InternalArray[0];
502 static constexpr Self
505 return MakeFilled<Self>(value);
513 if (pos >= VDimension)
515 throw std::out_of_range(
"array::ExceptionThrowingBoundsCheck");
521template <
unsigned int VDimension>
531template <
unsigned int VDimension>
536 for (
unsigned int i = 0; i + 1 < VDimension; ++i)
538 os << obj[i] <<
", ";
540 if constexpr (VDimension >= 1)
542 os << obj[VDimension - 1];
550template <
unsigned int VDimension>
557template <
unsigned int VDimension>
561 return !(one == two);
564template <
unsigned int VDimension>
568 return std::lexicographical_compare(one.
begin(), one.
end(), two.
begin(), two.
end());
571template <
unsigned int VDimension>
578template <
unsigned int VDimension>
585template <
unsigned int VDimension>
593template <
unsigned int VDimension>
597 std::swap(one.m_InternalArray, two.m_InternalArray);
602template <
typename... T>
606 const auto toValueType = [](
const auto value) {
607 static_assert(std::is_integral_v<
decltype(value)>,
"Each value must have an integral type!");
610 return Index<
sizeof...(T)>{ { toValueType(values)... } };
Pixel-wise addition of two images.
Simulate a standard C array with copy semantics.
constexpr unsigned int Dimension
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
void swap(Index< VDimension > &one, Index< VDimension > &two) noexcept
auto MakeIndex(const T... values)
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
bool operator>(const Index< VDimension > &one, const Index< VDimension > &two)
bool operator<=(const Index< VDimension > &one, const Index< VDimension > &two)
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)
std::ostream & operator<<(std::ostream &os, const Index< VDimension > &obj)
bool operator!=(const Index< VDimension > &one, const Index< VDimension > &two)
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
bool operator>=(const Index< VDimension > &one, const Index< VDimension > &two)
Represent a n-dimensional index in a n-dimensional image.
constexpr const_reference operator[](size_type pos) const
const Self operator*(const SizeType &vec) const
const OffsetType operator-(const Self &vec) const
const Self & operator+=(const OffsetType &offset)
const value_type * const_iterator
constexpr reference front()
const Self & operator-=(const SizeType &sz)
const_reverse_iterator rbegin() const
static constexpr Self Filled(const IndexValueType value)
void assign(const value_type &newValue)
constexpr size_type max_size() const
reverse_iterator rbegin()
const_reverse_iterator rend() const
void ExceptionThrowingBoundsCheck(size_type pos) const
IndexValueType m_InternalArray[VDimension]
constexpr bool empty() const
constexpr size_type size() const
const IndexValueType * GetIndex() const
constexpr const_iterator begin() const
const Self operator-(const OffsetType &off) const
static Self GetBasisIndex(unsigned int dim)
itk::IndexValueType IndexValueType
reference at(size_type pos)
const Self operator+(const SizeType &sz) const
std::reverse_iterator< iterator > reverse_iterator
itk::IndexValueType value_type
const value_type & const_reference
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr reference operator[](size_type pos)
constexpr const_iterator end() const
constexpr reference back()
const Self operator-(const SizeType &sz) const
void Fill(IndexValueType value)
void CopyWithCast(const FixedArray< TCoordinate, VDimension > &point)
void CopyWithRound(const FixedArray< TCoordinate, VDimension > &point)
constexpr const_reference back() const
const IndexValueType * data() const
void SetElement(unsigned int element, IndexValueType val)
const Self & operator+=(const SizeType &sz)
constexpr iterator begin()
const Self operator+(const OffsetType &offset) const
IndexValueType GetElement(unsigned int element) const
ptrdiff_t difference_type
constexpr const_iterator cend() const
constexpr const_reference front() const
itk::OffsetValueType OffsetValueType
constexpr const_iterator cbegin() const
static constexpr unsigned int GetIndexDimension()
void swap(Index &other) noexcept
void SetIndex(const IndexValueType val[VDimension])
const Self & operator-=(const OffsetType &offset)
const_reference at(size_type pos) const
OffsetValueType m_InternalArray[VDimension]
SizeValueType m_InternalArray[VDimension]