7 #ifndef vtkDataArrayTupleRange_AOS_h
8 #define vtkDataArrayTupleRange_AOS_h
13 #include "vtkDebugRangeIterators.h"
18 #include <type_traits>
21 #ifndef VTK_DEBUG_RANGE_ITERATORS
29 VTK_ABI_NAMESPACE_BEGIN
32 template <
typename ArrayType, ComponentIdType>
34 template <
typename ArrayType, ComponentIdType>
36 template <
typename ArrayType, ComponentIdType>
38 template <
typename ArrayType, ComponentIdType>
40 template <
typename ArrayType, ComponentIdType>
45 template <
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);
223 const ValueType* Tuple;
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;
527 this->NumComps = o.NumComps;
536 template <
typename ValueType, ComponentIdType TupleSize>
555 : Ref(tuple, numComps)
566 ConstTupleIterator(
const ConstTupleIterator& o) noexcept =
default;
568 ConstTupleIterator&
operator=(
const ConstTupleIterator& o) noexcept =
default;
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;
650 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
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;
689 template <
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;
755 return reference{ this->Ref.Tuple + i * this->Ref.
NumComps.value, this->Ref.NumComps };
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;
800 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
814 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
820 swap(lhs.GetTuple(), rhs.GetTuple());
821 swap(lhs.GetNumComps(), rhs.GetNumComps());
828 ValueType*
GetTuple() const noexcept {
return this->Ref.Tuple; }
830 ValueType*&
GetTuple() noexcept {
return this->Ref.Tuple; }
841 template <
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);
914 return static_cast<size_type>(this->EndTuple - this->BeginTuple) /
915 static_cast<size_type>(this->
NumComps.value);
953 ValueType* GetTuplePointer(ArrayType* array,
vtkIdType tuple)
const noexcept
955 return array->GetPointer(tuple * this->
NumComps.value);
959 TupleIdType GetTupleId(
const ValueType* ptr)
const noexcept
964 mutable ArrayType*
Array{
nullptr };
966 ValueType* BeginTuple{
nullptr };
967 ValueType* EndTuple{
nullptr };
973 typename ValueType =
typename ArrayType::ValueType,
979 VTK_ABI_NAMESPACE_END
985 #endif // VTK_DEBUG_RANGE_ITERATORS
986 #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