|
ITK
6.0.0
Insight Toolkit
|
Go to the documentation of this file.
25 #include <type_traits>
67 template <
unsigned int VDimension = 2>
68 struct 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)
118 m_InternalArray[i] += static_cast<IndexValueType>(sz[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)
144 m_InternalArray[i] -= static_cast<IndexValueType>(sz[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)
223 result[i] = m_InternalArray[i] * static_cast<IndexValueType>(vec.
m_InternalArray[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)
315 m_InternalArray[i] = static_cast<IndexValueType>(
point[i]);
324 GetBasisIndex(
unsigned int dim);
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");
521 template <
unsigned int VDimension>
531 template <
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];
550 template <
unsigned int VDimension>
557 template <
unsigned int VDimension>
561 return !(one == two);
564 template <
unsigned int VDimension>
568 return std::lexicographical_compare(one.
begin(), one.
end(), two.
begin(), two.
end());
571 template <
unsigned int VDimension>
578 template <
unsigned int VDimension>
585 template <
unsigned int VDimension>
593 template <
unsigned int VDimension>
597 std::swap(one.m_InternalArray, two.m_InternalArray);
602 template <
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!");
608 return static_cast<IndexValueType>(value);
610 return Index<
sizeof...(T)>{ { toValueType(values)... } };
constexpr const_reference operator[](size_type pos) const
std::reverse_iterator< const_iterator > const_reverse_iterator
Represent a n-dimensional index in a n-dimensional image.
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
constexpr const_iterator begin() const
bool operator<=(const Index< VDimension > &one, const Index< VDimension > &two)
constexpr size_type max_size() const
Represent a n-dimensional size (bounds) of a n-dimensional image.
constexpr reference back()
void CopyWithCast(const FixedArray< TCoordinate, VDimension > &point)
void assign(const value_type &newValue)
constexpr iterator begin()
const_reference at(size_type pos) const
void SetIndex(const IndexValueType val[VDimension])
void CopyWithRound(const FixedArray< TCoordinate, VDimension > &point)
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
const Self & operator+=(const OffsetType &offset)
itk::IndexValueType IndexValueType
const Self operator*(const SizeType &vec) const
const Self operator-(const OffsetType &off) const
constexpr reference front()
void SetElement(unsigned long element, IndexValueType val)
const Self operator+(const SizeType &sz) const
void Fill(IndexValueType value)
itk::OffsetValueType OffsetValueType
const Self operator+(const OffsetType &offset) const
void swap(Index &other) noexcept
constexpr const_reference front() const
constexpr const_reference back() const
const IndexValueType * GetIndex() const
const_reverse_iterator rend() const
*par Constraints *The filter requires an 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
reference at(size_type pos)
constexpr size_type size() const
constexpr const_iterator cend() const
const OffsetType operator-(const Self &vec) const
const value_type & const_reference
constexpr const_iterator cbegin() const
IndexValueType m_InternalArray[VDimension]
bool operator>=(const Index< VDimension > &one, const Index< VDimension > &two)
OffsetValueType m_InternalArray[VDimension]
const_reverse_iterator rbegin() const
bool operator>(const Index< VDimension > &one, const Index< VDimension > &two)
constexpr bool empty() const
ptrdiff_t difference_type
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)
Simulate a standard C array with copy semantics.
static constexpr unsigned int GetIndexDimension()
static constexpr Self Filled(const IndexValueType value)
IndexValueType GetElement(unsigned long element) const
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
void swap(Index< VDimension > &one, Index< VDimension > &two) noexcept
reverse_iterator rbegin()
itk::IndexValueType value_type
bool operator!=(const Index< VDimension > &one, const Index< VDimension > &two)
auto MakeIndex(const T... values)
SizeValueType m_InternalArray[VDimension]
void swap(Array< T > &a, Array< T > &b) noexcept
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
const IndexValueType * data() const
constexpr const_iterator end() const
static Self GetBasisIndex(unsigned int dim)
const Self & operator+=(const SizeType &sz)
const Self operator-(const SizeType &sz) const
const value_type * const_iterator
std::reverse_iterator< iterator > reverse_iterator
constexpr unsigned int Dimension
constexpr reference operator[](size_type pos)
void ExceptionThrowingBoundsCheck(size_type pos) const
const Self & operator-=(const SizeType &sz)
const Self & operator-=(const OffsetType &offset)