19 #ifndef vtkDataArrayTupleRange_AOS_h
20 #define vtkDataArrayTupleRange_AOS_h
25 #include "vtkDebugRangeIterators.h"
30 #include <type_traits>
33 #ifndef VTK_DEBUG_RANGE_ITERATORS
44 template <
typename ArrayType, ComponentIdType>
46 template <
typename ArrayType, ComponentIdType>
48 template <
typename ArrayType, ComponentIdType>
50 template <
typename ArrayType, ComponentIdType>
52 template <
typename ArrayType, ComponentIdType>
57 template <
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);
235 const ValueType* Tuple;
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;
539 this->NumComps = o.NumComps;
548 template <
typename ValueType, ComponentIdType TupleSize>
567 : Ref(tuple, numComps)
578 ConstTupleIterator(
const ConstTupleIterator& o) noexcept =
default;
580 ConstTupleIterator&
operator=(
const ConstTupleIterator& o) noexcept =
default;
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;
662 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
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;
701 template <
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;
767 return reference{ this->Ref.Tuple + i * this->Ref.
NumComps.value, this->Ref.NumComps };
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;
812 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
826 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
832 swap(lhs.GetTuple(), rhs.GetTuple());
833 swap(lhs.GetNumComps(), rhs.GetNumComps());
840 ValueType*
GetTuple() const noexcept {
return this->Ref.Tuple; }
842 ValueType*&
GetTuple() noexcept {
return this->Ref.Tuple; }
853 template <
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);
926 return static_cast<size_type>(this->EndTuple - this->BeginTuple) /
927 static_cast<size_type>(this->
NumComps.value);
965 ValueType* GetTuplePointer(ArrayType* array,
vtkIdType tuple)
const noexcept
967 return array->GetPointer(tuple * this->
NumComps.value);
971 TupleIdType GetTupleId(
const ValueType* ptr)
const noexcept
976 mutable ArrayType*
Array{
nullptr };
978 ValueType* BeginTuple{
nullptr };
979 ValueType* EndTuple{
nullptr };
985 typename ValueType =
typename ArrayType::ValueType,
996 #endif // VTK_DEBUG_RANGE_ITERATORS
997 #endif // vtkDataArrayTupleRange_AOS_h
TupleIdType difference_type
ComponentIdType size_type
VTK_ITER_INLINE ConstTupleIterator & operator--() noexcept
#define VTK_TMP_MAKE_OPERATOR(OP)
friend VTK_ITER_INLINE ConstTupleIterator operator+(difference_type offset, const ConstTupleIterator &it) noexcept
const ValueType * const_iterator
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE TupleIterator & operator++() noexcept
VTK_ITER_INLINE ConstTupleIterator operator++(int) noexcept
VTK_ITER_INLINE const TupleReference * operator->() const 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
APIType & ComponentReferenceType
VTK_ITER_INLINE TupleIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE TupleIterator & operator=(const TupleIterator &o) noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE void GetTuple(APIType *tuple) const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
const ValueType * const_iterator
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE NumCompsType GetNumComps() const noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
friend VTK_ITER_INLINE difference_type operator-(const TupleIterator &it1, const TupleIterator &it2) noexcept
ValueType const & const_reference
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const TupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE iterator end() noexcept
typename std::enable_if< IsEitherTupleSizeDynamic< S1, S2 >::value, T >::type EnableIfEitherTupleSizeIsDynamic
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE ConstTupleIterator operator--(int) noexcept
ConstComponentIterator< ArrayType, TupleSize > const_iterator
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
reference operator*() noexcept
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference< OArray, OSize > b) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
friend VTK_ITER_INLINE difference_type operator-(const ConstTupleIterator &it1, const ConstTupleIterator &it2) noexcept
VTK_ITER_INLINE TupleReference() noexcept
std::random_access_iterator_tag iterator_category
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE ConstTupleIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator++() noexcept
VTK_ITER_INLINE ConstTupleReference(const TupleReference< ArrayType, TupleSize > &o) noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE TupleIterator operator++(int) noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE reference operator[](size_type i) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE ComponentIdType GetTupleSize() const noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE size_type size() const noexcept
GetAPIType< ArrayType > APIType
VTK_ITER_INLINE ArrayType * GetArray() const noexcept
const ValueType * iterator
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
Array-Of-Structs implementation of vtkGenericDataArray.
APIType const * ConstComponentIteratorType
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE void GetTuple(volatile APIType *tuple) const noexcept
VTK_ITER_INLINE void GetTuple(volatile APIType *tuple) const noexcept
friend VTK_ITER_INLINE TupleIterator operator+(difference_type offset, const TupleIterator &it) noexcept
TupleIdType difference_type
VTK_ITER_INLINE ConstTupleReference() noexcept
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
friend VTK_ITER_INLINE void swap(TupleIterator &lhs, TupleIterator &rhs) noexcept
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference b) noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE const ConstTupleReference * operator->() const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, TupleReference & > operator=(const TupleReference< OArrayType, OSize > &other) noexcept
friend VTK_ITER_INLINE TupleIterator operator-(const TupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE iterator end() noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
friend VTK_ITER_INLINE TupleIterator operator+(const TupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE reference operator[](size_type i) noexcept
const APIType & ConstComponentReferenceType
ConstComponentIterator< ArrayType, TupleSize > iterator
ComponentIdType size_type
VTK_ITER_INLINE ValueType *& GetTuple() noexcept
TupleReference< ArrayType, TupleSize > Ref
friend VTK_ITER_INLINE ConstTupleIterator operator-(const ConstTupleIterator &it, difference_type offset) noexcept
TupleRange< AOSArrayType, TupleSize > DeclareTupleRangeSpecialization(ArrayType *)
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
VTK_ITER_INLINE void CopyReference(const TupleReference &o) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
VTK_ITER_INLINE TupleIdType GetBeginTupleId() const noexcept
const ValueType & const_reference
VTK_ITER_INLINE TupleIterator operator--(int) noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
typename detail::GetAPITypeImpl< ArrayType >::APIType GetAPIType
friend VTK_ITER_INLINE ConstTupleIterator operator+(const ConstTupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE ValueType * GetTuple() const noexcept
VTK_ITER_INLINE TupleReference & operator=(const TupleReference &other) noexcept
VTK_ITER_INLINE NumCompsType & GetNumComps() noexcept
VTK_ITER_INLINE pointer & operator->() noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
pointer & operator->() noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
std::random_access_iterator_tag iterator_category
VTK_ITER_INLINE ConstTupleReference(const ValueType *tuple, NumCompsType numComps) noexcept
VTK_ITER_INLINE ConstTupleReference & operator=(const ConstTupleReference &) noexcept=default
VTK_ITER_INLINE TupleIterator & operator--() noexcept
VTK_ITER_INLINE void fill(const value_type &v) noexcept
VTK_ITER_INLINE reference operator*() noexcept
VTK_ITER_INLINE TupleIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE void SetTuple(const APIType *tuple) noexcept
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE TupleRange GetSubRange(TupleIdType beginTuple=0, TupleIdType endTuple=-1) const noexcept
VTK_ITER_INLINE ConstTupleIterator(const TupleIterator< ArrayType, TupleSize > &o) noexcept
APIType * ComponentIteratorType
VTK_ITER_INLINE ConstTupleReference() noexcept
friend VTK_ITER_INLINE void swap(ConstTupleIterator &lhs, ConstTupleIterator &rhs) noexcept
VTK_ITER_INLINE TupleReference(ValueType *tuple, NumCompsType numComps) noexcept
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
VTK_ITER_INLINE TupleIdType GetEndTupleId() const noexcept
typename std::enable_if< AreStaticTupleSizes< S1, S2 >::value, T >::type EnableIfStaticTupleSizes
VTK_ITER_INLINE const_iterator cend() const noexcept