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];
110 template <
typename VT = ValueType>
112 volatile double* tuple)
const noexcept
118 tuple[i] =
static_cast<double>(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];
301 template <
typename VT = ValueType>
303 volatile double* tuple)
const noexcept
309 tuple[i] =
static_cast<double>(this->Tuple[i]);
317 volatile APIType* out = this->Tuple;
326 template <
typename VT = ValueType>
328 const double* tuple) noexcept
330 volatile APIType* out = this->Tuple;
335 out[i] =
static_cast<APIType
>(tuple[i]);
342 std::copy_n(other.cbegin(), this->NumComps.value, this->
begin());
346 template <
typename OArrayType, ComponentIdType OSize>
353 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
356 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
358 std::copy_n(other.cbegin(), OSize, this->
begin());
362 template <
typename OArrayType, ComponentIdType OSize>
369 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
373 std::copy_n(other.cbegin(), this->NumComps.value, this->
begin());
377 template <
typename OArrayType, ComponentIdType OSize>
384 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
387 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
389 std::copy_n(other.cbegin(), OSize, this->
begin());
393 template <
typename OArrayType, ComponentIdType OSize>
400 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
404 std::copy_n(other.cbegin(), this->NumComps.value, this->
begin());
409 template <
typename OArrayType, ComponentIdType OSize>
416 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
419 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
421 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
425 template <
typename OArrayType, ComponentIdType OSize>
432 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
436 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
440 template <
typename OArrayType, ComponentIdType OSize>
447 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
450 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
452 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
456 template <
typename OArrayType, ComponentIdType OSize>
463 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
467 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
470 template <
typename OArrayType, ComponentIdType OSize>
473 return !(*
this == o);
476 template <
typename OArray, ComponentIdType OSize>
479 return !(*
this == o);
483 template <
typename OArrayType, ComponentIdType OSize>
489 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
492 static_assert(TupleSize == OSize,
"Cannot swap tuples with different sizes.");
494 std::swap_ranges(this->
begin(), this->
end(), other.begin());
498 template <
typename OArrayType, ComponentIdType OSize>
504 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
508 std::swap_ranges(this->
begin(), this->
end(), other.begin());
513 template <
typename OArray, ComponentIdType OSize>
562 this->Tuple = o.Tuple;
563 this->NumComps = o.NumComps;
572 template <
typename ValueType, ComponentIdType TupleSize>
591 : Ref(tuple, numComps)
602 ConstTupleIterator(
const ConstTupleIterator& o) noexcept =
default;
604 ConstTupleIterator&
operator=(
const ConstTupleIterator& o) noexcept =
default;
609 this->Ref.Tuple += this->Ref.NumComps.value;
616 auto tuple = this->Ref.Tuple;
617 this->Ref.Tuple += this->Ref.NumComps.value;
624 this->Ref.Tuple -= this->Ref.NumComps.value;
631 auto tuple = this->Ref.Tuple;
632 this->Ref.Tuple -= this->Ref.NumComps.value;
639 return reference{ this->Ref.Tuple + i * this->Ref.
NumComps, this->Ref.NumComps };
648 #define VTK_TMP_MAKE_OPERATOR(OP) \
649 friend VTK_ITER_INLINE bool operator OP( \
650 const ConstTupleIterator& lhs, const ConstTupleIterator& rhs) noexcept \
652 return lhs.GetTuple() OP rhs.GetTuple(); \
662 #undef VTK_TMP_MAKE_OPERATOR
667 this->Ref.Tuple +=
offset * this->Ref.NumComps.value;
686 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
700 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
706 swap(lhs.GetTuple(), rhs.GetTuple());
707 swap(lhs.GetNumComps(), rhs.GetNumComps());
712 const ValueType*&
GetTuple() noexcept {
return this->Ref.Tuple; }
714 const ValueType*
GetTuple() const noexcept {
return this->Ref.Tuple; }
716 NumCompsType& GetNumComps() noexcept {
return this->Ref.NumComps; }
718 NumCompsType GetNumComps() const noexcept {
return this->Ref.NumComps; }
720 ConstTupleReference<ArrayType, TupleSize> Ref;
725 template <
typename ValueType, ComponentIdType TupleSize>
744 : Ref(tuple, numComps)
754 this->Ref.CopyReference(o.Ref);
761 this->Ref.Tuple += this->Ref.NumComps.value;
768 auto tuple = this->Ref.Tuple;
769 this->Ref.Tuple += this->Ref.NumComps.value;
776 this->Ref.Tuple -= this->Ref.NumComps.value;
783 auto tuple = this->Ref.Tuple;
784 this->Ref.Tuple -= this->Ref.NumComps.value;
791 return reference{ this->Ref.Tuple + i * this->Ref.
NumComps.value, this->Ref.NumComps };
798 #define VTK_TMP_MAKE_OPERATOR(OP) \
799 friend VTK_ITER_INLINE bool operator OP( \
800 const TupleIterator& lhs, const TupleIterator& rhs) noexcept \
802 return lhs.GetTuple() OP rhs.GetTuple(); \
812 #undef VTK_TMP_MAKE_OPERATOR
817 this->Ref.Tuple +=
offset * this->Ref.NumComps.value;
836 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
850 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
856 swap(lhs.GetTuple(), rhs.GetTuple());
857 swap(lhs.GetNumComps(), rhs.GetNumComps());
864 ValueType*
GetTuple() const noexcept {
return this->Ref.Tuple; }
866 ValueType*&
GetTuple() noexcept {
return this->Ref.Tuple; }
877 template <
typename ValueType, ComponentIdType TupleSize>
916 , BeginTuple(beginTuple)
920 assert(beginTuple >= 0 && beginTuple <= endTuple);
921 assert(endTuple >= 0 && endTuple <= this->
Array->GetNumberOfTuples());
924 assert(arr->GetNumberOfComponents() == TupleSize);
931 const TupleIdType curBegin = this->GetTupleId(this->GetTuplePointer(this->BeginTuple));
932 const TupleIdType realBegin = curBegin + beginTuple;
934 endTuple >= 0 ? curBegin + endTuple : this->GetTupleId(this->GetTuplePointer(this->EndTuple));
948 return this->GetTupleId(this->GetTuplePointer(this->BeginTuple));
954 return this->GetTupleId(this->GetTuplePointer(this->EndTuple));
961 this->GetTuplePointer(this->EndTuple) - this->GetTuplePointer(this->BeginTuple)) /
962 static_cast<size_type>(this->
NumComps.value);
1005 (this->BeginTuple + i) * this->
NumComps.value,
1013 (this->BeginTuple + i) * this->
NumComps.value,
1019 const ValueType* tuplePtr =
1020 this->
Array->Buffer->GetBuffer() + (this->BeginTuple + i) * this->
NumComps.value;
1023 tuple[c] = tuplePtr[c];
1027 template <
typename VT = ValueType>
1029 size_type i,
double* tuple)
const noexcept
1031 const ValueType* tuplePtr =
1032 this->
Array->Buffer->GetBuffer() + (this->BeginTuple + i) * this->
NumComps.value;
1035 tuple[c] =
static_cast<double>(tuplePtr[c]);
1041 ValueType* tuplePtr =
1042 this->
Array->Buffer->GetBuffer() + (this->BeginTuple + i) * this->
NumComps.value;
1045 tuplePtr[c] = tuple[c];
1049 template <
typename VT = ValueType>
1051 size_type i,
const double* tuple) noexcept
1053 ValueType* tuplePtr =
1054 this->
Array->Buffer->GetBuffer() + (this->BeginTuple + i) * this->
NumComps.value;
1057 tuplePtr[c] =
static_cast<ValueType
>(tuple[c]);
1063 ValueType* GetTuplePointer(
vtkIdType tuple)
const noexcept
1065 return this->
Array->Buffer->GetBuffer() + (tuple * this->
NumComps.value);
1069 TupleIdType GetTupleId(
const ValueType* ptr)
const noexcept
1074 mutable ArrayType*
Array{
nullptr };
1083 typename ValueType =
typename ArrayType::ValueType,
1089 VTK_ABI_NAMESPACE_END
1095 #endif // VTK_DEBUG_RANGE_ITERATORS
1096 #endif // vtkDataArrayTupleRange_AOS_h
TupleIdType difference_type
ComponentIdType size_type
VTK_ITER_INLINE ConstTupleIterator & operator--() noexcept
VTK_ITER_INLINE void GetTuple(size_type i, ValueType *tuple) const 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
std::enable_if_t< IsEitherTupleSizeDynamic< S1, S2 >::value, T > EnableIfEitherTupleSizeIsDynamic
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
typename detail::GetAPITypeImpl< ArrayType, ForceValueTypeForVtkDataArray >::APIType GetAPIType
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
std::enable_if<!std::is_same< VT, double >::value >::type VTK_ITER_INLINE GetTuple(volatile double *tuple) 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
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 void SetTuple(size_type i, const ValueType *tuple) noexcept
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
std::enable_if<!std::is_same< VT, double >::value >::type VTK_ITER_INLINE SetTuple(size_type i, const double *tuple) 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
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
std::enable_if<!std::is_same< VT, double >::value >::type VTK_ITER_INLINE GetTuple(volatile double *tuple) const 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
std::enable_if<!std::is_same< VT, double >::value >::type VTK_ITER_INLINE SetTuple(const double *tuple) 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
std::enable_if<!std::is_same< VT, double >::value >::type VTK_ITER_INLINE GetTuple(size_type i, double *tuple) const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept