MCPcopy Create free account
hub / github.com/Kitware/VTK / GetSubRange

Function GetSubRange

Common/Core/vtkDataArrayValueRange_Generic.h:856–913  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854// ValueRange
855template <typename ArrayTypeT, ComponentIdType TupleSize, typename ForceValueTypeForVtkDataArray>
856struct ValueRange
857{
858private:
859 static_assert(IsValidTupleSize<TupleSize>::value, "Invalid tuple size.");
860 static_assert(IsVtkDataArray<ArrayTypeT>::value, "Invalid array type.");
861
862 using IdStorageType = IdStorage<TupleSize>;
863 using NumCompsType = GenericTupleSize<TupleSize>;
864
865public:
866 using ArrayType = ArrayTypeT;
867 using ValueType = GetAPIType<ArrayType, ForceValueTypeForVtkDataArray>;
868
869 using IteratorType = ValueIterator<ArrayType, TupleSize, ForceValueTypeForVtkDataArray>;
870 using ConstIteratorType = ConstValueIterator<ArrayType, TupleSize, ForceValueTypeForVtkDataArray>;
871 using ReferenceType = ValueReference<ArrayType, TupleSize, ForceValueTypeForVtkDataArray>;
872 using ConstReferenceType =
873 ConstValueReference<ArrayType, TupleSize, ForceValueTypeForVtkDataArray>;
874
875 // May be DynamicTupleSize, or the actual tuple size.
876 constexpr static ComponentIdType TupleSizeTag = TupleSize;
877
878 // STL-compat
879 using value_type = ValueType;
880 using size_type = ValueIdType;
881 using iterator = IteratorType;
882 using const_iterator = ConstIteratorType;
883 using reference = ReferenceType;
884 using const_reference = ConstReferenceType;
885
886 VTK_ITER_INLINE
887 ValueRange() noexcept = default;
888
889 VTK_ITER_INLINE
890 ValueRange(ArrayType* arr, ValueIdType beginValue, ValueIdType endValue) noexcept
891 : Array(arr)
892 , NumComps(arr)
893 , BeginValue(beginValue, this->NumComps)
894 , EndValue(endValue, this->NumComps)
895 {
896 assert(this->Array);
897 assert(beginValue >= 0 && beginValue <= endValue);
898 assert(endValue >= 0 && endValue <= this->Array->GetNumberOfValues());
899 if constexpr (IsStaticTupleSize<TupleSize>::value)
900 {
901 assert(arr->GetNumberOfComponents() == TupleSize);
902 }
903 }
904
905 VTK_ITER_INLINE
906 ValueRange GetSubRange(ValueIdType beginValue = 0, ValueIdType endValue = -1) const noexcept
907 {
908 const ValueIdType realBegin = this->BeginValue.GetValueId() + beginValue;
909 const ValueIdType realEnd =
910 endValue >= 0 ? this->BeginValue.GetValueId() + endValue : this->EndValue.GetValueId();
911
912 return ValueRange{ this->Array, realBegin, realEnd };
913 }

Callers

nothing calls this directly

Calls 1

GetValueIdMethod · 0.80

Tested by

no test coverage detected