diff --git a/vtkm/cont/ArrayHandle.h b/vtkm/cont/ArrayHandle.h index 4d1336e4c..86194c334 100644 --- a/vtkm/cont/ArrayHandle.h +++ b/vtkm/cont/ArrayHandle.h @@ -232,10 +232,10 @@ template< class ArrayHandle : public internal::ArrayHandleBase { private: - typedef vtkm::cont::internal::Storage StorageType; typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase ExecutionManagerType; public: + typedef vtkm::cont::internal::Storage StorageType; typedef T ValueType; typedef StorageTag_ StorageTag; typedef typename StorageType::PortalType PortalControl; @@ -302,6 +302,38 @@ public: return *this; } + /// Get the storage. + /// + VTKM_CONT_EXPORT StorageType& GetStorage() + { + this->SyncControlArray(); + if (this->Internals->ControlArrayValid) + { + return this->Internals->ControlArray; + } + else + { + throw vtkm::cont::ErrorControlInternal( + "ArrayHandle::SyncControlArray did not make control array valid."); + } + } + + /// Get the storage. + /// + VTKM_CONT_EXPORT const StorageType& GetStorage() const + { + this->SyncControlArray(); + if (this->Internals->ControlArrayValid) + { + return this->Internals->ControlArray; + } + else + { + throw vtkm::cont::ErrorControlInternal( + "ArrayHandle::SyncControlArray did not make control array valid."); + } + } + /// Get the array portal of the control array. /// VTKM_CONT_EXPORT PortalControl GetPortalControl() diff --git a/vtkm/cont/StorageBasic.h b/vtkm/cont/StorageBasic.h index 74265e266..c06cf3e42 100755 --- a/vtkm/cont/StorageBasic.h +++ b/vtkm/cont/StorageBasic.h @@ -322,6 +322,23 @@ public: return PortalConstType(this->Array, this->Array + this->NumberOfValues); } + /// \brief Get a pointer to the underlying data structure. + /// + /// This method returns the pointer to the array held by this array. The + /// memory associated with this array still belongs to the Storage (i.e. + /// Storage will eventually deallocate the array). + /// + VTKM_CONT_EXPORT + ValueType *GetArray() + { + return this->Array; + } + VTKM_CONT_EXPORT + const ValueType *GetArray() const + { + return this->Array; + } + /// \brief Take the reference away from this object. /// /// This method returns the pointer to the array held by this array. It then