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)
220 for (
unsigned int i = 0; i < VDimension; ++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)
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");
512template <
unsigned int VDimension>
522template <
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];
541template <
unsigned int VDimension>
548template <
unsigned int VDimension>
552 return !(one == two);
555template <
unsigned int VDimension>
559 return std::lexicographical_compare(one.
begin(), one.
end(), two.
begin(), two.
end());
562template <
unsigned int VDimension>
569template <
unsigned int VDimension>
576template <
unsigned int VDimension>
584template <
unsigned int VDimension>
593template <
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!");
601 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....
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
void swap(Index< VDimension > &one, Index< VDimension > &two)
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
void CopyWithCast(const FixedArray< TCoordRep, VDimension > &point)
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()
void CopyWithRound(const FixedArray< TCoordRep, VDimension > &point)
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
IndexValueType GetElement(unsigned long element) const
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)
constexpr const_reference back() const
const IndexValueType * data() const
void SetElement(unsigned long element, IndexValueType val)
const Self & operator+=(const SizeType &sz)
constexpr iterator begin()
const Self operator+(const OffsetType &offset) 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 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]