VTK  9.3.20240424
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 = std::move(o.TupleId);
122 this->ComponentId = std::move(o.ComponentId);
123 }
124
125 VTK_ITER_INLINE operator APIType() const noexcept { return this->castOperator(); }
126
127protected:
128 template <typename AT = ArrayType>
129 typename std::enable_if<std::is_same<AT, vtkDataArray>::value, APIType>::type VTK_ITER_INLINE
130 castOperator() const noexcept
131 {
132 VTK_ITER_ASSUME(this->NumComps.value > 0);
133 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
134 return this->Array->GetComponent(this->TupleId, this->ComponentId);
135 }
136
137 template <typename AT = ArrayType>
138 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value, APIType>::type VTK_ITER_INLINE
139 castOperator() const noexcept
140 {
141 VTK_ITER_ASSUME(this->NumComps.value > 0);
142 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
143 return this->Array->GetTypedComponent(this->TupleId, this->ComponentId);
144 }
145
146 mutable ArrayType* Array;
150};
151
152//------------------------------------------------------------------------------
153// Component reference
154template <typename ArrayType, ComponentIdType TupleSize>
156{
157private:
158 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
159 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
160
162 using APIType = GetAPIType<ArrayType>;
163
164public:
165 using value_type = APIType;
166
169 : Array{ nullptr }
170 , NumComps{}
171 , TupleId{ 0 }
172 , ComponentId{ 0 }
173 {
174 }
175
178 ArrayType* array, NumCompsType numComps, TupleIdType tuple, ComponentIdType comp) noexcept
179 : Array{ array }
180 , NumComps{ numComps }
181 , TupleId{ tuple }
182 , ComponentId{ comp }
183 {
184 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
185 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
187 tuple >= 0 && tuple <= array->GetNumberOfTuples(), "Invalid tuple accessed by iterator.");
188 VTK_ITER_ASSERT(comp >= 0 && comp <= array->GetNumberOfComponents(),
189 "Invalid component accessed by iterator.");
190 }
191
193 ComponentReference(const ComponentReference& o) noexcept = default;
195 ComponentReference(ComponentReference&& o) noexcept = default;
196
199 {
200 if (this->Array)
201 { // Already initialized. Assign the value, not the reference
202 return *this = static_cast<APIType>(o);
203 }
204 else
205 { // Initialize the reference.
206 this->Array = o.Array;
207 this->NumComps = o.NumComps;
208 this->TupleId = o.TupleId;
209 this->ComponentId = o.ComponentId;
210
211 return *this;
212 }
213 }
214
217 {
218 if (this->Array)
219 { // Already initialized. Assign the value, not the reference
220 return *this = std::move(static_cast<APIType>(o));
221 }
222 else
223 { // Initialize the reference.
224 this->Array = std::move(o.Array);
225 this->NumComps = std::move(o.NumComps);
226 this->TupleId = std::move(o.TupleId);
227 this->ComponentId = std::move(o.ComponentId);
228
229 return *this;
230 }
231 }
232
233 template <typename OArray, ComponentIdType OSize>
235 { // Always copy the value for different reference types:
236 const APIType tmp = o;
237 return *this = std::move(tmp);
238 }
239
240 VTK_ITER_INLINE operator APIType() const noexcept { return this->castOperator(); }
241
242 template <typename AT = ArrayType>
243 typename std::enable_if<std::is_same<AT, vtkDataArray>::value, ComponentReference>::type
245 operator=(APIType val) noexcept
246 {
247 VTK_ITER_ASSUME(this->NumComps.value > 0);
248 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
249 this->Array->SetComponent(this->TupleId, this->ComponentId, val);
250 return *this;
251 }
252
253 template <typename AT = ArrayType>
254 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value, ComponentReference>::type
256 operator=(APIType val) noexcept
257 {
258 VTK_ITER_ASSUME(this->NumComps.value > 0);
259 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
260 this->Array->SetTypedComponent(this->TupleId, this->ComponentId, val);
261 return *this;
262 }
263
265 { // Swap values, not references:
266 APIType tmp = std::move(static_cast<APIType>(lhs));
267 lhs = std::move(static_cast<APIType>(rhs));
268 rhs = std::move(tmp);
269 }
270
271 template <typename OArray, ComponentIdType OSize>
274 { // Swap values, not references:
275 using OAPIType = GetAPIType<OArray>;
276 static_assert(
277 std::is_same<APIType, OAPIType>::value, "Cannot swap components with different types.");
278
279 APIType tmp = std::move(static_cast<APIType>(lhs));
280 lhs = std::move(static_cast<APIType>(rhs));
281 rhs = std::move(tmp);
282 }
283
284 friend VTK_ITER_INLINE void swap(ComponentReference lhs, APIType& rhs) noexcept
285 {
286 APIType tmp = std::move(static_cast<APIType>(lhs));
287 lhs = std::move(rhs);
288 rhs = std::move(tmp);
289 }
290
291 friend VTK_ITER_INLINE void swap(APIType& lhs, ComponentReference rhs) noexcept
292 {
293 APIType tmp = std::move(lhs);
294 lhs = std::move(static_cast<APIType>(rhs));
295 rhs = std::move(tmp);
296 }
297
299 ComponentReference operator++() noexcept // prefix
300 {
301 const APIType newVal = *this + 1;
302 *this = newVal;
303 return *this;
304 }
305
307 APIType operator++(int) noexcept // postfix
308 {
309 const APIType retVal = *this;
310 *this = *this + 1;
311 return retVal;
312 }
313
315 ComponentReference operator--() noexcept // prefix
316 {
317 const APIType newVal = *this - 1;
318 *this = newVal;
319 return *this;
320 }
321
323 APIType operator--(int) noexcept // postfix
324 {
325 const APIType retVal = *this;
326 *this = *this - 1;
327 return retVal;
328 }
329
330#define VTK_REF_OP_OVERLOADS(Op, ImplOp) \
331 friend VTK_ITER_INLINE ComponentReference operator Op( \
332 ComponentReference lhs, APIType val) noexcept \
333 { \
334 const APIType newVal = lhs ImplOp val; \
335 lhs = newVal; \
336 return lhs; \
337 } \
338 friend VTK_ITER_INLINE ComponentReference operator Op( \
339 ComponentReference lhs, ComponentReference val) noexcept \
340 { \
341 const APIType newVal = lhs ImplOp val; \
342 lhs = newVal; \
343 return lhs; \
344 } \
345 friend VTK_ITER_INLINE APIType& operator Op(APIType& lhs, ComponentReference val) noexcept \
346 { \
347 const APIType newVal = lhs ImplOp val; \
348 lhs = newVal; \
349 return lhs; \
350 }
351
356
357#undef VTK_REF_OP_OVERLOADS
358
359 friend struct ConstComponentReference<ArrayType, TupleSize>;
360 friend struct ComponentIterator<ArrayType, TupleSize>;
361
362protected:
363 template <typename AT = ArrayType>
364 typename std::enable_if<std::is_same<AT, vtkDataArray>::value, APIType>::type VTK_ITER_INLINE
365 castOperator() const noexcept
366 {
367 VTK_ITER_ASSUME(this->NumComps.value > 0);
368 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
369 return this->Array->GetComponent(this->TupleId, this->ComponentId);
370 }
371
372 template <typename AT = ArrayType>
373 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value, APIType>::type VTK_ITER_INLINE
374 castOperator() const noexcept
375 {
376 VTK_ITER_ASSUME(this->NumComps.value > 0);
377 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
378 return this->Array->GetTypedComponent(this->TupleId, this->ComponentId);
379 }
380
382 void CopyReference(const ComponentReference& o) noexcept
383 {
384 this->Array = o.Array;
385 this->NumComps = o.NumComps;
386 this->TupleId = o.TupleId;
387 this->ComponentId = o.ComponentId;
388 }
389
390 mutable ArrayType* Array;
394};
395
396//------------------------------------------------------------------------------
397// Const component iterator
398template <typename ArrayType, ComponentIdType TupleSize>
400{
401private:
402 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
403 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
404
406
407public:
408 using iterator_category = std::random_access_iterator_tag;
411 using pointer = void;
413
416 : Array{ nullptr }
417 , TupleId{ 0 }
418 , ComponentId{ 0 }
419 {
420 }
421
424 ArrayType* array, NumCompsType numComps, TupleIdType tupleId, ComponentIdType comp) noexcept
425 : Array(array)
426 , NumComps(numComps)
427 , TupleId(tupleId)
428 , ComponentId(comp)
429 {
430 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
431 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
432 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
433 "Const component iterator at invalid tuple id.");
434 VTK_ITER_ASSERT(comp >= 0 && comp <= this->NumComps.value,
435 "Const component iterator at invalid component id.");
436 }
437
440 : Array{ o.GetArray() }
441 , NumComps{ o.GetNumComps() }
442 , TupleId{ o.GetTupleId() }
443 , ComponentId{ o.GetComponentId() }
444 {
445 }
446
448 ConstComponentIterator(const ConstComponentIterator& o) noexcept = default;
451
453 ConstComponentIterator& operator++() noexcept // prefix
454 {
455 ++this->ComponentId;
456 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
457 "Const component iterator at invalid component id.");
458 return *this;
459 }
460
462 ConstComponentIterator operator++(int) noexcept // postfix
463 {
464 return ConstComponentIterator{ this->Array, this->NumComps, this->TupleId,
465 this->ComponentId++ };
466 }
467
469 ConstComponentIterator& operator--() noexcept // prefix
470 {
471 --this->ComponentId;
472 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
473 "Const component iterator at invalid component id.");
474 return *this;
475 }
476
478 ConstComponentIterator operator--(int) noexcept // postfix
479 {
480 return ConstComponentIterator{ this->Array, this->NumComps, this->TupleId,
481 this->ComponentId-- };
482 }
483
486 {
487 return reference{ this->Array, this->NumComps, this->TupleId, this->ComponentId + i };
488 }
489
491 reference operator*() const noexcept
492 {
493 return reference{ this->Array, this->NumComps, this->TupleId, this->ComponentId };
494 }
495
496#define VTK_TMP_MAKE_OPERATOR(OP) \
497 friend VTK_ITER_INLINE bool operator OP( \
498 const ConstComponentIterator& lhs, const ConstComponentIterator& rhs) noexcept \
499 { \
500 VTK_ITER_ASSERT(lhs.Array == rhs.Array, "Mismatched arrays in iterator comparison."); \
501 VTK_ITER_ASSERT(lhs.TupleId == rhs.TupleId, "Mismatched tuple ids in iterator comparison."); \
502 VTK_ITER_ASSUME(lhs.NumComps.value > 0); \
503 VTK_ITER_ASSUME(lhs.NumComps.value == rhs.NumComps.value); \
504 return lhs.ComponentId OP rhs.ComponentId; \
505 }
506
513
514#undef VTK_TMP_MAKE_OPERATOR
515
518 {
519 this->ComponentId += offset;
520 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
521 "Const component iterator at invalid component id.");
522 return *this;
523 }
524
526 const ConstComponentIterator& it, difference_type offset) noexcept
527 {
528 return ConstComponentIterator{ it.Array, it.NumComps, it.TupleId, it.ComponentId + offset };
529 }
530
532 difference_type offset, const ConstComponentIterator& it) noexcept
533 {
534 return ConstComponentIterator{ it.Array, it.NumComps, it.TupleId, it.ComponentId + offset };
535 }
536
539 {
540 this->ComponentId -= offset;
541 VTK_ITER_ASSERT(this->ComponentId >= 0 && this->ComponentId <= this->NumComps.value,
542 "Const component iterator at invalid component id.");
543 return *this;
544 }
545
547 const ConstComponentIterator& it, difference_type offset) noexcept
548 {
549 return ConstComponentIterator{ it.Array, it.NumComps, it.TupleId, it.ComponentId - offset };
550 }
551
553 const ConstComponentIterator& it1, const ConstComponentIterator& it2) noexcept
554 {
555 VTK_ITER_ASSERT(it1.Array == it2.Array, "Cannot do math with iterators from different arrays.");
556 VTK_ITER_ASSERT(it1.TupleId == it2.TupleId,
557 "Cannot do math with component iterators from different "
558 "tuples.");
559 return it1.ComponentId - it2.ComponentId;
560 }
561
564 {
565 // Different arrays may use different iterator implementations.
566 VTK_ITER_ASSERT(lhs.Array == rhs.Array, "Cannot swap iterators from different arrays.");
567
568 using std::swap;
569 swap(lhs.TupleId, rhs.TupleId);
570 swap(lhs.ComponentId, rhs.ComponentId);
571 }
572
573private:
574 mutable ArrayType* Array;
575 NumCompsType NumComps;
576 TupleIdType TupleId;
577 ComponentIdType ComponentId;
578};
579
580//------------------------------------------------------------------------------
581// Component iterator
582template <typename ArrayType, ComponentIdType TupleSize>
584{
585private:
586 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
587 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
588
590 using APIType = GetAPIType<ArrayType>;
591
592public:
593 using iterator_category = std::random_access_iterator_tag;
594 using value_type = APIType;
598
600 ComponentIterator() noexcept = default;
601
604 ArrayType* array, NumCompsType numComps, TupleIdType tupleId, ComponentIdType comp) noexcept
605 : Ref(array, numComps, tupleId, comp)
606 {
607 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
608 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
609 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
610 "Component iterator at invalid tuple id.");
612 comp >= 0 && comp <= numComps.value, "Component iterator at invalid component id.");
613 }
614
616 ComponentIterator(const ComponentIterator& o) noexcept = default;
617
620 {
621 this->Ref.CopyReference(o.Ref);
622 return *this;
623 }
624
626 ComponentIterator& operator++() noexcept // prefix
627 {
628 ++this->Ref.ComponentId;
629 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
630 "Component iterator at invalid component id.");
631 return *this;
632 }
633
635 ComponentIterator operator++(int) noexcept // postfix
636 {
637 return ComponentIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId,
638 this->Ref.ComponentId++ };
639 }
640
642 ComponentIterator& operator--() noexcept // prefix
643 {
644 --this->Ref.ComponentId;
645 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
646 "Component iterator at invalid component id.");
647 return *this;
648 }
649
651 ComponentIterator operator--(int) noexcept // postfix
652 {
653 return ComponentIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId,
654 this->Ref.ComponentId-- };
655 }
656
659 {
660 return reference{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId,
661 this->Ref.ComponentId + i };
662 }
663
665 reference operator*() const noexcept { return this->Ref; }
666
668 const pointer& operator->() const noexcept { return this->Ref; }
669
670#define VTK_TMP_MAKE_OPERATOR(OP) \
671 friend VTK_ITER_INLINE bool operator OP( \
672 const ComponentIterator& lhs, const ComponentIterator& rhs) noexcept \
673 { \
674 VTK_ITER_ASSERT( \
675 lhs.GetArray() == rhs.GetArray(), "Mismatched arrays in iterator comparison."); \
676 VTK_ITER_ASSERT( \
677 lhs.GetTupleId() == rhs.GetTupleId(), "Mismatched tuple ids in iterator comparison."); \
678 VTK_ITER_ASSUME(lhs.GetNumComps().value > 0); \
679 VTK_ITER_ASSUME(lhs.GetNumComps().value == rhs.GetNumComps().value); \
680 return lhs.GetComponentId() OP rhs.GetComponentId(); \
681 }
682
689
690#undef VTK_TMP_MAKE_OPERATOR
691
694 {
695 this->Ref.ComponentId += offset;
696 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
697 "Component iterator at invalid component id.");
698 return *this;
699 }
700
702 const ComponentIterator& it, difference_type offset) noexcept
703 {
704 return ComponentIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId(),
705 it.GetComponentId() + offset };
706 }
707
709 difference_type offset, const ComponentIterator& it) noexcept
710 {
711 return ComponentIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId(),
712 it.GetComponentId() + offset };
713 }
714
717 {
718 this->Ref.ComponentId -= offset;
719 VTK_ITER_ASSERT(this->Ref.ComponentId >= 0 && this->Ref.ComponentId <= this->Ref.NumComps.value,
720 "Component iterator at invalid component id.");
721 return *this;
722 }
723
725 const ComponentIterator& it, difference_type offset) noexcept
726 {
727 return ComponentIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId(),
728 it.GetComponentId() - offset };
729 }
730
732 const ComponentIterator& it1, const ComponentIterator& it2) noexcept
733 {
734 VTK_ITER_ASSERT(it1.GetArray() == it2.GetArray(),
735 "Cannot do math with component iterators from different "
736 "arrays.");
737 VTK_ITER_ASSERT(it1.GetTupleId() == it2.GetTupleId(),
738 "Cannot do math with component iterators from different "
739 "tuples.");
740 return it1.GetComponentId() - it2.GetComponentId();
741 }
742
744 {
745 // Different arrays may use different iterator implementations.
747 lhs.GetArray() == rhs.GetArray(), "Cannot swap iterators from different arrays.");
748
749 using std::swap;
750 swap(lhs.GetTupleId(), rhs.GetTupleId());
751 swap(lhs.GetComponentId(), rhs.GetComponentId());
752 }
753
754 friend struct ConstComponentIterator<ArrayType, TupleSize>;
755
756protected:
757 // Needed for access from friend functions. We could just store the array
758 // and ID here instead of the ref, but meh.
759 ArrayType* GetArray() const noexcept { return this->Ref.Array; }
760 TupleIdType& GetTupleId() noexcept { return this->Ref.TupleId; }
761 const TupleIdType& GetTupleId() const noexcept { return this->Ref.TupleId; }
762 ComponentIdType& GetComponentId() noexcept { return this->Ref.ComponentId; }
763 const ComponentIdType& GetComponentId() const noexcept { return this->Ref.ComponentId; }
764 NumCompsType& GetNumComps() noexcept { return this->Ref.NumComps; }
765 const NumCompsType& GetNumComps() const noexcept { return this->Ref.NumComps; }
766
768};
769
770//------------------------------------------------------------------------------
771// Const tuple reference
772template <typename ArrayType, ComponentIdType TupleSize>
774{
775private:
776 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
777 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
778
780 using APIType = GetAPIType<ArrayType>;
781
782public:
784 using value_type = APIType;
788
791 : Array(nullptr)
792 , TupleId(0)
793 {
794 }
795
797 ConstTupleReference(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
798 : Array(array)
799 , NumComps(numComps)
800 , TupleId(tupleId)
801 {
802 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
803 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
804 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
805 "Const tuple reference at invalid tuple id.");
806 }
807
810 : Array{ o.Array }
811 , NumComps{ o.NumComps }
812 , TupleId{ o.TupleId }
813 {
814 }
815
817 ConstTupleReference(const ConstTupleReference&) noexcept = default;
820
821 // Allow this type to masquerade as a pointer, so that tupleIiter->foo works.
823 ConstTupleReference* operator->() noexcept { return this; }
825 const ConstTupleReference* operator->() const noexcept { return this; }
826
827 // Caller must ensure that there are size() elements in array.
828 template <typename AT = ArrayType>
829 typename std::enable_if<std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE GetTuple(
830 APIType* tuple) const noexcept
831 {
832 VTK_ITER_ASSUME(this->NumComps.value > 0);
833 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
834 this->Array->GetTuple(this->TupleId, tuple);
835 }
836
837 template <typename AT = ArrayType>
838 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE GetTuple(
839 APIType* tuple) const noexcept
840 {
841 VTK_ITER_ASSUME(this->NumComps.value > 0);
842 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
843 this->Array->GetTypedTuple(this->TupleId, tuple);
844 }
845
846 template <typename VT = APIType, typename AT = ArrayType>
847 typename std::enable_if<!std::is_same<VT, double>::value &&
848 std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
849 GetTuple(double* tuple) const noexcept
850 {
851 VTK_ITER_ASSUME(this->NumComps.value > 0);
852 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
853 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
854 {
855 tuple[comp] = static_cast<double>(this->Array->GetComponent(this->TupleId, comp));
856 }
857 }
858
859 template <typename VT = APIType, typename AT = ArrayType>
860 typename std::enable_if<!std::is_same<VT, double>::value &&
861 !std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
862 GetTuple(double* tuple) const noexcept
863 {
864 VTK_ITER_ASSUME(this->NumComps.value > 0);
865 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
866 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
867 {
868 tuple[comp] = static_cast<double>(this->Array->GetTypedComponent(this->TupleId, comp));
869 }
870 }
871
872 // skips some runtime checks when both sizes are fixed:
873 template <typename OArrayType, ComponentIdType OSize>
875 const TupleReference<OArrayType, OSize>& other) const noexcept
876 {
877 // Check that types are convertible:
878 using OAPIType = GetAPIType<OArrayType>;
879 static_assert(
880 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
881
882 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
883 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
884
885 return std::equal(this->cbegin(), this->cend(), other.cbegin());
886 }
887
888 // Needs a runtime check:
889 template <typename OArrayType, ComponentIdType OSize>
891 const TupleReference<OArrayType, OSize>& other) const noexcept
892 {
893 // Check that types are convertible:
894 using OAPIType = GetAPIType<OArrayType>;
895 static_assert(
896 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
897
899 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
900
901 return std::equal(this->cbegin(), this->cend(), other.cbegin());
902 }
903
904 // skips some runtime checks when both sizes are fixed:
905 template <typename OArrayType, ComponentIdType OSize>
907 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
908 {
909 // Check that types are convertible:
910 using OAPIType = GetAPIType<OArrayType>;
911 static_assert(
912 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
913
914 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
915 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
916
917 return std::equal(this->cbegin(), this->cend(), other.cbegin());
918 }
919
920 // Needs a runtime check:
921 template <typename OArrayType, ComponentIdType OSize>
923 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
924 {
925 // Check that types are convertible:
926 using OAPIType = GetAPIType<OArrayType>;
927 static_assert(
928 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
929
931 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
932
933 return std::equal(this->cbegin(), this->cend(), other.cbegin());
934 }
935
936 template <typename OArrayType, ComponentIdType OSize>
938 {
939 return !(*this == o);
940 }
941
942 template <typename OArrayT, ComponentIdType OSize>
944 {
945 return !(*this == o);
946 }
947
950 {
951 return const_reference{ this->Array, this->NumComps, this->TupleId, i };
952 }
953
955 size_type size() const noexcept { return this->NumComps.value; }
956
958 const_iterator begin() const noexcept { return this->NewConstIterator(0); }
960 const_iterator end() const noexcept { return this->NewConstIterator(this->NumComps.value); }
961
963 const_iterator cbegin() const noexcept { return this->NewConstIterator(0); }
965 const_iterator cend() const noexcept { return this->NewConstIterator(this->NumComps.value); }
966
967 friend struct ConstTupleIterator<ArrayType, TupleSize>;
968
969protected:
970 // Intentionally hidden:
973
976 {
977 VTK_ITER_ASSUME(this->NumComps.value > 0);
978 return const_iterator{ this->Array, this->NumComps, this->TupleId, comp };
979 }
980
982 void CopyReference(const ConstTupleReference& o) noexcept
983 {
984 // Must use same array, other array types may use different implementations.
985 VTK_ITER_ASSERT(this->Array == o.Array, "Cannot copy reference objects between arrays.");
986 this->NumComps = o.NumComps;
987 this->TupleId = o.TupleId;
988 }
989
990 mutable ArrayType* Array;
993};
994
995//------------------------------------------------------------------------------
996// Tuple reference
997template <typename ArrayType, ComponentIdType TupleSize>
999{
1000private:
1001 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1002 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
1003
1005 using APIType = GetAPIType<ArrayType>;
1006
1007public:
1009 using value_type = APIType;
1014
1017 : Array(nullptr)
1018 , TupleId(0)
1019 {
1020 }
1021
1023 TupleReference(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
1024 : Array(array)
1025 , NumComps(numComps)
1026 , TupleId(tupleId)
1027 {
1028 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
1029 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
1030 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
1031 "Tuple reference at invalid tuple id.");
1032 }
1033
1037 TupleReference(TupleReference&&) noexcept = default;
1038
1039 // Allow this type to masquerade as a pointer, so that tupleIiter->foo works.
1041 TupleReference* operator->() noexcept { return this; }
1043 const TupleReference* operator->() const noexcept { return this; }
1044
1045 // Caller must ensure that there are size() elements in array.
1046 template <typename AT = ArrayType>
1047 typename std::enable_if<std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE GetTuple(
1048 APIType* tuple) const noexcept
1049 {
1050 VTK_ITER_ASSUME(this->NumComps.value > 0);
1051 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1052 this->Array->GetTuple(this->TupleId, tuple);
1053 }
1054
1055 template <typename AT = ArrayType>
1056 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE GetTuple(
1057 APIType* tuple) const noexcept
1058 {
1059 this->Array->GetTypedTuple(this->TupleId, tuple);
1060 }
1061
1062 template <typename VT = APIType, typename AT = ArrayType>
1063 typename std::enable_if<!std::is_same<VT, double>::value &&
1064 std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1065 GetTuple(double* tuple) const noexcept
1066 {
1067 VTK_ITER_ASSUME(this->NumComps.value > 0);
1068 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1069 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1070 {
1071 tuple[comp] = static_cast<double>(this->Array->GetComponent(this->TupleId, comp));
1072 }
1073 }
1074
1075 template <typename VT = APIType, typename AT = ArrayType>
1076 typename std::enable_if<!std::is_same<VT, double>::value &&
1077 !std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1078 GetTuple(double* tuple) const noexcept
1079 {
1080 VTK_ITER_ASSUME(this->NumComps.value > 0);
1081 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1082 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1083 {
1084 tuple[comp] = static_cast<double>(this->Array->GetTypedComponent(this->TupleId, comp));
1085 }
1086 }
1087
1088 // Caller must ensure that there are size() elements in array.
1089 template <typename AT = ArrayType>
1090 typename std::enable_if<std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE SetTuple(
1091 const APIType* tuple) noexcept
1092 {
1093 VTK_ITER_ASSUME(this->NumComps.value > 0);
1094 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1095 this->Array->SetTuple(this->TupleId, tuple);
1096 }
1097
1098 template <typename AT = ArrayType>
1099 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE SetTuple(
1100 const APIType* tuple) noexcept
1101 {
1102 VTK_ITER_ASSUME(this->NumComps.value > 0);
1103 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1104 this->Array->SetTypedTuple(this->TupleId, tuple);
1105 }
1106
1107 template <typename VT = APIType, typename AT = ArrayType>
1108 typename std::enable_if<!std::is_same<VT, double>::value &&
1109 std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1110 SetTuple(const double* tuple) noexcept
1111 {
1112 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1113 {
1114 VTK_ITER_ASSUME(this->NumComps.value > 0);
1115 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1116 this->Array->SetComponent(this->TupleId, comp, tuple[comp]);
1117 }
1118 }
1119
1120 template <typename VT = APIType, typename AT = ArrayType>
1121 typename std::enable_if<!std::is_same<VT, double>::value &&
1122 !std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1123 SetTuple(const double* tuple) noexcept
1124 {
1125 VTK_ITER_ASSUME(this->NumComps.value > 0);
1126 VTK_ITER_ASSUME(this->Array->GetNumberOfComponents() == this->NumComps.value);
1127 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1128 {
1129 this->Array->SetTypedComponent(this->TupleId, comp, static_cast<APIType>(tuple[comp]));
1130 }
1131 }
1132
1135 {
1136 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
1137 return *this;
1138 }
1139
1140 // skips some runtime checks when both sizes are fixed:
1141 template <typename OArrayType, ComponentIdType OSize>
1143 const TupleReference<OArrayType, OSize>& other) noexcept
1144 {
1145 // Check that types are convertible:
1146 using OAPIType = GetAPIType<OArrayType>;
1147 static_assert(
1148 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1149
1150 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1151 static_assert(TupleSize == OSize, "Cannot assign tuples with different sizes.");
1152
1153 std::copy_n(other.cbegin(), OSize, this->begin());
1154 return *this;
1155 }
1156
1157 // Needs a runtime check:
1158 template <typename OArrayType, ComponentIdType OSize>
1160 const TupleReference<OArrayType, OSize>& other) noexcept
1161 {
1162 // Check that types are convertible:
1163 using OAPIType = GetAPIType<OArrayType>;
1164 static_assert(
1165 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1166
1168 other.size() == this->NumComps.value, "Cannot assign tuples with different sizes.");
1169
1170 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
1171 return *this;
1172 }
1173
1174 // skips some runtime checks when both sizes are fixed:
1175 template <typename OArrayType, ComponentIdType OSize>
1177 const ConstTupleReference<OArrayType, OSize>& other) noexcept
1178 {
1179 // Check that types are convertible:
1180 using OAPIType = GetAPIType<OArrayType>;
1181 static_assert(
1182 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1183
1184 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1185 static_assert(TupleSize == OSize, "Cannot assign tuples with different sizes.");
1186
1187 std::copy_n(other.cbegin(), OSize, this->begin());
1188 return *this;
1189 }
1190
1191 // Needs a runtime check:
1192 template <typename OArrayType, ComponentIdType OSize>
1194 const ConstTupleReference<OArrayType, OSize>& other) noexcept
1195 {
1196 // Check that types are convertible:
1197 using OAPIType = GetAPIType<OArrayType>;
1198 static_assert(
1199 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when assigning tuples.");
1200
1202 other.size() == this->NumComps.value, "Cannot assign tuples with different sizes.");
1203
1204 std::copy_n(other.cbegin(), this->NumComps.value, this->begin());
1205 return *this;
1206 }
1207
1208 // skips some runtime checks when both sizes are fixed:
1209 template <typename OArrayType, ComponentIdType OSize>
1211 const TupleReference<OArrayType, OSize>& other) const noexcept
1212 {
1213 // Check that types are convertible:
1214 using OAPIType = GetAPIType<OArrayType>;
1215 static_assert(
1216 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1217
1218 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1219 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
1220
1221 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1222 }
1223
1224 // Needs a runtime check:
1225 template <typename OArrayType, ComponentIdType OSize>
1227 const TupleReference<OArrayType, OSize>& other) const noexcept
1228 {
1229 // Check that types are convertible:
1230 using OAPIType = GetAPIType<OArrayType>;
1231 static_assert(
1232 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1233
1235 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
1236
1237 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1238 }
1239
1240 // skips some runtime checks when both sizes are fixed:
1241 template <typename OArrayType, ComponentIdType OSize>
1243 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
1244 {
1245 // Check that types are convertible:
1246 using OAPIType = GetAPIType<OArrayType>;
1247 static_assert(
1248 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1249
1250 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1251 static_assert(TupleSize == OSize, "Cannot compare tuples with different sizes.");
1252
1253 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1254 }
1255
1256 // Needs a runtime check:
1257 template <typename OArrayType, ComponentIdType OSize>
1259 const ConstTupleReference<OArrayType, OSize>& other) const noexcept
1260 {
1261 // Check that types are convertible:
1262 using OAPIType = GetAPIType<OArrayType>;
1263 static_assert(
1264 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when comparing tuples.");
1265
1267 other.size() == this->NumComps.value, "Cannot compare tuples with different sizes.");
1268
1269 return std::equal(this->cbegin(), this->cend(), other.cbegin());
1270 }
1271
1272 template <typename OArrayType, ComponentIdType OSize>
1274 {
1275 return !(*this == o);
1276 }
1277
1278 template <typename OArray, ComponentIdType OSize>
1280 {
1281 return !(*this == o);
1282 }
1283
1284 // skips some runtime checks:
1285 template <typename OArrayType, ComponentIdType OSize>
1287 TupleReference<OArrayType, OSize> other) noexcept
1288 {
1289 // Check that types are convertible:
1290 using OAPIType = GetAPIType<OArrayType>;
1291 static_assert(
1292 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when swapping tuples.");
1293
1294 // SFINAE guarantees that the tuple sizes are not dynamic in this overload:
1295 static_assert(TupleSize == OSize, "Cannot swap tuples with different sizes.");
1296
1297 std::swap_ranges(this->begin(), this->end(), other.begin());
1298 }
1299
1300 // Needs a runtime check:
1301 template <typename OArrayType, ComponentIdType OSize>
1303 TupleReference<OArrayType, OSize> other) noexcept
1304 {
1305 // Check that types are convertible:
1306 using OAPIType = GetAPIType<OArrayType>;
1307 static_assert(
1308 (std::is_convertible<OAPIType, APIType>{}), "Incompatible types when swapping tuples.");
1309
1311 other.size() == this->NumComps.value, "Cannot swap tuples with different sizes.");
1312
1313 std::swap_ranges(this->begin(), this->end(), other.begin());
1314 }
1315
1316 friend VTK_ITER_INLINE void swap(TupleReference a, TupleReference b) noexcept { a.swap(b); }
1317
1318 template <typename OArray, ComponentIdType OSize>
1320 {
1321 a.swap(b);
1322 }
1323
1326 {
1327 return reference{ this->Array, this->NumComps, this->TupleId, i };
1328 }
1329
1332 {
1333 // Let the reference type do the lookup during implicit conversion.
1334 return const_reference{ this->Array, this->NumComps, this->TupleId, i };
1335 }
1336
1338 void fill(const value_type& v) noexcept { std::fill(this->begin(), this->end(), v); }
1339
1341 size_type size() const noexcept { return this->NumComps.value; }
1342
1344 iterator begin() noexcept { return this->NewIterator(0); }
1346 iterator end() noexcept { return this->NewIterator(this->NumComps.value); }
1347
1349 const_iterator begin() const noexcept { return this->NewConstIterator(0); }
1351 const_iterator end() const noexcept { return this->NewConstIterator(this->NumComps.value); }
1352
1354 const_iterator cbegin() const noexcept { return this->NewConstIterator(0); }
1356 const_iterator cend() const noexcept { return this->NewConstIterator(this->NumComps.value); }
1357
1358 friend struct ConstTupleReference<ArrayType, TupleSize>;
1359 friend struct TupleIterator<ArrayType, TupleSize>;
1360
1361protected:
1364 {
1365 VTK_ITER_ASSUME(this->NumComps.value > 0);
1366 return iterator{ this->Array, this->NumComps, this->TupleId, comp };
1367 }
1368
1371 {
1372 VTK_ITER_ASSUME(this->NumComps.value > 0);
1373 return const_iterator{ this->Array, this->NumComps, this->TupleId, comp };
1374 }
1375
1377 void CopyReference(const TupleReference& o) noexcept
1378 {
1379 // Must use same array, other array types may use different implementations.
1380 VTK_ITER_ASSERT(this->Array == o.Array, "Cannot copy reference objects between arrays.");
1381 this->NumComps = o.NumComps;
1382 this->TupleId = o.TupleId;
1383 }
1384
1385 mutable ArrayType* Array;
1388};
1389
1390//------------------------------------------------------------------------------
1391// Const tuple iterator
1392template <typename ArrayType, ComponentIdType TupleSize>
1394{
1395private:
1396 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1397 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
1398
1400
1401public:
1402 using iterator_category = std::random_access_iterator_tag;
1407
1409 ConstTupleIterator() noexcept = default;
1410
1412 ConstTupleIterator(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
1413 : Ref(array, numComps, tupleId)
1414 {
1415 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
1416 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
1417 VTK_ITER_ASSERT(tupleId >= 0 && tupleId <= array->GetNumberOfTuples(),
1418 "Const tuple iterator at invalid tuple id.");
1419 }
1420
1423 : Ref{ o.Ref }
1424 {
1425 }
1426
1428 ConstTupleIterator(const ConstTupleIterator& o) noexcept = default;
1431 {
1432 this->Ref.CopyReference(o.Ref);
1433 return *this;
1434 }
1435
1437 ConstTupleIterator& operator++() noexcept // prefix
1438 {
1439 ++this->Ref.TupleId;
1441 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1442 "Const tuple iterator at invalid component id.");
1443 return *this;
1444 }
1445
1447 ConstTupleIterator operator++(int) noexcept // postfix
1448 {
1449 return ConstTupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId++ };
1450 }
1451
1453 ConstTupleIterator& operator--() noexcept // prefix
1454 {
1455 --this->Ref.TupleId;
1457 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1458 "Const tuple iterator at invalid component id.");
1459 return *this;
1460 }
1461
1463 ConstTupleIterator operator--(int) noexcept // postfix
1464 {
1465 return ConstTupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId-- };
1466 }
1467
1470 {
1471 return reference{ this->GetArray(), this->GetNumComps(), this->GetTupleId() + i };
1472 }
1473
1475 reference operator*() noexcept { return this->Ref; }
1476
1478 pointer operator->() noexcept { return this->Ref; }
1479
1480#define VTK_TMP_MAKE_OPERATOR(OP) \
1481 friend VTK_ITER_INLINE bool operator OP( \
1482 const ConstTupleIterator& lhs, const ConstTupleIterator& rhs) noexcept \
1483 { \
1484 VTK_ITER_ASSERT( \
1485 lhs.GetArray() == rhs.GetArray(), "Cannot compare iterators from different arrays."); \
1486 VTK_ITER_ASSUME(lhs.GetNumComps().value > 0); \
1487 VTK_ITER_ASSUME(lhs.GetNumComps().value == rhs.GetNumComps().value); \
1488 return lhs.GetTupleId() OP rhs.GetTupleId(); \
1489 }
1490
1497
1498#undef VTK_TMP_MAKE_OPERATOR
1499
1502 {
1503 this->Ref.TupleId += offset;
1505 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1506 "Const tuple iterator at invalid component id.");
1507 return *this;
1508 }
1509
1511 const ConstTupleIterator& it, difference_type offset) noexcept
1512 {
1513 return ConstTupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1514 }
1515
1517 difference_type offset, const ConstTupleIterator& it) noexcept
1518 {
1519 return ConstTupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1520 }
1521
1524 {
1525 this->Ref.TupleId -= offset;
1527 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1528 "Const tuple iterator at invalid component id.");
1529 return *this;
1530 }
1531
1533 const ConstTupleIterator& it, difference_type offset) noexcept
1534 {
1535 return ConstTupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() - offset };
1536 }
1537
1539 const ConstTupleIterator& it1, const ConstTupleIterator& it2) noexcept
1540 {
1541 VTK_ITER_ASSERT(it1.GetArray() == it2.GetArray(),
1542 "Cannot do math with tuple iterators from different "
1543 "arrays.");
1544 return it1.GetTupleId() - it2.GetTupleId();
1545 }
1546
1548 {
1549 // Different arrays may use different iterator implementations.
1551 lhs.GetArray() == rhs.GetArray(), "Cannot swap iterators from different arrays.");
1552
1553 using std::swap;
1554 swap(lhs.GetTupleId(), rhs.GetTupleId());
1555 }
1556
1557private:
1559 ArrayType* GetArray() const noexcept { return this->Ref.Array; }
1561 ArrayType*& GetArray() noexcept { return this->Ref.Array; }
1563 NumCompsType GetNumComps() const noexcept { return this->Ref.NumComps; }
1565 NumCompsType& GetNumComps() noexcept { return this->Ref.NumComps; }
1567 TupleIdType GetTupleId() const noexcept { return this->Ref.TupleId; }
1569 TupleIdType& GetTupleId() noexcept { return this->Ref.TupleId; }
1570
1571 ConstTupleReference<ArrayType, TupleSize> Ref;
1572};
1573
1574//------------------------------------------------------------------------------
1575// Tuple iterator
1576template <typename ArrayType, ComponentIdType TupleSize>
1578{
1579private:
1580 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1581 static_assert(IsVtkDataArray<ArrayType>::value, "Invalid array type.");
1582
1584
1585public:
1586 using iterator_category = std::random_access_iterator_tag;
1591
1593 TupleIterator() noexcept = default;
1594
1596 TupleIterator(ArrayType* array, NumCompsType numComps, TupleIdType tupleId) noexcept
1597 : Ref(array, numComps, tupleId)
1598 {
1599 VTK_ITER_ASSERT(array != nullptr, "Invalid array.");
1600 VTK_ITER_ASSERT(numComps.value > 0, "Invalid number of components.");
1602 tupleId >= 0 && tupleId <= array->GetNumberOfTuples(), "Tuple iterator at invalid tuple id.");
1603 }
1604
1606 TupleIterator(const TupleIterator& o) noexcept = default;
1607
1610 {
1611 this->Ref.CopyReference(o.Ref);
1612 return *this;
1613 }
1614
1616 TupleIterator& operator++() noexcept // prefix
1617 {
1618 ++this->Ref.TupleId;
1620 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1621 "Tuple iterator at invalid component id.");
1622 return *this;
1623 }
1624
1626 TupleIterator operator++(int) noexcept // postfix
1627 {
1628 return TupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId++ };
1629 }
1630
1632 TupleIterator& operator--() noexcept // prefix
1633 {
1634 --this->Ref.TupleId;
1636 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1637 "Tuple iterator at invalid component id.");
1638 return *this;
1639 }
1640
1642 TupleIterator operator--(int) noexcept // postfix
1643 {
1644 return TupleIterator{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId-- };
1645 }
1646
1649 {
1650 return reference{ this->Ref.Array, this->Ref.NumComps, this->Ref.TupleId + i };
1651 }
1652
1654 reference operator*() noexcept { return this->Ref; }
1655
1657 pointer& operator->() noexcept { return this->Ref; }
1658
1659#define VTK_TMP_MAKE_OPERATOR(OP) \
1660 friend VTK_ITER_INLINE bool operator OP( \
1661 const TupleIterator& lhs, const TupleIterator& rhs) noexcept \
1662 { \
1663 VTK_ITER_ASSERT( \
1664 lhs.GetArray() == rhs.GetArray(), "Cannot compare iterators from different arrays."); \
1665 VTK_ITER_ASSUME(lhs.GetNumComps().value > 0); \
1666 VTK_ITER_ASSUME(lhs.GetNumComps().value == rhs.GetNumComps().value); \
1667 return lhs.GetTupleId() OP rhs.GetTupleId(); \
1668 }
1669
1676
1677#undef VTK_TMP_MAKE_OPERATOR
1678
1681 {
1682 this->Ref.TupleId += offset;
1684 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1685 "Tuple iterator at invalid component id.");
1686 return *this;
1687 }
1688
1690 const TupleIterator& it, difference_type offset) noexcept
1691 {
1692 return TupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1693 }
1694
1696 difference_type offset, const TupleIterator& it) noexcept
1697 {
1698 return TupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() + offset };
1699 }
1700
1703 {
1704 this->Ref.TupleId -= offset;
1706 this->Ref.TupleId >= 0 && this->Ref.TupleId <= this->Ref.Array->GetNumberOfTuples(),
1707 "Tuple iterator at invalid component id.");
1708 return *this;
1709 }
1710
1712 const TupleIterator& it, difference_type offset) noexcept
1713 {
1714 return TupleIterator{ it.GetArray(), it.GetNumComps(), it.GetTupleId() - offset };
1715 }
1716
1718 const TupleIterator& it1, const TupleIterator& it2) noexcept
1719 {
1720 VTK_ITER_ASSERT(it1.GetArray() == it2.GetArray(),
1721 "Cannot do math with tuple iterators from different "
1722 "arrays.");
1723 return it1.GetTupleId() - it2.GetTupleId();
1724 }
1725
1726 friend VTK_ITER_INLINE void swap(TupleIterator& lhs, TupleIterator& rhs) noexcept
1727 {
1728 // Different arrays may use different iterator implementations.
1730 lhs.GetArray() == rhs.GetArray(), "Cannot swap iterators from different arrays.");
1731
1732 using std::swap;
1733 swap(lhs.GetTupleId(), rhs.GetTupleId());
1734 }
1735
1736 friend struct ConstTupleIterator<ArrayType, TupleSize>;
1737 friend struct ConstTupleReference<ArrayType, TupleSize>;
1738
1739protected:
1741 ArrayType* GetArray() const noexcept { return this->Ref.Array; }
1743 ArrayType*& GetArray() noexcept { return this->Ref.Array; }
1745 NumCompsType GetNumComps() const noexcept { return this->Ref.NumComps; }
1747 NumCompsType& GetNumComps() noexcept { return this->Ref.NumComps; }
1749 TupleIdType GetTupleId() const noexcept { return this->Ref.TupleId; }
1751 TupleIdType& GetTupleId() noexcept { return this->Ref.TupleId; }
1752
1754};
1755
1756//------------------------------------------------------------------------------
1757// Tuple range
1758template <typename ArrayTypeT, ComponentIdType TupleSize>
1760{
1761 using ArrayType = ArrayTypeT;
1764
1765private:
1766 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
1767 static_assert(IsVtkDataArray<ArrayTypeT>::value, "Invalid array type.");
1768
1770
1771public:
1781
1782 // May be DynamicTupleSize, or the actual tuple size.
1783 constexpr static ComponentIdType TupleSizeTag = TupleSize;
1784
1790
1792 TupleRange() noexcept = default;
1793
1795 TupleRange(ArrayType* arr, TupleIdType beginTuple, TupleIdType endTuple) noexcept
1796 : Array(arr)
1797 , NumComps(arr)
1798 , BeginTuple(beginTuple)
1799 , EndTuple(endTuple)
1800 {
1801 assert(this->Array);
1802 assert(beginTuple >= 0 && beginTuple <= endTuple);
1803 assert(endTuple >= 0 && endTuple <= this->Array->GetNumberOfTuples());
1804 }
1805
1807 TupleRange GetSubRange(TupleIdType beginTuple = 0, TupleIdType endTuple = -1) const noexcept
1808 {
1809 const TupleIdType realBegin = this->BeginTuple + beginTuple;
1810 const TupleIdType realEnd = endTuple >= 0 ? this->BeginTuple + endTuple : this->EndTuple;
1811
1812 return TupleRange{ this->Array, realBegin, realEnd };
1813 }
1814
1816 ArrayType* GetArray() const noexcept { return this->Array; }
1818 ComponentIdType GetTupleSize() const noexcept { return this->NumComps.value; }
1820 TupleIdType GetBeginTupleId() const noexcept { return this->BeginTuple; }
1822 TupleIdType GetEndTupleId() const noexcept { return this->EndTuple; }
1823
1825 size_type size() const noexcept { return this->EndTuple - this->BeginTuple; }
1826
1828 iterator begin() noexcept { return this->NewIter(this->BeginTuple); }
1830 iterator end() noexcept { return this->NewIter(this->EndTuple); }
1831
1833 const_iterator begin() const noexcept { return this->NewCIter(this->BeginTuple); }
1835 const_iterator end() const noexcept { return this->NewCIter(this->EndTuple); }
1836
1838 const_iterator cbegin() const noexcept { return this->NewCIter(this->BeginTuple); }
1840 const_iterator cend() const noexcept { return this->NewCIter(this->EndTuple); }
1841
1844 {
1845 return reference{ this->Array, this->NumComps, this->BeginTuple + i };
1846 }
1847
1850 {
1851 return const_reference{ this->Array, this->NumComps, this->BeginTuple + i };
1852 }
1853
1854 template <typename AT = ArrayType>
1855 typename std::enable_if<std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE GetTuple(
1856 size_type i, ValueType* tuple) const noexcept
1857 {
1858 this->Array->GetTuple(this->BeginTuple + i, tuple);
1859 }
1860
1861 template <typename AT = ArrayType>
1862 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE GetTuple(
1863 size_type i, ValueType* tuple) const noexcept
1864 {
1865 this->Array->GetTypedTuple(this->BeginTuple + i, tuple);
1866 }
1867
1868 template <typename VT = ValueType, typename AT = ArrayType>
1869 typename std::enable_if<!std::is_same<VT, double>::value &&
1870 std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1871 GetTuple(size_type i, double* tuple) const noexcept
1872 {
1873 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1874 {
1875 tuple[comp] = static_cast<double>(this->Array->GetComponent(i, comp));
1876 }
1877 }
1878
1879 template <typename VT = ValueType, typename AT = ArrayType>
1880 typename std::enable_if<!std::is_same<VT, double>::value &&
1881 !std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1882 GetTuple(size_type i, double* tuple) const noexcept
1883 {
1884 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1885 {
1886 tuple[comp] = static_cast<double>(this->Array->GetTypedComponent(i, comp));
1887 }
1888 }
1889
1890 template <typename AT = ArrayType>
1891 typename std::enable_if<std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE SetTuple(
1892 size_type i, const ValueType* tuple) noexcept
1893 {
1894 this->Array->SetTuple(this->BeginTuple + i, tuple);
1895 }
1896
1897 template <typename AT = ArrayType>
1898 typename std::enable_if<!std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE SetTuple(
1899 size_type i, const ValueType* tuple) noexcept
1900 {
1901 this->Array->SetTypedTuple(this->BeginTuple + i, tuple);
1902 }
1903
1904 template <typename VT = ValueType, typename AT = ArrayType>
1905 typename std::enable_if<!std::is_same<VT, double>::value &&
1906 std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1907 SetTuple(size_type i, const double* tuple) noexcept
1908 {
1909 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1910 {
1911 this->Array->SetComponent(this->BeginTuple + i, comp, static_cast<ValueType>(tuple[comp]));
1912 }
1913 }
1914
1915 template <typename VT = ValueType, typename AT = ArrayType>
1916 typename std::enable_if<!std::is_same<VT, double>::value &&
1917 !std::is_same<AT, vtkDataArray>::value>::type VTK_ITER_INLINE
1918 SetTuple(size_type i, const double* tuple) noexcept
1919 {
1920 for (ComponentIdType comp = 0; comp < this->NumComps.value; ++comp)
1921 {
1922 this->Array->SetTypedComponent(
1923 this->BeginTuple + i, comp, static_cast<ValueType>(tuple[comp]));
1924 }
1925 }
1926
1927private:
1929 iterator NewIter(TupleIdType t) const { return iterator{ this->Array, this->NumComps, t }; }
1930
1932 const_iterator NewCIter(TupleIdType t) const
1933 {
1934 return const_iterator{ this->Array, this->NumComps, t };
1935 }
1936
1937 mutable ArrayType* Array{ nullptr };
1938 NumCompsType NumComps{};
1939 TupleIdType BeginTuple{ 0 };
1940 TupleIdType EndTuple{ 0 };
1941};
1942
1943// Unimplemented, only used inside decltype in SelectTupleRange:
1944template <typename ArrayType, ComponentIdType TupleSize>
1946
1947VTK_ABI_NAMESPACE_END
1948} // end namespace detail
1949} // end namespace vtk
1950
1952
1953#endif // __VTK_WRAP__
1954
1955// 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
std::enable_if< std::is_same< AT, vtkDataArray >::value, APIType >::type VTK_ITER_INLINE castOperator() const noexcept
std::enable_if< std::is_same< AT, vtkDataArray >::value, ComponentReference >::type VTK_ITER_INLINE operator=(APIType val) noexcept
VTK_ITER_INLINE ComponentReference(const ComponentReference &o) noexcept=default
std::enable_if<!std::is_same< AT, vtkDataArray >::value, ComponentReference >::type VTK_ITER_INLINE operator=(APIType val) noexcept
std::enable_if<!std::is_same< AT, vtkDataArray >::value, APIType >::type VTK_ITER_INLINE castOperator() const noexcept
friend VTK_ITER_INLINE void swap(APIType &lhs, ComponentReference rhs) 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
std::enable_if< std::is_same< AT, vtkDataArray >::value, APIType >::type VTK_ITER_INLINE castOperator() const 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
std::enable_if<!std::is_same< AT, vtkDataArray >::value, APIType >::type VTK_ITER_INLINE castOperator() const noexcept
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
std::enable_if<!std::is_same< VT, double >::value &&std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(double *tuple) const 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
std::enable_if<!std::is_same< VT, double >::value &&!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(double *tuple) const noexcept
std::enable_if< std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(APIType *tuple) 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<!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(APIType *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 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
static constexpr ComponentIdType TupleSizeTag
TupleIterator< ArrayType, TupleSize > TupleIteratorType
VTK_ITER_INLINE TupleRange() noexcept=default
std::enable_if< std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(size_type i, const ValueType *tuple) noexcept
VTK_ITER_INLINE const_reference operator[](size_type i) const noexcept
std::enable_if<!std::is_same< VT, double >::value &&std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(size_type i, const double *tuple) 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
std::enable_if<!std::is_same< VT, double >::value &&!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(size_type i, double *tuple) const noexcept
VTK_ITER_INLINE const_iterator cbegin() const noexcept
std::enable_if<!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(size_type i, const ValueType *tuple) noexcept
VTK_ITER_INLINE iterator end() noexcept
ConstTupleReference< ArrayType, TupleSize > ConstTupleReferenceType
std::enable_if< std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(size_type i, ValueType *tuple) const noexcept
std::enable_if<!std::is_same< VT, double >::value &&std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(size_type i, double *tuple) const noexcept
VTK_ITER_INLINE TupleRange GetSubRange(TupleIdType beginTuple=0, TupleIdType endTuple=-1) const noexcept
std::enable_if<!std::is_same< VT, double >::value &&!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(size_type i, const double *tuple) noexcept
VTK_ITER_INLINE iterator begin() noexcept
std::enable_if<!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(size_type i, ValueType *tuple) const noexcept
VTK_ITER_INLINE const_iterator begin() const noexcept
VTK_ITER_INLINE EnableIfEitherTupleSizeIsDynamic< TupleSize, OSize, TupleReference & > operator=(const TupleReference< OArrayType, OSize > &other) noexcept
std::enable_if<!std::is_same< VT, double >::value &&!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(double *tuple) const 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
std::enable_if<!std::is_same< VT, double >::value &&std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(const double *tuple) 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
std::enable_if<!std::is_same< VT, double >::value &&!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(const double *tuple) noexcept
std::enable_if<!std::is_same< VT, double >::value &&std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(double *tuple) const noexcept
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
std::enable_if<!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(APIType *tuple) 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< std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(const APIType *tuple) noexcept
std::enable_if< std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE GetTuple(APIType *tuple) const noexcept
VTK_ITER_INLINE void fill(const value_type &v) noexcept
std::enable_if<!std::is_same< AT, vtkDataArray >::value >::type VTK_ITER_INLINE SetTuple(const APIType *tuple) 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)