17 #ifndef vtkmlib_Storage_h 18 #define vtkmlib_Storage_h 22 #include <vtkm/cont/Storage.h> 28 template <
typename ValueType_>
29 class VTKM_ALWAYS_EXPORT Storage<ValueType_,
tovtkm::vtkAOSArrayContainerTag>
44 DeallocateOnRelease(false),
45 UserProvidedMemory(false)
52 NumberOfValues(array->GetNumberOfTuples()),
53 AllocatedSize(array->GetNumberOfTuples() * NUM_COMPONENTS),
54 DeallocateOnRelease(false),
55 UserProvidedMemory(true)
61 this->ReleaseResources();
65 operator=(
const Storage<ValueType, tovtkm::vtkAOSArrayContainerTag>& src)
67 if (src.DeallocateOnRelease)
69 throw vtkm::cont::ErrorBadValue(
70 "Attempted to copy a storage array that needs deallocation. " 71 "This is disallowed to prevent complications with deallocation.");
74 this->ReleaseResources();
75 this->Array = src.Array;
76 this->NumberOfValues = src.NumberOfValues;
77 this->AllocatedSize = src.AllocatedSize;
78 this->DeallocateOnRelease = src.DeallocateOnRelease;
79 this->UserProvidedMemory = src.UserProvidedMemory;
84 void ReleaseResources();
86 void Allocate(vtkm::Id numberOfValues);
90 return this->NumberOfValues;
95 if (numberOfValues > this->GetNumberOfValues())
97 throw vtkm::cont::ErrorBadValue(
98 "Shrink method cannot be used to grow array.");
101 this->NumberOfValues = numberOfValues;
104 PortalType GetPortal();
106 PortalConstType GetPortalConst()
const;
115 vtkm::Id NumberOfValues;
116 vtkm::Id AllocatedSize;
117 bool DeallocateOnRelease;
118 bool UserProvidedMemory;
121 template <
typename ValueType_>
122 class VTKM_ALWAYS_EXPORT Storage<ValueType_,
tovtkm::vtkSOAArrayContainerTag>
138 DeallocateOnRelease(false),
139 UserProvidedMemory(false)
145 NumberOfValues(array->GetNumberOfTuples()),
146 AllocatedSize(array->GetNumberOfTuples() * NUM_COMPONENTS),
147 DeallocateOnRelease(false),
148 UserProvidedMemory(true)
154 this->ReleaseResources();
160 if (src.DeallocateOnRelease)
162 throw vtkm::cont::ErrorBadValue(
163 "Attempted to copy a storage array that needs deallocation. " 164 "This is disallowed to prevent complications with deallocation.");
167 this->ReleaseResources();
168 this->Array = src.Array;
169 this->NumberOfValues = src.NumberOfValues;
170 this->AllocatedSize = src.AllocatedSize;
171 this->DeallocateOnRelease = src.DeallocateOnRelease;
172 this->UserProvidedMemory = src.UserProvidedMemory;
177 void ReleaseResources();
179 void Allocate(vtkm::Id numberOfValues);
183 return this->NumberOfValues;
188 if (numberOfValues > this->GetNumberOfValues())
190 throw vtkm::cont::ErrorBadValue(
191 "Shrink method cannot be used to grow array.");
194 this->NumberOfValues = numberOfValues;
197 PortalType GetPortal();
199 PortalConstType GetPortalConst()
const;
208 vtkm::Id NumberOfValues;
209 vtkm::Id AllocatedSize;
210 bool DeallocateOnRelease;
211 bool UserProvidedMemory;
214 template <
typename ValueType_>
215 class VTKM_ALWAYS_EXPORT Storage<ValueType_,
tovtkm::vtkCellArrayContainerTag>
228 DeallocateOnRelease(false),
229 UserProvidedMemory(false)
235 NumberOfValues(array->GetNumberOfConnectivityEntries()),
236 AllocatedSize(array->GetSize()),
237 DeallocateOnRelease(false),
238 UserProvidedMemory(true)
244 this->ReleaseResources();
250 if (src.DeallocateOnRelease)
252 throw vtkm::cont::ErrorBadValue(
253 "Attempted to copy a storage array that needs deallocation. " 254 "This is disallowed to prevent complications with deallocation.");
257 this->ReleaseResources();
258 this->Array = src.Array;
259 this->NumberOfValues = src.NumberOfValues;
260 this->AllocatedSize = src.AllocatedSize;
261 this->DeallocateOnRelease = src.DeallocateOnRelease;
262 this->UserProvidedMemory = src.UserProvidedMemory;
267 void ReleaseResources();
269 void Allocate(vtkm::Id numberOfValues);
273 return this->NumberOfValues;
278 if (numberOfValues > this->GetNumberOfValues())
280 throw vtkm::cont::ErrorBadValue(
281 "Shrink method cannot be used to grow array.");
284 this->NumberOfValues = numberOfValues;
287 PortalType GetPortal();
289 PortalConstType GetPortalConst()
const;
298 vtkm::Id NumberOfValues;
299 vtkm::Id AllocatedSize;
300 bool DeallocateOnRelease;
301 bool UserProvidedMemory;
307 #define VTKM_TEMPLATE_EXPORT_Storage(T, S) \ 308 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<const T, S>; \ 309 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<T, S>; \ 310 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \ 311 Storage<const vtkm::Vec<T, 2>, S>; \ 312 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \ 313 Storage<vtkm::Vec<T, 2>, S>; \ 314 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \ 315 Storage<const vtkm::Vec<T, 3>, S>; \ 316 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \ 317 Storage<vtkm::Vec<T, 3>, S>; \ 318 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \ 319 Storage<const vtkm::Vec<T, 4>, S>; \ 320 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<vtkm::Vec<T, 4>, S>; 322 #define VTKM_TEMPLATE_IMPORT_Storage(T, S) \ 323 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<const T, S>; \ 324 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<T, S>; \ 325 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<const vtkm::Vec<T, 2>, S>; \ 326 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<vtkm::Vec<T, 2>, S>; \ 327 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<const vtkm::Vec<T, 3>, S>; \ 328 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<vtkm::Vec<T, 3>, S>; \ 329 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<const vtkm::Vec<T, 4>, S>; \ 330 template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT Storage<vtkm::Vec<T, 4>, S>; 332 #ifndef vtkmlib_Storage_cxx 361 #if VTKM_SIZE_LONG_LONG == 8 369 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
370 Storage<vtkIdType, tovtkm::vtkCellArrayContainerTag>;
375 #endif // defined vtkmlib_Storage_cxx 377 #include "Storage.hxx" 378 #endif // vtkmlib_Storage_h Struct-Of-Arrays implementation of vtkGenericDataArray.
VTKM_TEMPLATE_EXPORT_Storage(char, tovtkm::vtkAOSArrayContainerTag)
ArrayType * VTKArray() const
vtkm::Id GetNumberOfValues() const
tovtkm::vtkArrayPortal< ValueType, ArrayType > PortalType
Storage(vtkCellArray *array)
vtkAOSDataArrayTemplate< ComponentType > ArrayType
void Shrink(vtkm::Id numberOfValues)
tovtkm::vtkArrayPortal< ValueType, ArrayType > PortalType
vtkAOSDataArrayTemplate< ValueType_ > ArrayType
tovtkm::vtkArrayPortal< const ValueType, ArrayType > PortalConstType
Storage & operator=(const Storage< ValueType_, tovtkm::vtkCellArrayContainerTag > &src)
tovtkm::vtkArrayPortal< const ValueType, ArrayType > PortalConstType
void Shrink(vtkm::Id numberOfValues)
vtkCellArray * VTKArray() const
Storage & operator=(const Storage< ValueType, tovtkm::vtkAOSArrayContainerTag > &src)
vtkSOADataArrayTemplate< ComponentType > ArrayType
Array-Of-Structs implementation of vtkGenericDataArray.
void Shrink(vtkm::Id numberOfValues)
tovtkm::vtkArrayPortal< const ValueType, ArrayType > PortalConstType
Storage(vtkSOADataArrayTemplate< ComponentType > *array)
vtkm::Id GetNumberOfValues() const
object to represent cell connectivity
ArrayType * VTKArray() const
vtkm::Id GetNumberOfValues() const
Storage & operator=(const Storage< ValueType_, tovtkm::vtkSOAArrayContainerTag > &src)
typename std::remove_const< T >::type ComponentType
tovtkm::vtkArrayPortal< ValueType, ArrayType > PortalType
Storage(vtkAOSDataArrayTemplate< ComponentType > *array)