19 #ifndef vtkDataArrayTupleRange_AOS_h 20 #define vtkDataArrayTupleRange_AOS_h 29 #include <type_traits> 34 #ifndef VTK_DEBUG_RANGE_ITERATORS 45 template <
typename ArrayType, ComponentIdType>
47 template <
typename ArrayType, ComponentIdType>
49 template <
typename ArrayType, ComponentIdType>
51 template <
typename ArrayType, ComponentIdType>
53 template <
typename ArrayType, ComponentIdType>
58 template <
typename ValueType, ComponentIdType TupleSize>
64 using APIType = ValueType;
116 tuple[i] = this->Tuple[i];
121 template <
typename OArrayType, ComponentIdType OSize>
128 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
131 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
133 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
137 template <
typename OArrayType, ComponentIdType OSize>
144 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
147 if (other.size() != this->
NumComps.value)
152 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
156 template <
typename OArrayType, ComponentIdType OSize>
163 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
166 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
168 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
172 template <
typename OArrayType, ComponentIdType OSize>
179 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
182 if (other.size() != this->
NumComps.value)
187 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
190 template <
typename OArrayType, ComponentIdType OSize>
193 return !(*
this == o);
196 template <
typename OArray, ComponentIdType OSize>
199 return !(*
this == o);
239 template <
typename ValueType, ComponentIdType TupleSize>
245 using APIType = ValueType;
278 void GetTuple(
volatile APIType* tuple)
const noexcept
292 tuple[i] = this->Tuple[i];
300 volatile APIType* out = this->Tuple;
313 std::copy_n(other.cbegin(), this->
NumComps.value, this->
begin());
317 template <
typename OArrayType, ComponentIdType OSize>
324 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
327 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
329 std::copy_n(other.cbegin(), OSize, this->
begin());
333 template <
typename OArrayType, ComponentIdType OSize>
340 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
344 std::copy_n(other.cbegin(), this->
NumComps.value, this->
begin());
348 template <
typename OArrayType, ComponentIdType OSize>
355 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
358 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
360 std::copy_n(other.cbegin(), OSize, this->
begin());
364 template <
typename OArrayType, ComponentIdType OSize>
371 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
375 std::copy_n(other.cbegin(), this->
NumComps.value, this->
begin());
380 template <
typename OArrayType, ComponentIdType OSize>
387 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
390 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
392 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
396 template <
typename OArrayType, ComponentIdType OSize>
403 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
407 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
411 template <
typename OArrayType, ComponentIdType OSize>
418 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
421 static_assert(TupleSize == OSize,
"Cannot assign tuples with different sizes.");
423 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
427 template <
typename OArrayType, ComponentIdType OSize>
434 (std::is_convertible<OAPIType, APIType>{}),
"Incompatible types when assigning tuples.");
438 return std::equal(this->
cbegin(), this->
cend(), other.cbegin());
441 template <
typename OArrayType, ComponentIdType OSize>
444 return !(*
this == o);
447 template <
typename OArray, ComponentIdType OSize>
450 return !(*
this == o);
454 template <
typename OArrayType, ComponentIdType OSize>
460 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
463 static_assert(TupleSize == OSize,
"Cannot swap tuples with different sizes.");
465 std::swap_ranges(this->
begin(), this->
end(), other.begin());
469 template <
typename OArrayType, ComponentIdType OSize>
475 static_assert((std::is_same<OAPIType, APIType>{}),
"Incompatible types when swapping tuples.");
479 std::swap_ranges(this->
begin(), this->
end(), other.begin());
484 template <
typename OArray, ComponentIdType OSize>
533 this->Tuple = o.Tuple;
543 template <
typename ValueType, ComponentIdType TupleSize>
545 :
public std::iterator<std::random_access_iterator_tag,
546 ConstTupleReference<vtkAOSDataArrayTemplate<ValueType>, TupleSize>, TupleIdType,
547 ConstTupleReference<vtkAOSDataArrayTemplate<ValueType>, TupleSize>,
548 ConstTupleReference<vtkAOSDataArrayTemplate<ValueType>, TupleSize> >
553 using Superclass = std::iterator<std::random_access_iterator_tag,
583 this->Ref.Tuple += this->Ref.NumComps.value;
590 auto tuple = this->Ref.Tuple;
591 this->Ref.Tuple += this->Ref.NumComps.value;
598 this->Ref.Tuple -= this->Ref.NumComps.value;
605 auto tuple = this->Ref.Tuple;
606 this->Ref.Tuple -= this->Ref.NumComps.value;
613 return reference{ this->Ref.Tuple + i * this->Ref.NumComps, this->Ref.NumComps };
622 #define VTK_TMP_MAKE_OPERATOR(OP) \ 623 friend VTK_ITER_INLINE bool operator OP( \ 624 const ConstTupleIterator& lhs, const ConstTupleIterator& rhs) noexcept \ 626 return lhs.GetTuple() OP rhs.GetTuple(); \ 636 #undef VTK_TMP_MAKE_OPERATOR 641 this->Ref.Tuple +=
offset * this->Ref.NumComps.value;
660 this->Ref.Tuple -=
offset * this->Ref.NumComps.value;
674 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
680 swap(lhs.GetTuple(), rhs.GetTuple());
681 swap(lhs.GetNumComps(), rhs.GetNumComps());
686 const ValueType*& GetTuple() noexcept {
return this->Ref.Tuple; }
688 const ValueType* GetTuple() const noexcept {
return this->Ref.Tuple; }
690 NumCompsType& GetNumComps() noexcept {
return this->Ref.NumComps; }
692 NumCompsType GetNumComps() const noexcept {
return this->Ref.NumComps; }
694 ConstTupleReference<ArrayType, TupleSize> Ref;
699 template <
typename ValueType, ComponentIdType TupleSize>
701 :
public std::iterator<std::random_access_iterator_tag,
702 TupleReference<vtkAOSDataArrayTemplate<ValueType>, TupleSize>, TupleIdType,
703 TupleReference<vtkAOSDataArrayTemplate<ValueType>, TupleSize>,
704 TupleReference<vtkAOSDataArrayTemplate<ValueType>, TupleSize> >
710 std::iterator<std::random_access_iterator_tag, TupleReference<ArrayType, TupleSize>,
732 this->
Ref.CopyReference(o.Ref);
739 this->
Ref.Tuple += this->
Ref.NumComps.value;
746 auto tuple = this->
Ref.Tuple;
747 this->
Ref.Tuple += this->
Ref.NumComps.value;
754 this->
Ref.Tuple -= this->
Ref.NumComps.value;
761 auto tuple = this->
Ref.Tuple;
762 this->
Ref.Tuple -= this->
Ref.NumComps.value;
769 return reference{ this->
Ref.Tuple + i * this->
Ref.NumComps.value, this->
Ref.NumComps };
776 #define VTK_TMP_MAKE_OPERATOR(OP) \ 777 friend VTK_ITER_INLINE bool operator OP(const TupleIterator& lhs, const TupleIterator& rhs) \ 780 return lhs.GetTuple() OP rhs.GetTuple(); \ 790 #undef VTK_TMP_MAKE_OPERATOR 828 (it1.GetTuple() - it2.GetTuple()) / it1.GetNumComps().value);
834 swap(lhs.GetTuple(), rhs.GetTuple());
835 swap(lhs.GetNumComps(), rhs.GetNumComps());
850 TupleReference<ArrayType, TupleSize>
Ref;
855 template <
typename ValueType, ComponentIdType TupleSize>
894 , BeginTuple(
TupleRange::GetTuplePointer(arr, beginTuple))
895 , EndTuple(
TupleRange::GetTuplePointer(arr, endTuple))
898 assert(beginTuple >= 0 && beginTuple <= endTuple);
899 assert(endTuple >= 0 && endTuple <= this->Array->GetNumberOfTuples());
905 const TupleIdType curBegin = this->GetTupleId(this->BeginTuple);
906 const TupleIdType realBegin = curBegin + beginTuple;
908 endTuple >= 0 ? curBegin + endTuple : this->GetTupleId(this->EndTuple);
910 return TupleRange{ this->Array, realBegin, realEnd };
928 return static_cast<size_type>(this->EndTuple - this->BeginTuple) /
929 static_cast<size_type>(this->NumComps.value);
956 return reference{ this->BeginTuple + i * this->NumComps.value, this->NumComps };
962 return const_reference{ this->BeginTuple + i * this->NumComps.value, this->NumComps };
969 return array->GetPointer(tuple * this->NumComps.value);
973 TupleIdType GetTupleId(
const ValueType* ptr)
const noexcept
975 return static_cast<TupleIdType>((ptr - this->Array->GetPointer(0)) / this->NumComps.value);
979 NumCompsType NumComps{};
980 ValueType* BeginTuple{
nullptr };
981 ValueType* EndTuple{
nullptr };
987 typename ValueType =
typename ArrayType::ValueType,
998 #endif // VTK_DEBUG_RANGE_ITERATORS 999 #endif // __VTK_WRAP__ 1000 #endif // vtkDataArrayTupleRange_AOS_h
VTK_ITER_INLINE const_iterator cbegin() const noexcept
ComponentIdType size_type
VTK_ITER_INLINE ConstTupleIterator & operator--() noexcept
TupleReference< ArrayType, TupleSize > TupleReferenceType
VTK_ITER_INLINE TupleReference() noexcept
friend VTK_ITER_INLINE ConstTupleIterator operator+(difference_type offset, const ConstTupleIterator &it) noexcept
const ValueType * const_iterator
VTK_ITER_INLINE TupleRange GetSubRange(TupleIdType beginTuple=0, TupleIdType endTuple=-1) const noexcept
ConstTupleIteratorType const_iterator
typename Superclass::reference reference
VTK_ITER_INLINE TupleIterator & operator++() noexcept
VTK_ITER_INLINE ConstTupleIterator operator++(int) noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< 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
TupleReference< ArrayType, TupleSize > Ref
VTK_ITER_INLINE TupleRange() noexcept=default
VTK_ITER_INLINE ConstTupleIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE ValueType * GetTuple() const noexcept
friend VTK_ITER_INLINE void swap(TupleIterator &lhs, TupleIterator &rhs) noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
typename Superclass::iterator_category iterator_category
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
const ValueType * const_iterator
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) 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
GetAPIType< ArrayType > APIType
VTK_ITER_INLINE iterator end() noexcept
typename std::enable_if< IsEitherTupleSizeDynamic< S1, S2 >::value, T >::type EnableIfEitherTupleSizeIsDynamic
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE ConstTupleIterator operator--(int) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE ConstTupleIterator() noexcept=default
VTK_ITER_INLINE const_iterator cbegin() const noexcept
reference operator*() noexcept
VTK_ITER_INLINE TupleIdType GetEndTupleId() const 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 ConstTupleIterator & operator=(const ConstTupleIterator &o) noexcept
typename Superclass::reference reference
typename Superclass::difference_type difference_type
VTK_ITER_INLINE NumCompsType GetNumComps() const noexcept
friend VTK_ITER_INLINE difference_type operator-(const ConstTupleIterator &it1, const ConstTupleIterator &it2) noexcept
VTK_ITER_INLINE TupleReference() noexcept
VTK_ITER_INLINE TupleIdType GetBeginTupleId() const noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE ConstTupleIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator++() noexcept
VTK_ITER_INLINE ComponentIdType GetTupleSize() const noexcept
VTK_ITER_INLINE ConstTupleReference(const TupleReference< ArrayType, TupleSize > &o) noexcept
VTK_ITER_INLINE TupleIterator operator++(int) noexcept
typename Superclass::difference_type difference_type
typename Superclass::value_type value_type
VTK_ITER_INLINE reference operator[](size_type i) noexcept
typename Superclass::pointer pointer
GetAPIType< ArrayType > APIType
const ValueType * iterator
Array-Of-Structs implementation of vtkGenericDataArray.
APIType const * ConstComponentIteratorType
static constexpr ComponentIdType TupleSizeTag
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
friend VTK_ITER_INLINE TupleIterator operator+(difference_type offset, const TupleIterator &it) noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
typename Superclass::iterator_category iterator_category
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
friend VTK_ITER_INLINE void swap(ConstTupleIterator &lhs, ConstTupleIterator &rhs) noexcept
TupleIterator< ArrayType, TupleSize > TupleIteratorType
VTK_ITER_INLINE ConstTupleReference() noexcept
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
VTK_ITER_INLINE iterator end() noexcept
friend VTK_ITER_INLINE void swap(TupleIterator &lhs, TupleIterator &rhs) noexcept
typename Superclass::value_type value_type
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference b) noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE ArrayType * GetArray() const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) 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 const_reference operator[](size_type i) const noexcept
typename Superclass::pointer pointer
VTK_ITER_INLINE iterator end() noexcept
friend VTK_ITER_INLINE TupleIterator operator+(const TupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE TupleIterator() noexcept=default
VTK_ITER_INLINE reference operator[](size_type i) noexcept
const APIType & ConstComponentReferenceType
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
ComponentIdType size_type
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE ValueType *& GetTuple() noexcept
TupleReference< ArrayType, TupleSize > Ref
friend VTK_ITER_INLINE ConstTupleIterator operator-(const ConstTupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
TupleRange< AOSArrayType, TupleSize > DeclareTupleRangeSpecialization(ArrayType *)
VTK_ITER_INLINE const_iterator begin() const noexcept
ConstTupleIterator< ArrayType, TupleSize > ConstTupleIteratorType
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
VTK_ITER_INLINE void GetTuple(volatile APIType *tuple) const noexcept
VTK_ITER_INLINE const ConstTupleReference * operator->() const noexcept
VTK_ITER_INLINE void CopyReference(const TupleReference &o) noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
const ValueType & const_reference
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE TupleIterator operator--(int) noexcept
VTK_ITER_INLINE void GetTuple(volatile APIType *tuple) const noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE size_type size() const noexcept
typename detail::GetAPITypeImpl< ArrayType >::APIType GetAPIType
friend VTK_ITER_INLINE ConstTupleIterator operator+(const ConstTupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE TupleReference & operator=(const TupleReference &other) noexcept
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE NumCompsType & GetNumComps() noexcept
VTK_ITER_INLINE pointer & operator->() noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
ConstTupleReference< ArrayType, TupleSize > ConstTupleReferenceType
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
#define VTK_TMP_MAKE_OPERATOR(OP)
pointer & operator->() noexcept
VTK_ITER_INLINE ConstTupleReference(const ValueType *tuple, NumCompsType numComps) noexcept
VTK_ITER_INLINE ConstTupleReference & operator=(const ConstTupleReference &) noexcept=default
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE TupleIterator & operator--() noexcept
VTK_ITER_INLINE void fill(const value_type &v) noexcept
VTK_ITER_INLINE const_iterator cbegin() const 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 TupleReference< OArrayType, OSize > &o) const noexcept
VTK_ITER_INLINE const TupleReference * operator->() const noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE ConstTupleIterator(const TupleIterator< ArrayType, TupleSize > &o) noexcept
APIType * ComponentIteratorType
VTK_ITER_INLINE const_iterator end() const noexcept
TupleIteratorType iterator
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 EnableIfStaticTupleSizes< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
typename std::enable_if< AreStaticTupleSizes< S1, S2 >::value, T >::type EnableIfStaticTupleSizes