7#ifndef vtkDataArrayTupleRange_AOS_h
8#define vtkDataArrayTupleRange_AOS_h
13#include "vtkDebugRangeIterators.h"
21#ifndef VTK_DEBUG_RANGE_ITERATORS
29VTK_ABI_NAMESPACE_BEGIN
32template <
typename ArrayType, ComponentIdType>
33struct ConstTupleReference;
34template <
typename ArrayType, ComponentIdType>
36template <
typename ArrayType, ComponentIdType>
37struct ConstTupleIterator;
38template <
typename ArrayType, ComponentIdType>
40template <
typename ArrayType, ComponentIdType>
45template <
typename ValueType, ComponentIdType TupleSize>
51 using APIType = ValueType;
106 tuple[i] = this->Tuple[i];
111 template <
typename OArrayType, ComponentIdType OSize>
118 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
121 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
123 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
127 template <
typename OArrayType, ComponentIdType OSize>
134 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
137 if (other.size() != this->
NumComps.value)
142 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
146 template <
typename OArrayType, ComponentIdType OSize>
153 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
156 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
158 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
162 template <
typename OArrayType, ComponentIdType OSize>
169 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
172 if (other.size() != this->
NumComps.value)
177 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
180 template <
typename OArrayType, ComponentIdType OSize>
183 return !(*
this == o);
186 template <
typename OArray, ComponentIdType OSize>
189 return !(*
this == o);
229template <
typename ValueType, ComponentIdType TupleSize>
235 using APIType = ValueType;
271 void GetTuple(
volatile APIType* tuple)
const noexcept
285 tuple[i] = this->Tuple[i];
293 volatile APIType* out = this->Tuple;
306 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
310 template <
typename OArrayType, ComponentIdType OSize>
317 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
320 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
322 std::copy_n(other.cbegin(), OSize, this->begin());
326 template <
typename OArrayType, ComponentIdType OSize>
333 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
337 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
341 template <
typename OArrayType, ComponentIdType OSize>
348 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
351 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
353 std::copy_n(other.cbegin(), OSize, this->begin());
357 template <
typename OArrayType, ComponentIdType OSize>
364 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
368 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
373 template <
typename OArrayType, ComponentIdType OSize>
380 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
383 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
385 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
389 template <
typename OArrayType, ComponentIdType OSize>
396 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
400 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
404 template <
typename OArrayType, ComponentIdType OSize>
411 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
414 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
416 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
420 template <
typename OArrayType, ComponentIdType OSize>
427 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
431 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
434 template <
typename OArrayType, ComponentIdType OSize>
437 return !(*
this == o);
440 template <
typename OArray, ComponentIdType OSize>
443 return !(*
this == o);
447 template <
typename OArrayType, ComponentIdType OSize>
453 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
456 static_assert(TupleSize == OSize,
"Cannot swap tuples with different sizes.");
458 std::swap_ranges(this->
begin(), this->
end(), other.begin());
462 template <
typename OArrayType, ComponentIdType OSize>
468 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
472 std::swap_ranges(this->
begin(), this->
end(), other.begin());
477 template <
typename OArray, ComponentIdType OSize>
526 this->Tuple = o.Tuple;
536template <
typename ValueType, ComponentIdType TupleSize>
555 : Ref(tuple, numComps)
573 this->Ref.Tuple += this->Ref.NumComps.value;
580 auto tuple = this->Ref.Tuple;
581 this->Ref.Tuple += this->Ref.NumComps.value;
588 this->Ref.Tuple -= this->Ref.NumComps.value;
595 auto tuple = this->Ref.Tuple;
596 this->Ref.Tuple -= this->Ref.NumComps.value;
603 return reference{ this->Ref.Tuple + i * this->Ref.NumComps, this->Ref.NumComps };
612#define VTK_TMP_MAKE_OPERATOR(OP) \
613 friend VTK_ITER_INLINE bool operator OP( \
614 const ConstTupleIterator& lhs, const ConstTupleIterator& rhs) noexcept \
616 return lhs.GetTuple() OP rhs.GetTuple(); \
626#undef VTK_TMP_MAKE_OPERATOR
631 this->Ref.Tuple += offset * this->Ref.NumComps.value;
638 return ConstTupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
644 return ConstTupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
650 this->Ref.Tuple -= offset * this->Ref.NumComps.value;
657 return ConstTupleIterator{ it.GetTuple() - offset * it.GetNumComps().value, it.GetNumComps() };
664 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
670 swap(lhs.GetTuple(), rhs.GetTuple());
671 swap(lhs.GetNumComps(), rhs.GetNumComps());
676 const ValueType*& GetTuple() noexcept {
return this->Ref.Tuple; }
678 const ValueType* GetTuple() const noexcept {
return this->Ref.Tuple; }
680 NumCompsType& GetNumComps() noexcept {
return this->Ref.NumComps; }
682 NumCompsType GetNumComps() const noexcept {
return this->Ref.NumComps; }
684 ConstTupleReference<ArrayType, TupleSize> Ref;
689template <
typename ValueType, ComponentIdType TupleSize>
708 :
Ref(tuple, numComps)
718 this->
Ref.CopyReference(o.Ref);
725 this->
Ref.Tuple += this->
Ref.NumComps.value;
732 auto tuple = this->
Ref.Tuple;
733 this->
Ref.Tuple += this->
Ref.NumComps.value;
740 this->
Ref.Tuple -= this->
Ref.NumComps.value;
747 auto tuple = this->
Ref.Tuple;
748 this->
Ref.Tuple -= this->
Ref.NumComps.value;
762#define VTK_TMP_MAKE_OPERATOR(OP) \
763 friend VTK_ITER_INLINE bool operator OP( \
764 const TupleIterator& lhs, const TupleIterator& rhs) noexcept \
766 return lhs.GetTuple() OP rhs.GetTuple(); \
776#undef VTK_TMP_MAKE_OPERATOR
781 this->
Ref.Tuple += offset * this->
Ref.NumComps.value;
788 return TupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
794 return TupleIterator{ it.GetTuple() + offset * it.GetNumComps().value, it.GetNumComps() };
800 this->
Ref.Tuple -= offset * this->
Ref.NumComps.value;
807 return TupleIterator{ it.GetTuple() - offset * it.GetNumComps().value, it.GetNumComps() };
814 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
820 swap(lhs.GetTuple(), rhs.GetTuple());
821 swap(lhs.GetNumComps(), rhs.GetNumComps());
841template <
typename ValueType, ComponentIdType TupleSize>
880 , BeginTuple(
TupleRange::GetTuplePointer(arr, beginTuple))
881 , EndTuple(
TupleRange::GetTuplePointer(arr, endTuple))
884 assert(beginTuple >= 0 && beginTuple <= endTuple);
885 assert(endTuple >= 0 && endTuple <= this->Array->GetNumberOfTuples());
891 const TupleIdType curBegin = this->GetTupleId(this->BeginTuple);
892 const TupleIdType realBegin = curBegin + beginTuple;
894 endTuple >= 0 ? curBegin + endTuple : this->GetTupleId(this->EndTuple);
896 return TupleRange{ this->Array, realBegin, realEnd };
914 return static_cast<size_type>(this->EndTuple - this->BeginTuple) /
915 static_cast<size_type>(this->NumComps.value);
942 return reference{ this->BeginTuple + i * this->NumComps.value, this->NumComps };
948 return const_reference{ this->BeginTuple + i * this->NumComps.value, this->NumComps };
955 return array->GetPointer(tuple * this->NumComps.value);
959 TupleIdType GetTupleId(
const ValueType* ptr)
const noexcept
961 return static_cast<TupleIdType>((ptr - this->Array->GetPointer(0)) / this->NumComps.value);
965 NumCompsType NumComps{};
966 ValueType* BeginTuple{
nullptr };
967 ValueType* EndTuple{
nullptr };
973 typename ValueType =
typename ArrayType::ValueType,
976 typename =
typename std::enable_if<IsAOSDataArray<ArrayType>::value>::type>
Array-Of-Structs implementation of vtkGenericDataArray.
typename std::enable_if< AreStaticTupleSizes< S1, S2 >::value, T >::type EnableIfStaticTupleSizes
TupleRange< AOSArrayType, TupleSize > DeclareTupleRangeSpecialization(ArrayType *)
typename std::enable_if< IsEitherTupleSizeDynamic< S1, S2 >::value, T >::type EnableIfEitherTupleSizeIsDynamic
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)