|
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)
220 for (
unsigned int i = 0; i < VDimension; ++i)
222 result[i] = m_InternalArray[i] * static_cast<IndexValueType>(vec.
m_InternalArray[i]);
232 return m_InternalArray;
242 std::copy_n(val, VDimension, m_InternalArray);
254 m_InternalArray[element] = val;
266 return m_InternalArray[element];
274 std::fill_n(begin(), size(), value);
291 static_assert(VDimension > 0,
"Error: Only positive value sized VDimension allowed");
296 template <
typename TCoordRep>
300 for (
unsigned int i = 0; i < VDimension; ++i)
302 m_InternalArray[i] = Math::Round<IndexValueType>(
point[i]);
308 template <
typename TCoordRep>
312 for (
unsigned int i = 0; i < VDimension; ++i)
314 m_InternalArray[i] = static_cast<IndexValueType>(
point[i]);
323 GetBasisIndex(
unsigned int dim);
349 std::fill_n(begin(), size(), newValue);
358 constexpr const_iterator
361 return &m_InternalArray[0];
367 return &m_InternalArray[0];
370 constexpr const_iterator
373 return &m_InternalArray[0];
376 constexpr const_iterator
379 return &m_InternalArray[VDimension];
385 return &m_InternalArray[VDimension];
388 constexpr const_iterator
391 return &m_InternalArray[VDimension];
400 const_reverse_iterator
412 const_reverse_iterator
443 ExceptionThrowingBoundsCheck(pos);
444 return m_InternalArray[pos];
450 ExceptionThrowingBoundsCheck(pos);
451 return m_InternalArray[pos];
460 constexpr const_reference
469 return VDimension ? *(end() - 1) : *end();
472 constexpr const_reference
475 return VDimension ? *(end() - 1) : *end();
481 return &m_InternalArray[0];
487 return &m_InternalArray[0];
493 static constexpr
Self
496 return MakeFilled<Self>(value);
504 if (pos >= VDimension)
506 throw std::out_of_range(
"array::ExceptionThrowingBoundsCheck");
512 template <
unsigned int VDimension>
522 template <
unsigned int VDimension>
527 for (
unsigned int i = 0; i + 1 < VDimension; ++i)
529 os << obj[i] <<
", ";
531 if constexpr (VDimension >= 1)
533 os << obj[VDimension - 1];
541 template <
unsigned int VDimension>
548 template <
unsigned int VDimension>
552 return !(one == two);
555 template <
unsigned int VDimension>
559 return std::lexicographical_compare(one.
begin(), one.
end(), two.
begin(), two.
end());
562 template <
unsigned int VDimension>
569 template <
unsigned int VDimension>
576 template <
unsigned int VDimension>
584 template <
unsigned int VDimension>
593 template <
typename... T>
597 const auto toValueType = [](
const auto value) {
598 static_assert(std::is_integral_v<decltype(value)>,
"Each value must have an integral type!");
599 return static_cast<IndexValueType>(value);
601 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 assign(const value_type &newValue)
void CopyWithRound(const FixedArray< TCoordRep, VDimension > &point)
constexpr iterator begin()
const_reference at(size_type pos) const
void SetIndex(const IndexValueType val[VDimension])
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
void swap(Index< VDimension > &one, Index< VDimension > &two)
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
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.
void CopyWithCast(const FixedArray< TCoordRep, VDimension > &point)
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.
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)