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::GetNumberOfComponentsFlat(buffers);
112 const std::vector<vtkm::cont::internal::Buffer>& buffers)
114 return SourceStorage::GetNumberOfValues(buffers);
117 VTKM_CONT static void Fill(
const std::vector<vtkm::cont::internal::Buffer>& buffers,
123 vtkm::Id numValues = GetNumberOfValues(buffers);
124 SourceStorage::Fill(buffers, fillValue, numValues - endIndex, numValues - startIndex, token);
127 VTKM_CONT static ReadPortalType CreateReadPortal(
128 const std::vector<vtkm::cont::internal::Buffer>& buffers,
132 return ReadPortalType(SourceStorage::CreateReadPortal(buffers, device, token));
135 VTKM_CONT static WritePortalType CreateWritePortal(
136 const std::vector<vtkm::cont::internal::Buffer>& buffers,
140 return WritePortalType(SourceStorage::CreateWritePortal(buffers, device, token));
152 template <
typename ArrayHandleType>
155 StorageTagReverse<typename ArrayHandleType::StorageTag>>
180 template <
typename HandleType>
191 template <
typename StorageTag>
193 : vtkm::cont::internal::ArrayExtractComponentImpl<StorageTag>
195 template <
typename T>
196 using StrideArrayType =
199 template <
typename T>
200 StrideArrayType<T> operator()(
206 StrideArrayType<T> subArray =
207 ArrayExtractComponentImpl<StorageTag>{}(srcArray.GetSourceArray(), componentIndex, allowCopy);
209 return StrideArrayType<T>(subArray.GetBasicArray(),
210 srcArray.GetNumberOfValues(),
211 -subArray.GetStride(),
212 subArray.GetOffset() +
213 (subArray.GetStride() * (subArray.GetNumberOfValues() - 1)),
214 subArray.GetModulo(),
215 subArray.GetDivisor());
232 template <
typename AH>
233 struct SerializableTypeString<
vtkm::cont::ArrayHandleReverse<AH>>
242 template <
typename T,
typename ST>
243 struct SerializableTypeString<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagReverse<ST>>>
244 : SerializableTypeString<vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<T, ST>>>
253 template <
typename AH>
254 struct Serialization<
vtkm::cont::ArrayHandleReverse<AH>>
261 static VTKM_CONT void save(BinaryBuffer& bb,
const Type& obj)
263 vtkmdiy::save(bb, obj.GetSourceArray());
274 template <
typename T,
typename ST>
275 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagReverse<ST>>>
276 : Serialization<vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<T, ST>>>
283 #endif // vtk_m_cont_ArrayHandleReverse_h