VTK  9.5.20251019
vtkDataArrayTupleRange_Generic.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
8#ifndef vtkDataArrayTupleRange_Generic_h
9#define vtkDataArrayTupleRange_Generic_h
10
11#include "vtkAssume.h"
13#include "vtkDataArrayMeta.h"
14
15#include <algorithm>
16#include <cassert>
17#include <iterator>
18#include <type_traits>
19
21
22namespace vtk
23{
24namespace detail
25{
26VTK_ABI_NAMESPACE_BEGIN
27
28// Forward decs for friends/args
29template <typename ArrayType, ComponentIdType>
30struct ConstComponentReference;
31template <typename ArrayType, ComponentIdType>
32struct ComponentReference;
33template <typename ArrayType, ComponentIdType>
34struct ConstComponentIterator;
35template <typename ArrayType, ComponentIdType>
36struct ComponentIterator;
37template <typename ArrayType, ComponentIdType>
38struct ConstTupleReference;
39template <typename ArrayType, ComponentIdType>
40struct TupleReference;
41template <typename ArrayType, ComponentIdType>
42struct ConstTupleIterator;
43template <typename ArrayType, ComponentIdType>
44struct TupleIterator;
45template <typename ArrayType, ComponentIdType>
46struct TupleRange;
47
48//------------------------------------------------------------------------------
49// Const component reference
50template <typename ArrayType, ComponentIdType TupleSize>
52{
53private:
54 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
55 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
56
58 using APIType = GetAPIType<ArrayType>;
59
60public:
61 using value_type = APIType;
62
65 : Array{ nullptr }
66 , NumComps{}
67 , TupleId{ 0 }
68 , ComponentId{ 0 }
69 {
70 }
71
74 ArrayType* array, NumCompsType numComps, TupleIdType tuple, ComponentIdType comp) noexcept
75 : Array{ array }
76 , NumComps{ numComps }
77 , TupleId{ tuple }
78 , ComponentId{ comp }
79 {
80 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
81 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
83 tuple >= 0 && tuple <= array->GetNumberOfTuples(), "Invalid tuple accessed by iterator.");
84 VTK_ITER_ASSERT(comp >= 0 && comp <= array->GetNumberOfComponents(),
85 "Invalid component accessed by iterator.");
86 }
87
90 : Array{ o.Array }
91 , NumComps{ o.NumComps }
92 , TupleId{ o.TupleId }
94 {
95 }
96
99
102
105 {
106 VTK_ITER_ASSERT(!this->Array, "Const reference already initialized.");
107 // Initialize the reference.
108 this->Array = o.Array;
109 this->NumComps = o.NumComps;
110 this->TupleId = o.TupleId;
111 this->ComponentId = o.ComponentId;
112 }
113
116 {
117 VTK_ITER_ASSERT(!this->Array, "Const reference already initialized.");
118 // Initialize the reference.
119 this->Array = std::move(o.Array);
120 this->NumComps = std::move(o.NumComps);
121 this->TupleId = o.TupleId;
122 this->ComponentId = o.ComponentId;
123 }
124
125 VTK_ITER_INLINE operator APIType() const noexcept
126 {
127 VTK_ITER_ASSUME(this->NumComps.value > 0);
128 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
129 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
130 {
131 return this->Array->GetComponent(this->TupleId, this->ComponentId);
132 }
133 else
134 {
135 return this->Array->GetTypedComponent(this->TupleId, this->ComponentId);
136 }
137 }
138
139protected:
140 mutable ArrayType* Array;
144};
145
146//------------------------------------------------------------------------------
147// Component reference
148template <typename ArrayType, ComponentIdType TupleSize>
150{
151private:
152 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
153 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
154
156 using APIType = GetAPIType<ArrayType>;
157
158public:
159 using value_type = APIType;
160
163 : Array{ nullptr }
164 , NumComps{}
165 , TupleId{ 0 }
166 , ComponentId{ 0 }
167 {
168 }
169
172 ArrayType* array, NumCompsType numComps, TupleIdType tuple, ComponentIdType comp) noexcept
173 : Array{ array }
174 , NumComps{ numComps }
175 , TupleId{ tuple }
176 , ComponentId{ comp }
177 {
178 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
179 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
181 tuple >= 0 && tuple <= array->GetNumberOfTuples(), "Invalid tuple accessed by iterator.");
182 VTK_ITER_ASSERT(comp >= 0 && comp <= array->GetNumberOfComponents(),
183 "Invalid component accessed by iterator.");
184 }
185
187 ComponentReference(const ComponentReference& o) noexcept = default;
189 ComponentReference(ComponentReference&& o) noexcept = default;
190
193 {
194 if (this->Array)
195 { // Already initialized. Assign the value, not the reference
196 return *this = static_cast<APIType>(o);
197 }
198 else
199 { // Initialize the reference.
200 this->Array = o.Array;
201 this->NumComps = o.NumComps;
202 this->TupleId = o.TupleId;
203 this->ComponentId = o.ComponentId;
204
205 return *this;
206 }
207 }
208
211 {
212 if (this->Array)
213 { // Already initialized. Assign the value, not the reference
214 return *this = std::move(static_cast<APIType>(o));
215 }
216 else
217 { // Initialize the reference.
218 this->Array = std::move(o.Array);
219 this->NumComps = std::move(o.NumComps);
220 this->TupleId = o.TupleId;
221 this->ComponentId = o.ComponentId;
222
223 return *this;
224 }
225 }
226
227 template <typename OArray, ComponentIdType OSize>
229 { // Always copy the value for different reference types:
230 const APIType tmp = o;
231 return *this = std::move(tmp);
232 }
233
234 VTK_ITER_INLINE operator APIType() const noexcept
235 {
236 VTK_ITER_ASSUME(this->NumComps.value > 0);
237 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
238 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
239 {
240 return this->Array->GetComponent(this->TupleId, this->ComponentId);
241 }
242 else
243 {
244 return this->Array->GetTypedComponent(this->TupleId, this->ComponentId);
245 }
246 }
247
249 {
250 VTK_ITER_ASSUME(this->NumComps.value > 0);
251 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
252 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
253 {
254 this->Array->SetComponent(this->TupleId, this->ComponentId, val);
255 }
256 else
257 {
258 this->Array->SetTypedComponent(this->TupleId, this->ComponentId, val);
259 }
260 return *this;
261 }
262
264 { // Swap values, not references:
265 APIType tmp = std::move(static_cast<APIType>(lhs));
266 lhs = std::move(static_cast<APIType>(rhs));
267 rhs = std::move(tmp);
268 }
269
270 template <typename OArray, ComponentIdType OSize>
273 { // Swap values, not references:
274 using OAPIType = GetAPIType<OArray>;
275 static_assert(
276 std::is_same<APIType, OAPIType>::value, "Cannot swap components with different types.");
277
278 APIType tmp = std::move(static_cast<APIType>(lhs));
279 lhs = std::move(static_cast<APIType>(rhs));
280 rhs = std::move(tmp);
281 }
282
283 friend VTK_ITER_INLINE void swap(ComponentReference lhs, APIType& rhs) noexcept
284 {
285 APIType tmp = std::move(static_cast<APIType>(lhs));
286 lhs = std::move(rhs);
287 rhs = std::move(tmp);
288 }
289
290 friend VTK_ITER_INLINE void swap(APIType& lhs, ComponentReference rhs) noexcept
291 {
292 APIType tmp = std::move(lhs);
293 lhs = std::move(static_cast<APIType>(rhs));
294 rhs = std::move(tmp);
295 }
296
298 ComponentReference operator++() noexcept // prefix
299 {
300 const APIType newVal = *this + 1;
301 *this = newVal;
302 return *this;
303 }
304
306 APIType operator++(int) noexcept // postfix
307 {
308 const APIType retVal = *this;
309 *this = *this + 1;
310 return retVal;
311 }
312
314 ComponentReference operator--() noexcept // prefix
315 {
316 const APIType newVal = *this - 1;
317 *this = newVal;
318 return *this;
319 }
320
322 APIType operator--(int) noexcept // postfix
323 {
324 const APIType retVal = *this;
325 *this = *this - 1;
326 return retVal;
327 }
328
329#define VTK_REF_OP_OVERLOADS(Op, ImplOp) \
330 friend VTK_ITER_INLINE ComponentReference operator Op( \
331 ComponentReference lhs, APIType val) noexcept \
332 { \
333 const APIType newVal = lhs ImplOp val; \
334 lhs = newVal; \
335 return lhs; \
336 } \
337 friend VTK_ITER_INLINE ComponentReference operator Op( \
338 ComponentReference lhs, ComponentReference val) noexcept \
339 { \
340 const APIType newVal = lhs ImplOp val; \
341 lhs = newVal; \
342 return lhs; \
343 } \
344 friend VTK_ITER_INLINE APIType& operator Op(APIType& lhs, ComponentReference val) noexcept \
345 { \
346 const APIType newVal = lhs ImplOp val; \
347 lhs = newVal; \
348 return lhs; \
349 }
350
355
356#undef VTK_REF_OP_OVERLOADS
357
358 friend struct ConstComponentReference<ArrayType, TupleSize>;
359 friend struct ComponentIterator<ArrayType, TupleSize>;
360
361protected:
363 void CopyReference(const ComponentReference& o) noexcept
364 {
365 this->Array = o.Array;
366 this->NumComps = o.NumComps;
367 this->TupleId = o.TupleId;
368 this->ComponentId = o.ComponentId;
369 }
370
371 mutable ArrayType* Array;
375};
376
377//------------------------------------------------------------------------------
378// Const component iterator
379template <typename ArrayType, ComponentIdType TupleSize>
381{
382private:
383 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
384 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
385
387
388public:
389 using iterator_category = std::random_access_iterator_tag;
392 using pointer = void;
394
397 : Array{ nullptr }
398 , TupleId{ 0 }
399 , ComponentId{ 0 }
400 {
401 }
402
405 ArrayType* array, NumCompsType numComps, TupleIdType tupleId, ComponentIdType comp) noexcept
406 : Array(array)
407 , NumComps(numComps)
408 , TupleId(tupleId)
409 , ComponentId(comp)
410 {
411 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
412 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
413 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
414 "Const component iterator at invalid tuple id.");
415 VTK_ITER_ASSERT(comp >= 0 && comp <= this->NumComps.value,
416 "Const component iterator at invalid component id.");
417 }
418
421 : Array{ o.GetArray() }
422 , NumComps{ o.GetNumComps() }
423 , TupleId{ o.GetTupleId() }
424 , ComponentId{ o.GetComponentId() }
425 {
426 }
427
429 ConstComponentIterator(const ConstComponentIterator& o) noexcept = default;
432
434 ConstComponentIterator& operator++() noexcept // prefix
435 {
436 ++this->ComponentId;
437 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
438 "Const component iterator at invalid component id.");
439 return *this;
440 }
441
443 ConstComponentIterator operator++(int) noexcept // postfix
444 {
445 return ConstComponentIterator{ this->Array, this->NumComps, this->TupleId,
446 this->ComponentId++ };
447 }
448
450 ConstComponentIterator& operator--() noexcept // prefix
451 {
452 --this->ComponentId;
453 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
454 "Const component iterator at invalid component id.");
455 return *this;
456 }
457
459 ConstComponentIterator operator--(int) noexcept // postfix
460 {
461 return ConstComponentIterator{ this->Array, this->NumComps, this->TupleId,
462 this->ComponentId-- };
463 }
464
467 {
468 return reference{ this->Array, this->NumComps, this->TupleId, this->ComponentId + i };
469 }
470
472 reference operator*() const noexcept
473 {
474 return reference{ this->Array, this->NumComps, this->TupleId, this->ComponentId };
475 }
476
477#define VTK_TMP_MAKE_OPERATOR(OP) \
478 friend VTK_ITER_INLINE bool operator OP( \
479 const ConstComponentIterator& lhs, const ConstComponentIterator& rhs) noexcept \
480 { \
481 VTK_ITER_ASSERT(lhs.Array == rhs.Array, "Mismatched arrays in iterator comparison."); \
482 VTK_ITER_ASSERT(lhs.TupleId == rhs.TupleId, "Mismatched tuple ids in iterator comparison."); \
483 VTK_ITER_ASSUME(lhs.NumComps.value > 0); \
484 VTK_ITER_ASSUME(lhs.NumComps.value == rhs.NumComps.value); \
485 return lhs.ComponentId OP rhs.ComponentId; \
486 }
487
494
495#undef VTK_TMP_MAKE_OPERATOR
496
499 {
500 this->ComponentId += offset;
501 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
502 "Const component iterator at invalid component id.");
503 return *this;
504 }
505
507 const ConstComponentIterator& it, difference_type offset) noexcept
508 {
509 return ConstComponentIterator{ it.Array, it.NumComps, it.TupleId, it.ComponentId + offset };
510 }
511
513 difference_type offset, const ConstComponentIterator& it) noexcept
514 {
515 return ConstComponentIterator{ it.Array, it.NumComps, it.TupleId, it.ComponentId + offset };
516 }
517
520 {
521 this->ComponentId -= offset;
522 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
523 "Const component iterator at invalid component id.");
524 return *this;
525 }
526
528 const ConstComponentIterator& it, difference_type offset) noexcept
529 {
530 return ConstComponentIterator{ it.Array, it.NumComps, it.TupleId, it.ComponentId - offset };
531 }
532
534 const ConstComponentIterator& it1, const ConstComponentIterator& it2) noexcept
535 {
536 VTK_ITER_ASSERT(it1.Array == it2.Array, "Cannot do math with iterators from different arrays.");
537 VTK_ITER_ASSERT(it1.TupleId == it2.TupleId,
538 "Cannot do math with component iterators from different "
539 "tuples.");
540 return it1.ComponentId - it2.ComponentId;
541 }
542
545 {
546 // Different arrays may use different iterator implementations.
547 VTK_ITER_ASSERT(lhs.Array == rhs.Array, "Cannot swap iterators from different arrays.");
548
549 using std::swap;
550 swap(lhs.TupleId, rhs.TupleId);
551 swap(lhs.ComponentId, rhs.ComponentId);
552 }
553
554private:
555 mutable ArrayType* Array;
556 NumCompsType NumComps;
557 TupleIdType TupleId;
558 ComponentIdType ComponentId;
559};
560
561//------------------------------------------------------------------------------
562// Component iterator
563template <typename ArrayType, ComponentIdType TupleSize>
565{
566private:
567 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
568 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
569
571 using APIType = GetAPIType<ArrayType>;
572
573public:
574 using iterator_category = std::random_access_iterator_tag;
575 using value_type = APIType;
579
581 ComponentIterator() noexcept = default;
582
585 ArrayType* array, NumCompsType numComps, TupleIdType tupleId, ComponentIdType comp) noexcept
586 : Ref(array, numComps, tupleId, comp)
587 {
588 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
589 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
590 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
591 "Component iterator at invalid tuple id.");
593 comp >= 0 && comp <= numComps.value, "Component iterator at invalid component id.");
594 }
595
597 ComponentIterator(const ComponentIterator& o) noexcept = default;
598
601 {
602 this->Ref.CopyReference(o.Ref);
603 return *this;
604 }
605
607 ComponentIterator& operator++() noexcept // prefix
608 {
609 ++this->Ref.ComponentId;
610 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
611 "Component iterator at invalid component id.");
612 return *this;
613 }
614
616 ComponentIterator operator++(int) noexcept // postfix
617 {
618 return ComponentIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId,
619 this->Ref.ComponentId++ };
620 }
621
623 ComponentIterator& operator--() noexcept // prefix
624 {
625 --this->Ref.ComponentId;
626 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
627 "Component iterator at invalid component id.");
628 return *this;
629 }
630
632 ComponentIterator operator--(int) noexcept // postfix
633 {
634 return ComponentIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId,
635 this->Ref.ComponentId-- };
636 }
637
640 {
641 return reference{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId,
642 this->Ref.ComponentId + i };
643 }
644
646 reference operator*() const noexcept { return this->Ref; }
647
649 const pointer& operator->() const noexcept { return this->Ref; }
650
651#define VTK_TMP_MAKE_OPERATOR(OP) \
652 friend VTK_ITER_INLINE bool operator OP( \
653 const ComponentIterator& lhs, const ComponentIterator& rhs) noexcept \
654 { \
655 VTK_ITER_ASSERT( \
656 lhs.GetArray() == rhs.GetArray(), "Mismatched arrays in iterator comparison."); \
657 VTK_ITER_ASSERT( \
658 lhs.GetTupleId() == rhs.GetTupleId(), "Mismatched tuple ids in iterator comparison."); \
659 VTK_ITER_ASSUME(lhs.GetNumComps().value > 0); \
660 VTK_ITER_ASSUME(lhs.GetNumComps().value == rhs.GetNumComps().value); \
661 return lhs.GetComponentId() OP rhs.GetComponentId(); \
662 }
663
670
671#undef VTK_TMP_MAKE_OPERATOR
672
675 {
676 this->Ref.ComponentId += offset;
677 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
678 "Component iterator at invalid component id.");
679 return *this;
680 }
681
683 const ComponentIterator& it, difference_type offset) noexcept
684 {
685 return ComponentIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId(),
686 it.GetComponentId() + offset };
687 }
688
690 difference_type offset, const ComponentIterator& it) noexcept
691 {
692 return ComponentIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId(),
693 it.GetComponentId() + offset };
694 }
695
698 {
699 this->Ref.ComponentId -= offset;
700 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
701 "Component iterator at invalid component id.");
702 return *this;
703 }
704
706 const ComponentIterator& it, difference_type offset) noexcept
707 {
708 return ComponentIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId(),
709 it.GetComponentId() - offset };
710 }
711
713 const ComponentIterator& it1, const ComponentIterator& it2) noexcept
714 {
715 VTK_ITER_ASSERT(it1.GetArray() == it2.GetArray(),
716 "Cannot do math with component iterators from different "
717 "arrays.");
718 VTK_ITER_ASSERT(it1.GetTupleId() == it2.GetTupleId(),
719 "Cannot do math with component iterators from different "
720 "tuples.");
721 return it1.GetComponentId() - it2.GetComponentId();
722 }
723
725 {
726 // Different arrays may use different iterator implementations.
728 lhs.GetArray() == rhs.GetArray(), "Cannot swap iterators from different arrays.");
729
730 using std::swap;
731 swap(lhs.GetTupleId(), rhs.GetTupleId());
732 swap(lhs.GetComponentId(), rhs.GetComponentId());
733 }
734
735 friend struct ConstComponentIterator<ArrayType, TupleSize>;
736
737protected:
738 // Needed for access from friend functions. We could just store the array
739 // and ID here instead of the ref, but meh.
740 ArrayType* GetArray() const noexcept { return this->Ref.Array; }
741 TupleIdType& GetTupleId() noexcept { return this->Ref.TupleId; }
742 const TupleIdType& GetTupleId() const noexcept { return this->Ref.TupleId; }
743 ComponentIdType& GetComponentId() noexcept { return this->Ref.ComponentId; }
744 const ComponentIdType& GetComponentId() const noexcept { return this->Ref.ComponentId; }
745 NumCompsType& GetNumComps() noexcept { return this->Ref.NumComps; }
746 const NumCompsType& GetNumComps() const noexcept { return this->Ref.NumComps; }
747
749};
750
751//------------------------------------------------------------------------------
752// Const tuple reference
753template <typename ArrayType, ComponentIdType TupleSize>
755{
756private:
757 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
758 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
759
761 using APIType = GetAPIType<ArrayType>;
762
763public:
765 using value_type = APIType;
769
772 : Array(nullptr)
773 , TupleId(0)
774 {
775 }
776
778 ConstTupleReference(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
779 : Array(array)
780 , NumComps(numComps)
781 , TupleId(tupleId)
782 {
783 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
784 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
785 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
786 "Const tuple reference at invalid tuple id.");
787 }
788
791 : Array{ o.Array }
792 , NumComps{ o.NumComps }
793 , TupleId{ o.TupleId }
794 {
795 }
796
798 ConstTupleReference(const ConstTupleReference&) noexcept = default;
801
802 // Allow this type to masquerade as a pointer, so that tupleIiter->foo works.
804 ConstTupleReference* operator->() noexcept { return this; }
806 const ConstTupleReference* operator->() const noexcept { return this; }
807
808 // Caller must ensure that there are size() elements in array.
809 VTK_ITER_INLINE void GetTuple(APIType* tuple) const noexcept
810 {
811 VTK_ITER_ASSUME(this->NumComps.value > 0);
812 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
813 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
814 {
815 this->Array->GetTuple(this->TupleId, tuple);
816 }
817 else
818 {
819 this->Array->GetTypedTuple(this->TupleId, tuple);
820 }
821 }
822
823 template <typename VT = APIType>
824 typename std::enable_if_t<!std::is_same_v<VT, double>> VTK_ITER_INLINE GetTuple(
825 double* tuple) const noexcept
826 {
827 VTK_ITER_ASSUME(this->NumComps.value > 0);
828 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
829 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
830 {
831 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
832 {
833 tuple[comp] = static_cast<double>(this->Array->GetComponent(this->TupleId, comp));
834 }
835 }
836 else
837 {
838 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
839 {
840 tuple[comp] = static_cast<double>(this->Array->GetTypedComponent(this->TupleId, comp));
841 }
842 }
843 }
844
845 // skips some runtime checks when both sizes are fixed:
846 template <typename OArrayType, ComponentIdType OSize>
848 const TupleReference<OArrayType, OSize>& other) const noexcept
849 {
850 // Check that types are convertible:
851 using OAPIType = GetAPIType<OArrayType>;
852 static_assert(
853 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
854
855 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
856 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
857
858 return std::equal(this->cbegin(), this->cend(), other.cbegin());
859 }
860
861 // Needs a runtime check:
862 template <typename OArrayType, ComponentIdType OSize>
864 const TupleReference<OArrayType, OSize>& other) const noexcept
865 {
866 // Check that types are convertible:
867 using OAPIType = GetAPIType<OArrayType>;
868 static_assert(
869 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
870
872 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
873
874 return std::equal(this->cbegin(), this->cend(), other.cbegin());
875 }
876
877 // skips some runtime checks when both sizes are fixed:
878 template <typename OArrayType, ComponentIdType OSize>
880 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
881 {
882 // Check that types are convertible:
883 using OAPIType = GetAPIType<OArrayType>;
884 static_assert(
885 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
886
887 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
888 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
889
890 return std::equal(this->cbegin(), this->cend(), other.cbegin());
891 }
892
893 // Needs a runtime check:
894 template <typename OArrayType, ComponentIdType OSize>
896 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
897 {
898 // Check that types are convertible:
899 using OAPIType = GetAPIType<OArrayType>;
900 static_assert(
901 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
902
904 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
905
906 return std::equal(this->cbegin(), this->cend(), other.cbegin());
907 }
908
909 template <typename OArrayType, ComponentIdType OSize>
911 {
912 return !(*this == o);
913 }
914
915 template <typename OArrayT, ComponentIdType OSize>
917 {
918 return !(*this == o);
919 }
920
923 {
924 return const_reference{ this->Array, this->NumComps, this->TupleId, i };
925 }
926
928 size_type size() const noexcept { return this->NumComps.value; }
929
931 const_iterator begin() const noexcept { return this->NewConstIterator(0); }
933 const_iterator end() const noexcept { return this->NewConstIterator(this->NumComps.value); }
934
936 const_iterator cbegin() const noexcept { return this->NewConstIterator(0); }
938 const_iterator cend() const noexcept { return this->NewConstIterator(this->NumComps.value); }
939
940 friend struct ConstTupleIterator<ArrayType, TupleSize>;
941
942protected:
943 // Intentionally hidden:
946
949 {
950 VTK_ITER_ASSUME(this->NumComps.value > 0);
951 return const_iterator{ this->Array, this->NumComps, this->TupleId, comp };
952 }
953
955 void CopyReference(const ConstTupleReference& o) noexcept
956 {
957 // Must use same array, other array types may use different implementations.
958 VTK_ITER_ASSERT(this->Array == o.Array, "Cannot copy reference objects between arrays.");
959 this->NumComps = o.NumComps;
960 this->TupleId = o.TupleId;
961 }
962
963 mutable ArrayType* Array;
966};
967
968//------------------------------------------------------------------------------
969// Tuple reference
970template <typename ArrayType, ComponentIdType TupleSize>
972{
973private:
974 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
975 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
976
978 using APIType = GetAPIType<ArrayType>;
979
980public:
982 using value_type = APIType;
987
989 TupleReference() noexcept
990 : Array(nullptr)
991 , TupleId(0)
992 {
993 }
994
996 TupleReference(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
997 : Array(array)
998 , NumComps(numComps)
999 , TupleId(tupleId)
1000 {
1001 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
1002 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
1003 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
1004 "Tuple reference at invalid tuple id.");
1005 }
1006
1010 TupleReference(TupleReference&&) noexcept = default;
1011
1012 // Allow this type to masquerade as a pointer, so that tupleIiter->foo works.
1014 TupleReference* operator->() noexcept { return this; }
1016 const TupleReference* operator->() const noexcept { return this; }
1017
1018 // Caller must ensure that there are size() elements in array.
1019 VTK_ITER_INLINE void GetTuple(APIType* tuple) const noexcept
1020 {
1021 VTK_ITER_ASSUME(this->NumComps.value > 0);
1022 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1023 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1024 {
1025 this->Array->GetTuple(this->TupleId, tuple);
1026 }
1027 else
1028 {
1029 this->Array->GetTypedTuple(this->TupleId, tuple);
1030 }
1031 }
1032
1033 template <typename VT = APIType>
1034 typename std::enable_if_t<!std::is_same_v<VT, double>> VTK_ITER_INLINE GetTuple(
1035 double* tuple) const noexcept
1036 {
1037 VTK_ITER_ASSUME(this->NumComps.value > 0);
1038 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1039 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1040 {
1041 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1042 {
1043 tuple[comp] = static_cast<double>(this->Array->GetComponent(this->TupleId, comp));
1044 }
1045 }
1046 else
1047 {
1048 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1049 {
1050 tuple[comp] = static_cast<double>(this->Array->GetTypedComponent(this->TupleId, comp));
1051 }
1052 }
1053 }
1054
1055 // Caller must ensure that there are size() elements in array.
1056 VTK_ITER_INLINE void SetTuple(const APIType* tuple) noexcept
1057 {
1058 VTK_ITER_ASSUME(this->NumComps.value > 0);
1059 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1060 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1061 {
1062 this->Array->SetTuple(this->TupleId, tuple);
1063 }
1064 else
1065 {
1066 this->Array->SetTypedTuple(this->TupleId, tuple);
1067 }
1068 }
1069
1070 template <typename VT = APIType>
1071 typename std::enable_if_t<!std::is_same_v<VT, double>> VTK_ITER_INLINE SetTuple(
1072 const double* tuple) noexcept
1073 {
1074 VTK_ITER_ASSUME(this->NumComps.value > 0);
1075 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1076 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1077 {
1078 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1079 {
1080 this->Array->SetComponent(this->TupleId, comp, static_cast<APIType>(tuple[comp]));
1081 }
1082 }
1083 else
1084 {
1085 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1086 {
1087 this->Array->SetTypedComponent(this->TupleId, comp, static_cast<APIType>(tuple[comp]));
1088 }
1089 }
1090 }
1091
1094 {
1095 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
1096 return *this;
1097 }
1098
1099 // skips some runtime checks when both sizes are fixed:
1100 template <typename OArrayType, ComponentIdType OSize>
1102 const TupleReference<OArrayType, OSize>& other) noexcept
1103 {
1104 // Check that types are convertible:
1105 using OAPIType = GetAPIType<OArrayType>;
1106 static_assert(
1107 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1108
1109 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1110 static_assert(TupleSize == OSize, "Cannot assign tuples with different sizes.");
1111
1112 std::copy_n(other.cbegin(), OSize, this->begin());
1113 return *this;
1114 }
1115
1116 // Needs a runtime check:
1117 template <typename OArrayType, ComponentIdType OSize>
1119 const TupleReference<OArrayType, OSize>& other) noexcept
1120 {
1121 // Check that types are convertible:
1122 using OAPIType = GetAPIType<OArrayType>;
1123 static_assert(
1124 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1125
1127 other.size() == this->NumComps.value, "Cannot assign tuples with different sizes.");
1128
1129 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
1130 return *this;
1131 }
1132
1133 // skips some runtime checks when both sizes are fixed:
1134 template <typename OArrayType, ComponentIdType OSize>
1136 const ConstTupleReference<OArrayType, OSize>& other) noexcept
1137 {
1138 // Check that types are convertible:
1139 using OAPIType = GetAPIType<OArrayType>;
1140 static_assert(
1141 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1142
1143 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1144 static_assert(TupleSize == OSize, "Cannot assign tuples with different sizes.");
1145
1146 std::copy_n(other.cbegin(), OSize, this->begin());
1147 return *this;
1148 }
1149
1150 // Needs a runtime check:
1151 template <typename OArrayType, ComponentIdType OSize>
1153 const ConstTupleReference<OArrayType, OSize>& other) noexcept
1154 {
1155 // Check that types are convertible:
1156 using OAPIType = GetAPIType<OArrayType>;
1157 static_assert(
1158 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1159
1161 other.size() == this->NumComps.value, "Cannot assign tuples with different sizes.");
1162
1163 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
1164 return *this;
1165 }
1166
1167 // skips some runtime checks when both sizes are fixed:
1168 template <typename OArrayType, ComponentIdType OSize>
1170 const TupleReference<OArrayType, OSize>& other) const noexcept
1171 {
1172 // Check that types are convertible:
1173 using OAPIType = GetAPIType<OArrayType>;
1174 static_assert(
1175 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1176
1177 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1178 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
1179
1180 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1181 }
1182
1183 // Needs a runtime check:
1184 template <typename OArrayType, ComponentIdType OSize>
1186 const TupleReference<OArrayType, OSize>& other) const noexcept
1187 {
1188 // Check that types are convertible:
1189 using OAPIType = GetAPIType<OArrayType>;
1190 static_assert(
1191 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1192
1194 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
1195
1196 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1197 }
1198
1199 // skips some runtime checks when both sizes are fixed:
1200 template <typename OArrayType, ComponentIdType OSize>
1202 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
1203 {
1204 // Check that types are convertible:
1205 using OAPIType = GetAPIType<OArrayType>;
1206 static_assert(
1207 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1208
1209 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1210 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
1211
1212 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1213 }
1214
1215 // Needs a runtime check:
1216 template <typename OArrayType, ComponentIdType OSize>
1218 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
1219 {
1220 // Check that types are convertible:
1221 using OAPIType = GetAPIType<OArrayType>;
1222 static_assert(
1223 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1224
1226 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
1227
1228 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1229 }
1230
1231 template <typename OArrayType, ComponentIdType OSize>
1233 {
1234 return !(*this == o);
1235 }
1236
1237 template <typename OArray, ComponentIdType OSize>
1239 {
1240 return !(*this == o);
1241 }
1242
1243 // skips some runtime checks:
1244 template <typename OArrayType, ComponentIdType OSize>
1246 TupleReference<OArrayType, OSize> other) noexcept
1247 {
1248 // Check that types are convertible:
1249 using OAPIType = GetAPIType<OArrayType>;
1250 static_assert(
1251 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when swapping tuples.");
1252
1253 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1254 static_assert(TupleSize == OSize, "Cannot swap tuples with different sizes.");
1255
1256 std::swap_ranges(this->begin(), this->end(), other.begin());
1257 }
1258
1259 // Needs a runtime check:
1260 template <typename OArrayType, ComponentIdType OSize>
1262 TupleReference<OArrayType, OSize> other) noexcept
1263 {
1264 // Check that types are convertible:
1265 using OAPIType = GetAPIType<OArrayType>;
1266 static_assert(
1267 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when swapping tuples.");
1268
1270 other.size() == this->NumComps.value, "Cannot swap tuples with different sizes.");
1271
1272 std::swap_ranges(this->begin(), this->end(), other.begin());
1273 }
1274
1275 friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference b) noexcept { a.swap(b); }
1276
1277 template <typename OArray, ComponentIdType OSize>
1279 {
1280 a.swap(b);
1281 }
1282
1285 {
1286 return reference{ this->Array, this->NumComps, this->TupleId, i };
1287 }
1288
1291 {
1292 // Let the reference type do the lookup during implicit conversion.
1293 return const_reference{ this->Array, this->NumComps, this->TupleId, i };
1294 }
1295
1297 void fill(const value_type& v) noexcept { std::fill(this->begin(), this->end(), v); }
1298
1300 size_type size() const noexcept { return this->NumComps.value; }
1301
1303 iterator begin() noexcept { return this->NewIterator(0); }
1305 iterator end() noexcept { return this->NewIterator(this->NumComps.value); }
1306
1308 const_iterator begin() const noexcept { return this->NewConstIterator(0); }
1310 const_iterator end() const noexcept { return this->NewConstIterator(this->NumComps.value); }
1311
1313 const_iterator cbegin() const noexcept { return this->NewConstIterator(0); }
1315 const_iterator cend() const noexcept { return this->NewConstIterator(this->NumComps.value); }
1316
1317 friend struct ConstTupleReference<ArrayType, TupleSize>;
1318 friend struct TupleIterator<ArrayType, TupleSize>;
1319
1320protected:
1323 {
1324 VTK_ITER_ASSUME(this->NumComps.value > 0);
1325 return iterator{ this->Array, this->NumComps, this->TupleId, comp };
1326 }
1327
1330 {
1331 VTK_ITER_ASSUME(this->NumComps.value > 0);
1332 return const_iterator{ this->Array, this->NumComps, this->TupleId, comp };
1333 }
1334
1336 void CopyReference(const TupleReference& o) noexcept
1337 {
1338 // Must use same array, other array types may use different implementations.
1339 VTK_ITER_ASSERT(this->Array == o.Array, "Cannot copy reference objects between arrays.");
1340 this->NumComps = o.NumComps;
1341 this->TupleId = o.TupleId;
1342 }
1343
1344 mutable ArrayType* Array;
1347};
1348
1349//------------------------------------------------------------------------------
1350// Const tuple iterator
1351template <typename ArrayType, ComponentIdType TupleSize>
1353{
1354private:
1355 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1356 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
1357
1359
1360public:
1361 using iterator_category = std::random_access_iterator_tag;
1366
1368 ConstTupleIterator() noexcept = default;
1369
1371 ConstTupleIterator(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
1372 : Ref(array, numComps, tupleId)
1373 {
1374 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
1375 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
1376 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
1377 "Const tuple iterator at invalid tuple id.");
1378 }
1379
1382 : Ref{ o.Ref }
1383 {
1384 }
1385
1387 ConstTupleIterator(const ConstTupleIterator& o) noexcept = default;
1390 {
1391 this->Ref.CopyReference(o.Ref);
1392 return *this;
1393 }
1394
1396 ConstTupleIterator& operator++() noexcept // prefix
1397 {
1398 ++this->Ref.TupleId;
1400 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1401 "Const tuple iterator at invalid component id.");
1402 return *this;
1403 }
1404
1406 ConstTupleIterator operator++(int) noexcept // postfix
1407 {
1408 return ConstTupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId++ };
1409 }
1410
1412 ConstTupleIterator& operator--() noexcept // prefix
1413 {
1414 --this->Ref.TupleId;
1416 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1417 "Const tuple iterator at invalid component id.");
1418 return *this;
1419 }
1420
1422 ConstTupleIterator operator--(int) noexcept // postfix
1423 {
1424 return ConstTupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId-- };
1425 }
1426
1429 {
1430 return reference{ this->GetArray(), this->GetNumComps(), this->GetTupleId() + i };
1431 }
1432
1434 reference operator*() noexcept { return this->Ref; }
1435
1437 pointer operator->() noexcept { return this->Ref; }
1438
1439#define VTK_TMP_MAKE_OPERATOR(OP) \
1440 friend VTK_ITER_INLINE bool operator OP( \
1441 const ConstTupleIterator& lhs, const ConstTupleIterator& rhs) noexcept \
1442 { \
1443 VTK_ITER_ASSERT( \
1444 lhs.GetArray() == rhs.GetArray(), "Cannot compare iterators from different arrays."); \
1445 VTK_ITER_ASSUME(lhs.GetNumComps().value > 0); \
1446 VTK_ITER_ASSUME(lhs.GetNumComps().value == rhs.GetNumComps().value); \
1447 return lhs.GetTupleId() OP rhs.GetTupleId(); \
1448 }
1449
1456
1457#undef VTK_TMP_MAKE_OPERATOR
1458
1461 {
1462 this->Ref.TupleId += offset;
1464 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1465 "Const tuple iterator at invalid component id.");
1466 return *this;
1467 }
1468
1470 const ConstTupleIterator& it, difference_type offset) noexcept
1471 {
1472 return ConstTupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1473 }
1474
1476 difference_type offset, const ConstTupleIterator& it) noexcept
1477 {
1478 return ConstTupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1479 }
1480
1483 {
1484 this->Ref.TupleId -= offset;
1486 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1487 "Const tuple iterator at invalid component id.");
1488 return *this;
1489 }
1490
1492 const ConstTupleIterator& it, difference_type offset) noexcept
1493 {
1494 return ConstTupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() - offset };
1495 }
1496
1498 const ConstTupleIterator& it1, const ConstTupleIterator& it2) noexcept
1499 {
1500 VTK_ITER_ASSERT(it1.GetArray() == it2.GetArray(),
1501 "Cannot do math with tuple iterators from different "
1502 "arrays.");
1503 return it1.GetTupleId() - it2.GetTupleId();
1504 }
1505
1507 {
1508 // Different arrays may use different iterator implementations.
1510 lhs.GetArray() == rhs.GetArray(), "Cannot swap iterators from different arrays.");
1511
1512 using std::swap;
1513 swap(lhs.GetTupleId(), rhs.GetTupleId());
1514 }
1515
1516private:
1518 ArrayType* GetArray() const noexcept { return this->Ref.Array; }
1520 ArrayType*& GetArray() noexcept { return this->Ref.Array; }
1522 NumCompsType GetNumComps() const noexcept { return this->Ref.NumComps; }
1524 NumCompsType& GetNumComps() noexcept { return this->Ref.NumComps; }
1526 TupleIdType GetTupleId() const noexcept { return this->Ref.TupleId; }
1528 TupleIdType& GetTupleId() noexcept { return this->Ref.TupleId; }
1529
1530 ConstTupleReference<ArrayType, TupleSize> Ref;
1531};
1532
1533//------------------------------------------------------------------------------
1534// Tuple iterator
1535template <typename ArrayType, ComponentIdType TupleSize>
1537{
1538private:
1539 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1540 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
1541
1543
1544public:
1545 using iterator_category = std::random_access_iterator_tag;
1550
1552 TupleIterator() noexcept = default;
1553
1555 TupleIterator(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
1556 : Ref(array, numComps, tupleId)
1557 {
1558 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
1559 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
1561 tupleId >= 0 && tupleId <= array->GetNumberOfTuples(), "Tuple iterator at invalid tuple id.");
1562 }
1563
1565 TupleIterator(const TupleIterator& o) noexcept = default;
1566
1569 {
1570 this->Ref.CopyReference(o.Ref);
1571 return *this;
1572 }
1573
1575 TupleIterator& operator++() noexcept // prefix
1576 {
1577 ++this->Ref.TupleId;
1579 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1580 "Tuple iterator at invalid component id.");
1581 return *this;
1582 }
1583
1585 TupleIterator operator++(int) noexcept // postfix
1586 {
1587 return TupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId++ };
1588 }
1589
1591 TupleIterator& operator--() noexcept // prefix
1592 {
1593 --this->Ref.TupleId;
1595 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1596 "Tuple iterator at invalid component id.");
1597 return *this;
1598 }
1599
1601 TupleIterator operator--(int) noexcept // postfix
1602 {
1603 return TupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId-- };
1604 }
1605
1608 {
1609 return reference{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId + i };
1610 }
1611
1613 reference operator*() noexcept { return this->Ref; }
1614
1616 pointer& operator->() noexcept { return this->Ref; }
1617
1618#define VTK_TMP_MAKE_OPERATOR(OP) \
1619 friend VTK_ITER_INLINE bool operator OP( \
1620 const TupleIterator& lhs, const TupleIterator& rhs) noexcept \
1621 { \
1622 VTK_ITER_ASSERT( \
1623 lhs.GetArray() == rhs.GetArray(), "Cannot compare iterators from different arrays."); \
1624 VTK_ITER_ASSUME(lhs.GetNumComps().value > 0); \
1625 VTK_ITER_ASSUME(lhs.GetNumComps().value == rhs.GetNumComps().value); \
1626 return lhs.GetTupleId() OP rhs.GetTupleId(); \
1627 }
1628
1635
1636#undef VTK_TMP_MAKE_OPERATOR
1637
1640 {
1641 this->Ref.TupleId += offset;
1643 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1644 "Tuple iterator at invalid component id.");
1645 return *this;
1646 }
1647
1649 const TupleIterator& it, difference_type offset) noexcept
1650 {
1651 return TupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1652 }
1653
1655 difference_type offset, const TupleIterator& it) noexcept
1656 {
1657 return TupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1658 }
1659
1662 {
1663 this->Ref.TupleId -= offset;
1665 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1666 "Tuple iterator at invalid component id.");
1667 return *this;
1668 }
1669
1671 const TupleIterator& it, difference_type offset) noexcept
1672 {
1673 return TupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() - offset };
1674 }
1675
1677 const TupleIterator& it1, const TupleIterator& it2) noexcept
1678 {
1679 VTK_ITER_ASSERT(it1.GetArray() == it2.GetArray(),
1680 "Cannot do math with tuple iterators from different "
1681 "arrays.");
1682 return it1.GetTupleId() - it2.GetTupleId();
1683 }
1684
1685 friend VTK_ITER_INLINE void swap(TupleIterator& lhs, TupleIterator& rhs) noexcept
1686 {
1687 // Different arrays may use different iterator implementations.
1689 lhs.GetArray() == rhs.GetArray(), "Cannot swap iterators from different arrays.");
1690
1691 using std::swap;
1692 swap(lhs.GetTupleId(), rhs.GetTupleId());
1693 }
1694
1695 friend struct ConstTupleIterator<ArrayType, TupleSize>;
1696 friend struct ConstTupleReference<ArrayType, TupleSize>;
1697
1698protected:
1700 ArrayType* GetArray() const noexcept { return this->Ref.Array; }
1702 ArrayType*& GetArray() noexcept { return this->Ref.Array; }
1704 NumCompsType GetNumComps() const noexcept { return this->Ref.NumComps; }
1706 NumCompsType& GetNumComps() noexcept { return this->Ref.NumComps; }
1708 TupleIdType GetTupleId() const noexcept { return this->Ref.TupleId; }
1710 TupleIdType& GetTupleId() noexcept { return this->Ref.TupleId; }
1711
1713};
1714
1715//------------------------------------------------------------------------------
1716// Tuple range
1717template <typename ArrayTypeT, ComponentIdType TupleSize>
1719{
1720 using ArrayType = ArrayTypeT;
1723
1724private:
1725 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1726 static_assert(IsVtkDataArray<ArrayTypeT>::value, "Invalid array type.");
1727
1729
1730public:
1740
1741 // May be DynamicTupleSize, or the actual tuple size.
1742 constexpr static ComponentIdType TupleSizeTag = TupleSize;
1743
1749
1751 TupleRange() noexcept = default;
1752
1754 TupleRange(ArrayType* arr, TupleIdType beginTuple, TupleIdType endTuple) noexcept
1755 : Array(arr)
1756 , NumComps(arr)
1757 , BeginTuple(beginTuple)
1758 , EndTuple(endTuple)
1759 {
1760 assert(this->Array);
1761 assert(beginTuple >= 0 && beginTuple <= endTuple);
1762 assert(endTuple >= 0 && endTuple <= this->Array->GetNumberOfTuples());
1763 }
1764
1766 TupleRange GetSubRange(TupleIdType beginTuple = 0, TupleIdType endTuple = -1) const noexcept
1767 {
1768 const TupleIdType realBegin = this->BeginTuple + beginTuple;
1769 const TupleIdType realEnd = endTuple >= 0 ? this->BeginTuple + endTuple : this->EndTuple;
1770
1771 return TupleRange{ this->Array, realBegin, realEnd };
1772 }
1773
1775 ArrayType* GetArray() const noexcept { return this->Array; }
1777 ComponentIdType GetTupleSize() const noexcept { return this->NumComps.value; }
1779 TupleIdType GetBeginTupleId() const noexcept { return this->BeginTuple; }
1781 TupleIdType GetEndTupleId() const noexcept { return this->EndTuple; }
1782
1784 size_type size() const noexcept { return this->EndTuple - this->BeginTuple; }
1785
1787 iterator begin() noexcept { return this->NewIter(this->BeginTuple); }
1789 iterator end() noexcept { return this->NewIter(this->EndTuple); }
1790
1792 const_iterator begin() const noexcept { return this->NewCIter(this->BeginTuple); }
1794 const_iterator end() const noexcept { return this->NewCIter(this->EndTuple); }
1795
1797 const_iterator cbegin() const noexcept { return this->NewCIter(this->BeginTuple); }
1799 const_iterator cend() const noexcept { return this->NewCIter(this->EndTuple); }
1800
1803 {
1804 return reference{ this->Array, this->NumComps, this->BeginTuple + i };
1805 }
1806
1809 {
1810 return const_reference{ this->Array, this->NumComps, this->BeginTuple + i };
1811 }
1812
1813 void VTK_ITER_INLINE GetTuple(size_type i, ValueType* tuple) const noexcept
1814 {
1815 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1816 {
1817 this->Array->GetTuple(this->BeginTuple + i, tuple);
1818 }
1819 else
1820 {
1821 this->Array->GetTypedTuple(this->BeginTuple + i, tuple);
1822 }
1823 }
1824
1825 template <typename VT = APIType>
1826 typename std::enable_if_t<!std::is_same_v<VT, double>> VTK_ITER_INLINE GetTuple(
1827 size_type i, double* tuple) const noexcept
1828 {
1829 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1830 {
1831 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1832 {
1833 tuple[comp] = static_cast<double>(this->Array->GetComponent(i, comp));
1834 }
1835 }
1836 else
1837 {
1838 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1839 {
1840 tuple[comp] = static_cast<double>(this->Array->GetTypedComponent(i, comp));
1841 }
1842 }
1843 }
1844
1845 void VTK_ITER_INLINE SetTuple(size_type i, const ValueType* tuple) noexcept
1846 {
1847 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1848 {
1849 this->Array->SetTuple(this->BeginTuple + i, tuple);
1850 }
1851 else
1852 {
1853 this->Array->SetTypedTuple(this->BeginTuple + i, tuple);
1854 }
1855 }
1856
1857 template <typename VT = APIType>
1858 typename std::enable_if_t<!std::is_same_v<VT, double>> VTK_ITER_INLINE SetTuple(
1859 size_type i, const double* tuple) noexcept
1860 {
1861 if constexpr (std::is_same<ArrayType, vtkDataArray>::value)
1862 {
1863 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1864 {
1865 this->Array->SetComponent(this->BeginTuple + i, comp, static_cast<ValueType>(tuple[comp]));
1866 }
1867 }
1868 else
1869 {
1870 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1871 {
1872 this->Array->SetTypedComponent(
1873 this->BeginTuple + i, comp, static_cast<ValueType>(tuple[comp]));
1874 }
1875 }
1876 }
1877
1878private:
1880 iterator NewIter(TupleIdType t) const { return iterator{ this->Array, this->NumComps, t }; }
1881
1883 const_iterator NewCIter(TupleIdType t) const
1884 {
1885 return const_iterator{ this->Array, this->NumComps, t };
1886 }
1887
1888 mutable ArrayType* Array{ nullptr };
1889 NumCompsType NumComps{};
1890 TupleIdType BeginTuple{ 0 };
1891 TupleIdType EndTuple{ 0 };
1892};
1893
1894// Unimplemented, only used inside decltype in SelectTupleRange:
1895template <typename ArrayType, ComponentIdType TupleSize>
1897
1898VTK_ABI_NAMESPACE_END
1899} // end namespace detail
1900} // end namespace vtk
1901
1903
1904#endif // __VTK_WRAP__
1905
1906// VTK-HeaderTest-Exclude: vtkDataArrayTupleRange_Generic.h
abstract superclass for arrays of numeric data
typename std::enable_if< AreStaticTupleSizes< S1, S2 >::value, T >::type EnableIfStaticTupleSizes
TupleRange< AOSArrayType, TupleSize > DeclareTupleRangeSpecialization(ArrayType *)
typename std::enable_if< IsEitherTupleSizeDynamic< S1, S2 >::value, T >::type EnableIfEitherTupleSizeIsDynamic
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
typename detail::GetAPITypeImpl< ArrayType, ForceValueTypeForVtkDataArray >::APIType GetAPIType
vtkIdType TupleIdType
int ComponentIdType
const ComponentIdType & GetComponentId() const noexcept
ComponentReference< ArrayType, TupleSize > Ref
VTK_ITER_INLINE ComponentIterator(const ComponentIterator &o) noexcept=default
VTK_ITER_INLINE reference operator[](difference_type i) const noexcept
friend VTK_ITER_INLINE difference_type operator-(const ComponentIterator &it1, const ComponentIterator &it2) noexcept
VTK_ITER_INLINE ComponentIterator operator++(int) noexcept
VTK_ITER_INLINE const pointer & operator->() const noexcept
VTK_ITER_INLINE ComponentIterator & operator+=(difference_type offset) noexcept
friend VTK_ITER_INLINE void swap(ComponentIterator &lhs, ComponentIterator &rhs) noexcept
VTK_ITER_INLINE ComponentIterator operator--(int) noexcept
std::random_access_iterator_tag iterator_category
friend VTK_ITER_INLINE ComponentIterator operator+(const ComponentIterator &it, difference_type offset) noexcept
const TupleIdType & GetTupleId() const noexcept
VTK_ITER_INLINE ComponentIterator() noexcept=default
VTK_ITER_INLINE ComponentIterator & operator--() noexcept
VTK_ITER_INLINE ComponentIterator & operator=(const ComponentIterator &o) noexcept
VTK_ITER_INLINE ComponentIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE reference operator*() const noexcept
const NumCompsType & GetNumComps() const noexcept
VTK_ITER_INLINE ComponentIterator & operator++() noexcept
friend VTK_ITER_INLINE ComponentIterator operator+(difference_type offset, const ComponentIterator &it) noexcept
friend VTK_ITER_INLINE ComponentIterator operator-(const ComponentIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE ComponentReference operator++() noexcept
VTK_ITER_INLINE ComponentReference(ComponentReference &&o) noexcept=default
VTK_ITER_INLINE ComponentReference operator=(ComponentReference &&o) noexcept
VTK_ITER_INLINE APIType operator++(int) noexcept
VTK_ITER_INLINE ComponentReference operator--() noexcept
friend VTK_ITER_INLINE void swap(ComponentReference lhs, ComponentReference rhs) noexcept
VTK_ITER_INLINE ComponentReference(const ComponentReference &o) noexcept=default
friend VTK_ITER_INLINE void swap(APIType &lhs, ComponentReference rhs) noexcept
VTK_ITER_INLINE ComponentReference operator=(APIType val) noexcept
friend VTK_ITER_INLINE void swap(ComponentReference lhs, ComponentReference< OArray, OSize > rhs) noexcept
VTK_ITER_INLINE ComponentReference(ArrayType *array, NumCompsType numComps, TupleIdType tuple, ComponentIdType comp) noexcept
VTK_ITER_INLINE ComponentReference operator=(const ComponentReference< OArray, OSize > &o) noexcept
friend VTK_ITER_INLINE void swap(ComponentReference lhs, APIType &rhs) noexcept
VTK_ITER_INLINE ComponentReference operator=(const ComponentReference &o) noexcept
VTK_ITER_INLINE void CopyReference(const ComponentReference &o) noexcept
friend VTK_ITER_INLINE ConstComponentIterator operator+(difference_type offset, const ConstComponentIterator &it) noexcept
VTK_ITER_INLINE ConstComponentIterator & operator--() noexcept
VTK_ITER_INLINE ConstComponentIterator & operator=(const ConstComponentIterator &o) noexcept=default
VTK_ITER_INLINE ConstComponentIterator(const ConstComponentIterator &o) noexcept=default
friend VTK_ITER_INLINE difference_type operator-(const ConstComponentIterator &it1, const ConstComponentIterator &it2) noexcept
std::random_access_iterator_tag iterator_category
VTK_ITER_INLINE reference operator*() const noexcept
VTK_ITER_INLINE ConstComponentIterator operator--(int) noexcept
VTK_ITER_INLINE ConstComponentIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE ConstComponentIterator & operator++() noexcept
friend VTK_ITER_INLINE void swap(ConstComponentIterator &lhs, ConstComponentIterator &rhs) noexcept
VTK_ITER_INLINE ConstComponentIterator(const ComponentIterator< ArrayType, TupleSize > &o) noexcept
friend VTK_ITER_INLINE ConstComponentIterator operator-(const ConstComponentIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE ConstComponentIterator(ArrayType *array, NumCompsType numComps, TupleIdType tupleId, ComponentIdType comp) noexcept
VTK_ITER_INLINE ConstComponentIterator operator++(int) noexcept
friend VTK_ITER_INLINE ConstComponentIterator operator+(const ConstComponentIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE reference operator[](difference_type i) const noexcept
VTK_ITER_INLINE ConstComponentIterator & operator-=(difference_type offset) noexcept
VTK_ITER_INLINE ConstComponentReference(const ConstComponentReference &o) noexcept=default
VTK_ITER_INLINE ConstComponentReference & operator=(ConstComponentReference &&o) noexcept
VTK_ITER_INLINE ConstComponentReference(const ComponentReference< ArrayType, TupleSize > &o)
VTK_ITER_INLINE ConstComponentReference & operator=(const ConstComponentReference &o) noexcept
VTK_ITER_INLINE ConstComponentReference(ArrayType *array, NumCompsType numComps, TupleIdType tuple, ComponentIdType comp) noexcept
VTK_ITER_INLINE ConstComponentReference(ConstComponentReference &&o) noexcept=default
VTK_ITER_INLINE ConstTupleIterator & operator+=(difference_type offset) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator=(const ConstTupleIterator &o) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator++() noexcept
friend VTK_ITER_INLINE void swap(ConstTupleIterator &lhs, ConstTupleIterator &rhs) noexcept
VTK_ITER_INLINE ConstTupleIterator operator--(int) noexcept
friend VTK_ITER_INLINE ConstTupleIterator operator+(difference_type offset, const ConstTupleIterator &it) noexcept
VTK_ITER_INLINE reference operator*() noexcept
VTK_ITER_INLINE ConstTupleIterator() noexcept=default
VTK_ITER_INLINE pointer operator->() noexcept
std::random_access_iterator_tag iterator_category
friend VTK_ITER_INLINE ConstTupleIterator operator+(const ConstTupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
friend VTK_ITER_INLINE ConstTupleIterator operator-(const ConstTupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE ConstTupleIterator(const ConstTupleIterator &o) noexcept=default
VTK_ITER_INLINE ConstTupleIterator(const TupleIterator< ArrayType, TupleSize > &o) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator-=(difference_type offset) noexcept
friend VTK_ITER_INLINE difference_type operator-(const ConstTupleIterator &it1, const ConstTupleIterator &it2) noexcept
VTK_ITER_INLINE ConstTupleIterator operator++(int) noexcept
VTK_ITER_INLINE ConstTupleIterator & operator--() noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE const ConstTupleReference * operator->() const noexcept
VTK_ITER_INLINE ConstTupleReference(ConstTupleReference &&) noexcept=default
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE void CopyReference(const ConstTupleReference &o) noexcept
std::enable_if_t<!std::is_same_v< VT, double > > VTK_ITER_INLINE GetTuple(double *tuple) const noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE ConstTupleReference(ArrayType *array, NumCompsType numComps, TupleIdType tupleId) noexcept
VTK_ITER_INLINE ConstTupleReference(const ConstTupleReference &) noexcept=default
VTK_ITER_INLINE void GetTuple(APIType *tuple) const noexcept
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArrayT, OSize > &o) const noexcept
VTK_ITER_INLINE const_iterator NewConstIterator(ComponentIdType comp) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE ConstTupleReference(const TupleReference< ArrayType, TupleSize > &o) noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE ConstTupleReference & operator=(const ConstTupleReference &) noexcept=default
VTK_ITER_INLINE TupleIterator & operator=(const TupleIterator &o) noexcept
VTK_ITER_INLINE ArrayType *& GetArray() noexcept
friend VTK_ITER_INLINE TupleIterator operator+(const TupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE TupleIdType & GetTupleId() noexcept
friend VTK_ITER_INLINE void swap(TupleIterator &lhs, TupleIterator &rhs) noexcept
VTK_ITER_INLINE NumCompsType GetNumComps() const noexcept
VTK_ITER_INLINE TupleIterator(const TupleIterator &o) noexcept=default
VTK_ITER_INLINE ArrayType * GetArray() const noexcept
VTK_ITER_INLINE TupleIterator & operator++() noexcept
VTK_ITER_INLINE TupleIterator & operator--() noexcept
VTK_ITER_INLINE NumCompsType & GetNumComps() noexcept
VTK_ITER_INLINE pointer & operator->() noexcept
friend VTK_ITER_INLINE TupleIterator operator-(const TupleIterator &it, difference_type offset) noexcept
VTK_ITER_INLINE TupleIdType GetTupleId() const noexcept
VTK_ITER_INLINE TupleIterator & operator+=(difference_type offset) noexcept
TupleReference< ArrayType, TupleSize > Ref
VTK_ITER_INLINE reference operator[](difference_type i) noexcept
friend VTK_ITER_INLINE TupleIterator operator+(difference_type offset, const TupleIterator &it) noexcept
VTK_ITER_INLINE reference operator*() noexcept
VTK_ITER_INLINE TupleIterator operator++(int) noexcept
VTK_ITER_INLINE TupleIterator operator--(int) noexcept
VTK_ITER_INLINE TupleIterator & operator-=(difference_type offset) noexcept
friend VTK_ITER_INLINE difference_type operator-(const TupleIterator &it1, const TupleIterator &it2) noexcept
std::random_access_iterator_tag iterator_category
VTK_ITER_INLINE TupleIterator() noexcept=default
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE ArrayType * GetArray() const noexcept
VTK_ITER_INLINE TupleIdType GetBeginTupleId() const noexcept
VTK_ITER_INLINE TupleIdType GetEndTupleId() const noexcept
std::enable_if_t<!std::is_same_v< VT, double > > VTK_ITER_INLINE GetTuple(size_type i, double *tuple) const noexcept
std::enable_if_t<!std::is_same_v< VT, double > > VTK_ITER_INLINE SetTuple(size_type i, const double *tuple) noexcept
static constexpr ComponentIdType TupleSizeTag
TupleIterator< ArrayType, TupleSize > TupleIteratorType
VTK_ITER_INLINE TupleRange() noexcept=default
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE size_type size() const noexcept
ConstTupleIterator< ArrayType, TupleSize > ConstTupleIteratorType
VTK_ITER_INLINE reference operator[](size_type i) noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
TupleReference< ArrayType, TupleSize > TupleReferenceType
VTK_ITER_INLINE ComponentIdType GetTupleSize() const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE iterator end() noexcept
ConstTupleReference< ArrayType, TupleSize > ConstTupleReferenceType
void VTK_ITER_INLINE GetTuple(size_type i, ValueType *tuple) const noexcept
VTK_ITER_INLINE TupleRange GetSubRange(TupleIdType beginTuple=0, TupleIdType endTuple=-1) const noexcept
VTK_ITER_INLINE iterator begin() noexcept
void VTK_ITER_INLINE SetTuple(size_type i, const ValueType *tuple) noexcept
VTK_ITER_INLINE void SetTuple(const APIType *tuple) noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const TupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const TupleReference * operator->() const noexcept
VTK_ITER_INLINE reference operator[](size_type i) noexcept
VTK_ITER_INLINE TupleReference(const TupleReference &)=default
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE void GetTuple(APIType *tuple) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const TupleReference< OArrayType, OSize > &other) const noexcept
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference b) noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE TupleReference(ArrayType *array, NumCompsType numComps, TupleIdType tupleId) noexcept
VTK_ITER_INLINE TupleReference & operator=(const TupleReference &other) noexcept
VTK_ITER_INLINE TupleReference(TupleReference &&) noexcept=default
VTK_ITER_INLINE iterator NewIterator(ComponentIdType comp) const noexcept
VTK_ITER_INLINE const_iterator cend() const noexcept
VTK_ITER_INLINE size_type size() const noexcept
VTK_ITER_INLINE bool operator!=(const TupleReference< OArrayType, OSize > &o) const noexcept
VTK_ITER_INLINE void CopyReference(const TupleReference &o) noexcept
VTK_ITER_INLINE iterator begin() 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
VTK_ITER_INLINE const_iterator end() const noexcept
VTK_ITER_INLINE iterator end() noexcept
std::enable_if_t<!std::is_same_v< VT, double > > VTK_ITER_INLINE SetTuple(const double *tuple) noexcept
VTK_ITER_INLINE void fill(const value_type &v) noexcept
std::enable_if_t<!std::is_same_v< VT, double > > VTK_ITER_INLINE GetTuple(double *tuple) const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const ConstTupleReference< OArrayType, OSize > &other) noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, void > swap(TupleReference< OArrayType, OSize > other) noexcept
VTK_ITER_INLINE EnableIfStaticTupleSizes< TupleSize, OSize, bool > operator==(const ConstTupleReference< OArrayType, OSize > &other) const noexcept
VTK_ITER_INLINE const_iterator NewConstIterator(ComponentIdType comp) const noexcept
VTK_ITER_INLINE bool operator!=(const ConstTupleReference< OArray, OSize > &o) const noexcept
friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference< OArray, OSize > b) noexcept
This file contains a variety of metaprogramming constructs for working with vtkDataArrays.
#define VTK_ITER_OPTIMIZE_START
#define VTK_ITER_INLINE
#define VTK_ITER_OPTIMIZE_END
#define VTK_ITER_ASSERT(x, msg)
#define VTK_ITER_ASSUME
#define VTK_TMP_MAKE_OPERATOR(OP)
#define VTK_REF_OP_OVERLOADS(Op, ImplOp)