19#ifndef vtkDataArrayTupleRange_AOS_h
20#define vtkDataArrayTupleRange_AOS_h
25#include "vtkDebugRangeIterators.h"
33#ifndef VTK_DEBUG_RANGE_ITERATORS
44template <
typename ArrayType, ComponentIdType>
45struct ConstTupleReference;
46template <
typename ArrayType, ComponentIdType>
48template <
typename ArrayType, ComponentIdType>
49struct ConstTupleIterator;
50template <
typename ArrayType, ComponentIdType>
52template <
typename ArrayType, ComponentIdType>
57template <
typename ValueType, ComponentIdType TupleSize>
63 using APIType = ValueType;
118 tuple[i] = this->Tuple[i];
123 template <
typename OArrayType, ComponentIdType OSize>
130 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
133 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
135 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
139 template <
typename OArrayType, ComponentIdType OSize>
146 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
149 if (other.size() != this->
NumComps.value)
154 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
158 template <
typename OArrayType, ComponentIdType OSize>
165 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
168 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
170 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
174 template <
typename OArrayType, ComponentIdType OSize>
181 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
184 if (other.size() != this->
NumComps.value)
189 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
192 template <
typename OArrayType, ComponentIdType OSize>
195 return !(*
this == o);
198 template <
typename OArray, ComponentIdType OSize>
201 return !(*
this == o);
241template <
typename ValueType, ComponentIdType TupleSize>
247 using APIType = ValueType;
283 void GetTuple(
volatile APIType* tuple)
const noexcept
297 tuple[i] = this->Tuple[i];
305 volatile APIType* out = this->Tuple;
318 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
322 template <
typename OArrayType, ComponentIdType OSize>
329 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
332 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
334 std::copy_n(other.cbegin(), OSize, this->begin());
338 template <
typename OArrayType, ComponentIdType OSize>
345 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
349 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
353 template <
typename OArrayType, ComponentIdType OSize>
360 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
363 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
365 std::copy_n(other.cbegin(), OSize, this->begin());
369 template <
typename OArrayType, ComponentIdType OSize>
376 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
380 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
385 template <
typename OArrayType, ComponentIdType OSize>
392 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
395 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
397 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
401 template <
typename OArrayType, ComponentIdType OSize>
408 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
412 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
416 template <
typename OArrayType, ComponentIdType OSize>
423 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
426 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
428 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
432 template <
typename OArrayType, ComponentIdType OSize>
439 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
443 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
446 template <
typename OArrayType, ComponentIdType OSize>
449 return !(*
this == o);
452 template <
typename OArray, ComponentIdType OSize>
455 return !(*
this == o);
459 template <
typename OArrayType, ComponentIdType OSize>
465 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
468 static_assert(TupleSize == OSize,
"Cannot swap tuples with different sizes.");
470 std::swap_ranges(this->
begin(), this->
end(), other.begin());
474 template <
typename OArrayType, ComponentIdType OSize>
480 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
484 std::swap_ranges(this->
begin(), this->
end(), other.begin());
489 template <
typename OArray, ComponentIdType OSize>
538 this->Tuple = o.Tuple;
548template <
typename ValueType, ComponentIdType TupleSize>
567 : Ref(tuple, numComps)
585 this->Ref.Tuple += this->Ref.NumComps.value;
592 auto tuple = this->Ref.Tuple;
593 this->Ref.Tuple += this->Ref.NumComps.value;
600 this->Ref.Tuple -= this->Ref.NumComps.value;
607 auto tuple = this->Ref.Tuple;
608 this->Ref.Tuple -= this->Ref.NumComps.value;
615 return reference{ this->Ref.Tuple + i * this->Ref.NumComps, this->Ref.NumComps };
624#define VTK_TMP_MAKE_OPERATOR(OP) \
625 friend VTK_ITER_INLINE bool operator OP( \
626 const ConstTupleIterator& lhs, const ConstTupleIterator& rhs) noexcept \
628 return lhs.GetTuple() OP rhs.GetTuple(); \
638#undef VTK_TMP_MAKE_OPERATOR
643 this->Ref.Tuple += offset * this->Ref.NumComps.value;
650 return ConstTupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
656 return ConstTupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
662 this->Ref.Tuple -= offset * this->Ref.NumComps.value;
669 return ConstTupleIterator{ it.GetTuple() - offset * it.GetNumComps().value, it.GetNumComps() };
676 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
682 swap(lhs.GetTuple(), rhs.GetTuple());
683 swap(lhs.GetNumComps(), rhs.GetNumComps());
688 const ValueType*& GetTuple() noexcept {
return this->Ref.Tuple; }
690 const ValueType* GetTuple() const noexcept {
return this->Ref.Tuple; }
692 NumCompsType& GetNumComps() noexcept {
return this->Ref.NumComps; }
694 NumCompsType GetNumComps() const noexcept {
return this->Ref.NumComps; }
696 ConstTupleReference<ArrayType, TupleSize> Ref;
701template <
typename ValueType, ComponentIdType TupleSize>
720 :
Ref(tuple, numComps)
730 this->
Ref.CopyReference(o.Ref);
737 this->
Ref.Tuple += this->
Ref.NumComps.value;
744 auto tuple = this->
Ref.Tuple;
745 this->
Ref.Tuple += this->
Ref.NumComps.value;
752 this->
Ref.Tuple -= this->
Ref.NumComps.value;
759 auto tuple = this->
Ref.Tuple;
760 this->
Ref.Tuple -= this->
Ref.NumComps.value;
774#define VTK_TMP_MAKE_OPERATOR(OP) \
775 friend VTK_ITER_INLINE bool operator OP( \
776 const TupleIterator& lhs, const TupleIterator& rhs) noexcept \
778 return lhs.GetTuple() OP rhs.GetTuple(); \
788#undef VTK_TMP_MAKE_OPERATOR
793 this->
Ref.Tuple += offset * this->
Ref.NumComps.value;
800 return TupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
806 return TupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
812 this->
Ref.Tuple -= offset * this->
Ref.NumComps.value;
819 return TupleIterator{ it.GetTuple() - offset * it.GetNumComps().value, it.GetNumComps() };
826 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
832 swap(lhs.GetTuple(), rhs.GetTuple());
833 swap(lhs.GetNumComps(), rhs.GetNumComps());
853template <
typename ValueType, ComponentIdType TupleSize>
892 , BeginTuple(
TupleRange::GetTuplePointer(arr, beginTuple))
893 , EndTuple(
TupleRange::GetTuplePointer(arr, endTuple))
896 assert(beginTuple >= 0 && beginTuple <= endTuple);
897 assert(endTuple >= 0 && endTuple <= this->Array->GetNumberOfTuples());
903 const TupleIdType curBegin = this->GetTupleId(this->BeginTuple);
904 const TupleIdType realBegin = curBegin + beginTuple;
906 endTuple >= 0 ? curBegin + endTuple : this->GetTupleId(this->EndTuple);
908 return TupleRange{ this->Array, realBegin, realEnd };
926 return static_cast<size_type>(this->EndTuple - this->BeginTuple) /
927 static_cast<size_type>(this->NumComps.value);
954 return reference{ this->BeginTuple + i * this->NumComps.value, this->NumComps };
960 return const_reference{ this->BeginTuple + i * this->NumComps.value, this->NumComps };
967 return array->GetPointer(tuple * this->NumComps.value);
971 TupleIdType GetTupleId(
const ValueType* ptr)
const noexcept
973 return static_cast<TupleIdType>((ptr - this->Array->GetPointer(0)) / this->NumComps.value);
977 NumCompsType NumComps{};
978 ValueType* BeginTuple{
nullptr };
979 ValueType* EndTuple{
nullptr };
985 typename ValueType =
typename ArrayType::ValueType,
988 typename =
typename std::enable_if<IsAOSDataArray<ArrayType>::value>::type>
Array-Of-Structs implementation of vtkGenericDataArray.
typename std::enable_if< IsEitherTupleSizeDynamic< S1, S2 >::value, T >::type EnableIfEitherTupleSizeIsDynamic
TupleRange< AOSArrayType, TupleSize > DeclareTupleRangeSpecialization(ArrayType *)
typename std::enable_if< AreStaticTupleSizes< S1, S2 >::value, T >::type EnableIfStaticTupleSizes
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
typename detail::GetAPITypeImpl< ArrayType >::APIType GetAPIType
TupleIdType difference_type
friend VTK_ITER_INLINE void swap(ConstTupleIterator &lhs, ConstTupleIterator &rhs) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE ConstTupleIterator operator--(int) noexcept
std::random_access_iterator_tag iterator_category
friend VTK_ITER_INLINE ConstTupleIterator operator+(difference_type offset, const ConstTupleIterator &it) noexcept
friend VTK_ITER_INLINE ConstTupleIterator operator+(const ConstTupleIterator &it, difference_type offset) noexcept
friend VTK_ITER_INLINE ConstTupleIterator operator-(const ConstTupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator--() noexcept
VTK_ITER_INLINE pointer & operator->() noexcept
VTK_ITER_INLINE ConstTupleIterator(const TupleIterator< ArrayType, TupleSize > &o) noexcept
friend VTK_ITER_INLINE difference_type operator-(const ConstTupleIterator &it1, const ConstTupleIterator &it2) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator=(const ConstTupleIterator &o) noexcept=default
VTK_ITER_INLINE ConstTupleIterator(const ConstTupleIterator &o) noexcept=default
VTK_ITER_INLINE reference operator*() noexcept
VTK_ITER_INLINE ConstTupleIterator operator++(int) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator++() noexcept
VTK_ITER_INLINE ConstTupleIterator() noexcept=default
friend VTK_ITER_INLINE void swap(ConstTupleIterator &lhs, ConstTupleIterator &rhs) noexcept
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
VTK_ITER_INLINE ConstTupleReference(const ConstTupleReference &) noexcept=default
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
const ValueType & const_reference
VTK_ITER_INLINE const ConstTupleReference * operator->() const noexcept
ComponentIdType size_type
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE ConstTupleReference(ConstTupleReference &&) noexcept=default
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE ConstTupleReference & operator=(const ConstTupleReference &) noexcept=default
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE void GetTuple(volatile APIType *tuple) const noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE ConstTupleReference(const ValueType *tuple, NumCompsType numComps) noexcept
VTK_ITER_INLINE ConstTupleReference() noexcept
const ValueType * iterator
VTK_ITER_INLINE ConstTupleReference(const TupleReference< ArrayType, TupleSize > &o) noexcept
const ValueType * const_iterator
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE TupleIterator() noexcept=default
VTK_ITER_INLINE NumCompsType GetNumComps() const noexcept
VTK_ITER_INLINE TupleIterator & operator--() noexcept
VTK_ITER_INLINE TupleIterator operator++(int) noexcept
friend VTK_ITER_INLINE TupleIterator operator+(const TupleIterator &it, difference_type offset) noexcept
TupleIdType difference_type
std::random_access_iterator_tag iterator_category
VTK_ITER_INLINE TupleIterator operator--(int) noexcept
VTK_ITER_INLINE TupleIterator & operator++() noexcept
VTK_ITER_INLINE NumCompsType & GetNumComps() noexcept
friend VTK_ITER_INLINE TupleIterator operator-(const TupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE TupleIterator & operator=(const TupleIterator &o) noexcept
reference operator*() noexcept
VTK_ITER_INLINE ValueType * GetTuple() const noexcept
VTK_ITER_INLINE TupleIterator(const TupleIterator &o) noexcept=default
pointer & operator->() noexcept
TupleReference< ArrayType, TupleSize > Ref
friend VTK_ITER_INLINE TupleIterator operator+(difference_type offset, const TupleIterator &it) noexcept
VTK_ITER_INLINE TupleIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE ValueType *& GetTuple() noexcept
VTK_ITER_INLINE TupleIterator & operator+=(difference_type offset) noexcept
friend VTK_ITER_INLINE difference_type operator-(const TupleIterator &it1, const TupleIterator &it2) noexcept
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
friend VTK_ITER_INLINE void swap(TupleIterator &lhs, TupleIterator &rhs) noexcept
TupleReference< ArrayType, TupleSize > Ref
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
GetAPIType< ArrayType > APIType
VTK_ITER_INLINE TupleRange() noexcept=default
APIType & ComponentReferenceType
VTK_ITER_INLINE reference operator[](size_type i) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE TupleIdType GetEndTupleId() const noexcept
APIType * ComponentIteratorType
VTK_ITER_INLINE ArrayType * GetArray() const noexcept
VTK_ITER_INLINE ComponentIdType GetTupleSize() const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE TupleIdType GetBeginTupleId() const noexcept
VTK_ITER_INLINE TupleRange GetSubRange(TupleIdType beginTuple=0, TupleIdType endTuple=-1) const noexcept
const APIType & ConstComponentReferenceType
VTK_ITER_INLINE iterator end() noexcept
APIType const * ConstComponentIteratorType
VTK_ITER_INLINE iterator begin() noexcept
GetAPIType< ArrayType > APIType
static constexpr ComponentIdType TupleSizeTag
TupleIterator< ArrayType, TupleSize > TupleIteratorType
ConstTupleIterator< ArrayType, TupleSize > ConstTupleIteratorType
ConstTupleIteratorType const_iterator
TupleReference< ArrayType, TupleSize > TupleReferenceType
ConstTupleReference< ArrayType, TupleSize > ConstTupleReferenceType
TupleIteratorType iterator
VTK_ITER_INLINE TupleReference() noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE const TupleReference * operator->() const noexcept
VTK_ITER_INLINE TupleReference & operator=(const TupleReference &other) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference b) noexcept
VTK_ITER_INLINE void GetTuple(volatile APIType *tuple) const noexcept
VTK_ITER_INLINE TupleReference(ValueType *tuple, NumCompsType numComps) noexcept
const ValueType * const_iterator
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, TupleReference & > operator=(const TupleReference< OArrayType, OSize > &other) noexcept
ValueType const & const_reference
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE iterator end() noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE reference operator[](size_type i) noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE void fill(const value_type &v) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const TupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE void SetTuple(const APIType *tuple) noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE TupleReference(const TupleReference &) noexcept=default
VTK_ITER_INLINE TupleReference(TupleReference &&) noexcept=default
VTK_ITER_INLINE void CopyReference(const TupleReference &o) noexcept
ComponentIdType size_type
VTK_ITER_INLINE size_type size() const noexcept
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference< OArray, OSize > b) noexcept
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE iterator end() noexcept
#define VTK_TMP_MAKE_OPERATOR(OP)