|  | VTK
    9.0.1
    | 
 
 
 
Go to the documentation of this file.
   20 #ifndef vtkDataArrayValueRange_Generic_h 
   21 #define vtkDataArrayValueRange_Generic_h 
   30 #include <type_traits> 
   43 template <
typename ArrayType, ComponentIdType>
 
   45 template <
typename ArrayType, ComponentIdType>
 
   47 template <
typename ArrayType, ComponentIdType>
 
   49 template <
typename ArrayType, ComponentIdType>
 
   51 template <
typename ArrayType, ComponentIdType>
 
   62 template <ComponentIdType TupleSize>
 
   86     : ValueId(tupleId* numComps.value + comp)
 
  103   template <
typename ArrayType>
 
  109       "Inconsistent internal state in IdStorage.");
 
  112       this->ValueId >= 0 && this->ValueId <= array->GetNumberOfValues(), 
"Invalid value id.");
 
  114       "Invalid tuple id.");
 
  118             this->
GetTupleId() == array->GetNumberOfTuples())),
 
  119       "Invalid component id.");
 
  121       "Invalid value id.");
 
  131       this->ComponentId = 0;
 
  140     auto v = this->ValueId++;
 
  141     auto t = this->TupleId;
 
  142     auto c = this->ComponentId++;
 
  145       this->ComponentId = 0;
 
  148     return IdStorage{ v, t, c, this->NumComps };
 
  163     if (this->ComponentId < 0)
 
  174     auto v = this->ValueId--;
 
  175     auto t = this->TupleId;
 
  176     auto c = this->ComponentId--;
 
  177     if (this->ComponentId < 0)
 
  182     return IdStorage{ v, t, c, this->NumComps };
 
  188     return static_cast<ValueIdType>(tuple) * this->NumComps.value + comp;
 
  194     return std::make_pair(
static_cast<TupleIdType>(
value / this->NumComps.value),
 
  202     std::tie(this->TupleId, this->ComponentId) = this->
Convert(this->ValueId);
 
  220     swap(lhs.ValueId, rhs.ValueId);
 
  221     swap(lhs.TupleId, rhs.TupleId);
 
  222     swap(lhs.ComponentId, rhs.ComponentId);
 
  234 template <
typename ArrayType, ComponentIdType TupleSize>
 
  235 struct ConstValueReference
 
  241   using IdStorageType = IdStorage<TupleSize>;
 
  278     this->
Array = o.Array;
 
  288     this->
Array = std::move(o.Array);
 
  289     this->
Id = std::move(o.Id);
 
  294   operator APIType() const noexcept
 
  299     return acc.Get(this->
Id.
GetTupleId(), this->Id.GetComponentId());
 
  309 template <
typename ArrayType, ComponentIdType TupleSize>
 
  347       return *
this = 
static_cast<APIType
>(o);
 
  351       this->
Array = o.Array;
 
  362       return *
this = 
static_cast<APIType
>(o);
 
  366       this->
Array = std::move(o.Array);
 
  367       this->
Id = std::move(o.Id);
 
  372   template <
typename OArray, ComponentIdType OSize>
 
  375     const APIType tmp = o;
 
  376     return *
this = std::move(tmp);
 
  380   operator APIType() const noexcept
 
  385     return acc.Get(this->
Id.
GetTupleId(), this->Id.GetComponentId());
 
  394     acc.Set(this->
Id.
GetTupleId(), this->Id.GetComponentId(), val);
 
  400     APIType tmp = std::move(
static_cast<APIType
>(lhs));
 
  401     lhs = std::move(
static_cast<APIType
>(rhs));
 
  402     rhs = std::move(tmp);
 
  405   template <
typename OArray, ComponentIdType OSize>
 
  412     APIType tmp = std::move(
static_cast<APIType
>(lhs));
 
  413     lhs = std::move(
static_cast<APIType
>(rhs));
 
  414     rhs = std::move(tmp);
 
  419     APIType tmp = std::move(
static_cast<APIType
>(lhs));
 
  420     lhs = std::move(rhs);
 
  421     rhs = std::move(tmp);
 
  426     APIType tmp = std::move(lhs);
 
  427     lhs = std::move(
static_cast<APIType
>(rhs));
 
  428     rhs = std::move(tmp);
 
  434     const APIType newVal = *
this + 1;
 
  442     const APIType retVal = *
this;
 
  450     const APIType newVal = *
this - 1;
 
  458     const APIType retVal = *
this;
 
  463 #define VTK_REF_OP_OVERLOADS(Op, ImplOp)                                                           \ 
  464   friend VTK_ITER_INLINE ValueReference operator Op(ValueReference lhs, APIType val) noexcept      \ 
  466     const APIType newVal = lhs ImplOp val;                                                         \ 
  470   friend VTK_ITER_INLINE ValueReference operator Op(ValueReference lhs, ValueReference val)        \ 
  473     const APIType newVal = lhs ImplOp val;                                                         \ 
  477   friend VTK_ITER_INLINE APIType& operator Op(APIType& lhs, ValueReference val) noexcept           \ 
  479     const APIType newVal = lhs ImplOp val;                                                         \ 
  489 #undef VTK_REF_OP_OVERLOADS 
  497     this->
Array = o.Array;
 
  507 template <
typename ArrayType, ComponentIdType TupleSize>
 
  509   : 
public std::iterator<std::random_access_iterator_tag, GetAPIType<ArrayType>, ValueIdType,
 
  511       void, ConstValueReference<ArrayType, TupleSize> >
 
  519   using Superclass = std::iterator<std::random_access_iterator_tag, APIType, 
ValueIdType, void,
 
  546     : Array{ o.GetArray() }
 
  567     auto ret = this->Id++;
 
  583     auto ret = this->Id--;
 
  591     return reference{ this->Array, this->Id + i };
 
  599 #define VTK_TMP_MAKE_OPERATOR(OP)                                                                  \ 
  600   friend VTK_ITER_INLINE bool operator OP(                                                         \ 
  601     const ConstValueIterator& lhs, const ConstValueIterator& rhs) noexcept                         \ 
  603     VTK_ITER_ASSERT(lhs.Array == rhs.Array, "Mismatched arrays in iterator comparison.");          \ 
  604     return lhs.Id.GetValueId() OP rhs.Id.GetValueId();                                             \ 
  614 #undef VTK_TMP_MAKE_OPERATOR 
  653     VTK_ITER_ASSERT(it1.Array == it2.Array, 
"Cannot do math with iterators from different arrays.");
 
  654     return it1.Id.GetValueId() - it2.Id.GetValueId();
 
  660     VTK_ITER_ASSERT(lhs.Array == rhs.Array, 
"Cannot swap iterators from different arrays.");
 
  663     swap(lhs.Id, rhs.Id);
 
  667   mutable ArrayType* Array;
 
  673 template <
typename ArrayType, ComponentIdType TupleSize>
 
  675   : 
public std::iterator<std::random_access_iterator_tag, vtk::GetAPIType<ArrayType>, ValueIdType,
 
  676       ValueReference<ArrayType, TupleSize>, ValueReference<ArrayType, TupleSize> >
 
  683   using IdStorageType = IdStorage<TupleSize>;
 
  684   using Superclass = std::iterator<std::random_access_iterator_tag, GetAPIType<ArrayType>,
 
  685     ValueIdType, ValueReference<ArrayType, TupleSize>, ValueReference<ArrayType, TupleSize> >;
 
  709     this->
Ref.CopyReference(o.Ref);
 
  725     auto ret = this->
Ref.Id++;
 
  741     auto ret = this->
Ref.Id--;
 
  758 #define VTK_TMP_MAKE_OPERATOR(OP)                                                                  \ 
  759   friend VTK_ITER_INLINE bool operator OP(const ValueIterator& lhs, const ValueIterator& rhs)      \ 
  763       lhs.GetArray() == rhs.GetArray(), "Mismatched arrays in iterator comparison.");              \ 
  764     return lhs.GetId().GetValueId() OP rhs.GetId().GetValueId();                                   \ 
  774 #undef VTK_TMP_MAKE_OPERATOR 
  800     this->
Ref.Id.DebugAsserts(this->
Ref.Array);
 
  814       it1.Ref.Array == it2.Ref.Array, 
"Cannot do math with iterators from different arrays.");
 
  815     return it1.GetId().GetValueId() - it2.GetId().GetValueId();
 
  822       lhs.GetArray() == rhs.GetArray(), 
"Cannot swap iterators from different arrays.");
 
  825     swap(lhs.GetId(), rhs.GetId());
 
  840   ValueReference<ArrayType, TupleSize> 
Ref;
 
  845 template <
typename ArrayTypeT, ComponentIdType TupleSize>
 
  882     , BeginValue(beginValue, this->NumComps)
 
  883     , EndValue(endValue, this->NumComps)
 
  886     assert(beginValue >= 0 && beginValue <= endValue);
 
  887     assert(endValue >= 0 && endValue <= this->Array->GetNumberOfValues());
 
  897     return ValueRange{ this->Array, realBegin, realEnd };
 
  920   iterator end() noexcept { 
return this->NewIterator(this->EndValue); }
 
  935     return reference{ this->Array, this->BeginValue + i };
 
  945   iterator NewIterator(IdStorageType 
id) 
const noexcept { 
return iterator{ this->Array, 
id }; }
 
  954   NumCompsType NumComps{};
 
  955   IdStorageType BeginValue{};
 
  956   IdStorageType EndValue{};
 
  960 template <
typename ArrayType, ComponentIdType TupleSize>
 
  968 #endif // __VTK_WRAP__ 
  969 #endif // vtkDataArrayValueRange_Generic_h 
  
VTK_ITER_INLINE ValueReference operator=(const ValueReference &o) noexcept
Efficient templated access to vtkDataArray.
VTK_ITER_INLINE ConstValueIterator & operator=(const ConstValueIterator &o) noexcept=default
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE ConstValueReference operator=(ConstValueReference &&o) noexcept
friend VTK_ITER_INLINE void swap(APIType &lhs, ValueReference rhs) noexcept
VTK_ITER_INLINE ArrayType * GetArray() const noexcept
friend VTK_ITER_INLINE difference_type operator-(const ConstValueIterator &it1, const ConstValueIterator &it2) noexcept
#define VTK_TMP_MAKE_OPERATOR(OP)
VTK_ITER_INLINE ComponentIdType GetTupleSize() const noexcept
IdStorageType & GetId() noexcept
VTK_ITER_INLINE ConstValueIterator(ArrayType *array, IdStorageType id) noexcept
VTK_ITER_INLINE void DebugIdAsserts() const
typename Superclass::difference_type difference_type
VTK_ITER_INLINE ValueIdType GetValueId() const noexcept
VTK_ITER_INLINE ConstValueIterator & operator--() noexcept
VTK_ITER_INLINE ComponentIdType GetComponentId() const noexcept
VTK_ITER_INLINE ValueReference operator++() noexcept
VTK_ITER_INLINE ConstValueIterator & operator+=(difference_type offset) noexcept
friend VTK_ITER_INLINE void swap(ValueReference lhs, APIType &rhs) noexcept
typename Superclass::difference_type difference_type
ArrayType * GetArray() const noexcept
friend VTK_ITER_INLINE ValueIterator operator-(const ValueIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE ConstValueIterator(const ValueIterator< ArrayType, TupleSize > &o) noexcept
friend VTK_ITER_INLINE void swap(ValueIterator &lhs, ValueIterator &rhs) noexcept
VTK_ITER_INLINE ValueRange GetSubRange(ValueIdType beginValue=0, ValueIdType endValue=-1) const noexcept
VTK_ITER_INLINE IdStorage & operator++() noexcept
VTK_ITER_INLINE reference operator[](size_type i) noexcept
VTK_ITER_INLINE ComponentIdType GetTupleSize() const noexcept
VTK_ITER_INLINE ConstValueIterator & operator++() noexcept
GenericTupleSize< TupleSize > NumCompsType
ValueReference< ArrayType, TupleSize > Ref
VTK_ITER_INLINE const_iterator cend() const noexcept
abstract superclass for arrays of numeric data
friend VTK_ITER_INLINE ConstValueIterator operator-(const ConstValueIterator &it, difference_type offset) noexcept
typename Superclass::pointer pointer
const IdStorageType & GetId() const noexcept
VTK_ITER_INLINE std::pair< TupleIdType, ComponentIdType > Convert(ValueIdType value) const noexcept
VTK_ITER_INLINE void DebugAsserts(ArrayType *array) const noexcept
typename detail::GetAPITypeImpl< ArrayType >::APIType GetAPIType
VTK_ITER_INLINE ConstValueReference(const ValueReference< ArrayType, TupleSize > &o)
typename Superclass::reference reference
ValueIterator< ArrayType, TupleSize > IteratorType
const VTK_ITER_INLINE pointer & operator->() const noexcept
typename Superclass::pointer pointer
typename Superclass::iterator_category iterator_category
friend VTK_ITER_INLINE difference_type operator-(const ValueIterator &it1, const ValueIterator &it2) noexcept
friend VTK_ITER_INLINE ValueIterator operator+(const ValueIterator &it, difference_type offset) noexcept
friend VTK_ITER_INLINE void swap(ConstValueIterator &lhs, ConstValueIterator &rhs) noexcept
VTK_ITER_INLINE reference operator*() const noexcept
friend VTK_ITER_INLINE ConstValueIterator operator+(difference_type offset, const ConstValueIterator &it) noexcept
VTK_ITER_INLINE ConstValueReference operator=(const ConstValueReference &o) noexcept
ConstIteratorType const_iterator
VTK_ITER_INLINE ValueIdType GetBeginValueId() const noexcept
VTK_ITER_INLINE ValueIterator & operator--() noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE IdStorage & operator--() noexcept
friend VTK_ITER_INLINE void swap(ValueReference lhs, ValueReference< OArray, OSize > rhs) noexcept
VTK_ITER_INLINE ValueIdType GetEndValueId() const noexcept
VTK_ITER_INLINE ValueIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE ConstValueIterator operator++(int) noexcept
constexpr static ComponentIdType TupleSizeTag
VTK_ITER_INLINE ValueIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE IdStorage() noexcept
VTK_ITER_INLINE IdStorage operator++(int) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE ValueIterator operator++(int) noexcept
VTK_ITER_INLINE iterator end() noexcept
VTK_ITER_INLINE ValueReference(ArrayType *array, IdStorageType id) noexcept
VTK_ITER_INLINE ValueIterator & operator++() noexcept
#define VTK_REF_OP_OVERLOADS(Op, ImplOp)
friend VTK_ITER_INLINE ValueIterator operator+(difference_type offset, const ValueIterator &it) noexcept
VTK_ITER_INLINE ValueIterator() noexcept=default
VTK_ITER_INLINE IdStorage(ValueIdType valueId, NumCompsType numComps) noexcept
VTK_ITER_INLINE ValueIdType Convert(TupleIdType tuple, ComponentIdType comp) const noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
ConstValueReference< ArrayType, TupleSize > ConstReferenceType
friend VTK_ITER_INLINE ConstValueIterator operator+(const ConstValueIterator &it, difference_type offset) noexcept
typename Superclass::value_type value_type
VTK_ITER_INLINE IdStorage operator--(int) noexcept
VTK_ITER_INLINE reference operator[](difference_type i) const noexcept
VTK_ITER_INLINE void AddOffset(ValueIdType offset) noexcept
ConstValueIterator< ArrayType, TupleSize > ConstIteratorType
VTK_ITER_INLINE ValueReference() noexcept
VTK_ITER_INLINE ValueIterator operator--(int) noexcept
VTK_ITER_INLINE APIType operator--(int) noexcept
VTK_ITER_INLINE ConstValueIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE APIType operator++(int) noexcept
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
typename Superclass::value_type value_type
VTK_ITER_INLINE ValueReference operator=(APIType val) noexcept
typename Superclass::iterator_category iterator_category
VTK_ITER_INLINE ConstValueIterator operator--(int) noexcept
friend VTK_ITER_INLINE void swap(ValueReference lhs, ValueReference rhs) noexcept
GetAPIType< ArrayTypeT > ValueType
void CopyReference(const ValueReference &o) noexcept
ValueReference< ArrayType, TupleSize > ReferenceType
VTK_ITER_INLINE ValueRange() noexcept=default
friend VTK_ITER_INLINE IdStorage operator+(const IdStorage &id, ValueIdType offset) noexcept
VTK_ITER_INLINE ValueReference operator--() noexcept
VTK_ITER_INLINE ValueIterator & operator=(const ValueIterator &o) noexcept
typename Superclass::reference reference
VTK_ITER_INLINE IdStorage(ValueIdType valueId, TupleIdType tupleId, ComponentIdType comp, NumCompsType numComps) noexcept
friend VTK_ITER_INLINE void swap(IdStorage &lhs, IdStorage &rhs) noexcept
VTK_ITER_INLINE iterator begin() noexcept
VTK_ITER_INLINE reference operator*() const noexcept
VTK_ITER_INLINE ConstValueReference() noexcept
VTK_ITER_INLINE ConstValueIterator() noexcept
VTK_ITER_INLINE ConstValueReference(ArrayType *array, IdStorageType id) noexcept
VTK_ITER_INLINE ValueReference operator=(ValueReference &&o) noexcept
VTK_ITER_INLINE reference operator[](difference_type i) const noexcept
ValueRange< AOSArrayType, TupleSize > DeclareValueRangeSpecialization(ArrayType *)
VTK_ITER_INLINE TupleIdType GetTupleId() const noexcept
VTK_ITER_INLINE ValueReference operator=(const ValueReference< OArray, OSize > &o) noexcept
VTK_ITER_INLINE IdStorage(TupleIdType tupleId, ComponentIdType comp, NumCompsType numComps) noexcept