11 #ifndef vtk_m_cont_ArrayHandleReverse_h
12 #define vtk_m_cont_ArrayHandleReverse_h
27 template <
typename PortalType>
30 using Writable = vtkm::internal::PortalSupportsSets<PortalType>;
33 using ValueType =
typename PortalType::ValueType;
42 ArrayPortalReverse(
const PortalType& p)
47 template <
typename OtherPortal>
48 VTKM_EXEC_CONT ArrayPortalReverse(
const ArrayPortalReverse<OtherPortal>& src)
49 : portal(src.GetPortal())
54 vtkm::Id GetNumberOfValues()
const {
return this->portal.GetNumberOfValues(); }
59 return this->portal.Get(portal.GetNumberOfValues() - index - 1);
62 template <
typename Writable_ = Writable,
63 typename =
typename std::enable_if<Writable_::value>::type>
66 this->portal.Set(portal.GetNumberOfValues() - index - 1, value);
74 template <
typename StorageTag>
82 template <
typename T,
typename ST>
85 using SourceStorage = Storage<T, ST>;
89 using ReadPortalType = ArrayPortalReverse<typename ArrayHandleType::ReadPortalType>;
90 using WritePortalType = ArrayPortalReverse<typename ArrayHandleType::WritePortalType>;
92 VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> CreateBuffers()
94 return SourceStorage::CreateBuffers();
98 const std::vector<vtkm::cont::internal::Buffer>& buffers,
102 SourceStorage::ResizeBuffers(numValues, buffers, preserve, token);
106 const std::vector<vtkm::cont::internal::Buffer>& buffers)
108 return SourceStorage::GetNumberOfValues(buffers);
111 VTKM_CONT static void Fill(
const std::vector<vtkm::cont::internal::Buffer>& buffers,
117 vtkm::Id numValues = GetNumberOfValues(buffers);
118 SourceStorage::Fill(buffers, fillValue, numValues - endIndex, numValues - startIndex, token);
121 VTKM_CONT static ReadPortalType CreateReadPortal(
122 const std::vector<vtkm::cont::internal::Buffer>& buffers,
126 return ReadPortalType(SourceStorage::CreateReadPortal(buffers, device, token));
129 VTKM_CONT static WritePortalType CreateWritePortal(
130 const std::vector<vtkm::cont::internal::Buffer>& buffers,
134 return WritePortalType(SourceStorage::CreateWritePortal(buffers, device, token));
146 template <
typename ArrayHandleType>
149 StorageTagReverse<typename ArrayHandleType::StorageTag>>
175 template <
typename HandleType>
186 template <
typename StorageTag>
188 : vtkm::cont::internal::ArrayExtractComponentImpl<StorageTag>
190 template <
typename T>
191 using StrideArrayType =
194 template <
typename T>
195 StrideArrayType<T> operator()(
201 StrideArrayType<T> subArray =
202 ArrayExtractComponentImpl<StorageTag>{}(srcArray.GetSourceArray(), componentIndex, allowCopy);
204 return StrideArrayType<T>(subArray.GetBasicArray(),
205 srcArray.GetNumberOfValues(),
206 -subArray.GetStride(),
207 subArray.GetOffset() +
208 (subArray.GetStride() * (subArray.GetNumberOfValues() - 1)),
209 subArray.GetModulo(),
210 subArray.GetDivisor());
227 template <
typename AH>
228 struct SerializableTypeString<
vtkm::cont::ArrayHandleReverse<AH>>
237 template <
typename T,
typename ST>
238 struct SerializableTypeString<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagReverse<ST>>>
239 : SerializableTypeString<vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<T, ST>>>
248 template <
typename AH>
249 struct Serialization<
vtkm::cont::ArrayHandleReverse<AH>>
256 static VTKM_CONT void save(BinaryBuffer& bb,
const Type& obj)
258 vtkmdiy::save(bb, obj.GetSourceArray());
269 template <
typename T,
typename ST>
270 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagReverse<ST>>>
271 : Serialization<vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<T, ST>>>
278 #endif // vtk_m_cont_ArrayHandleReverse_h