//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #ifndef vtk_m_cont_ArrayHandleExtrudeCoords_h #define vtk_m_cont_ArrayHandleExtrudeCoords_h #include #include namespace vtkm { namespace cont { template class VTKM_ALWAYS_EXPORT ArrayHandleExtrudeCoords : public vtkm::cont::ArrayHandle, internal::StorageTagExtrude> { using StorageType = vtkm::cont::internal::Storage, internal::StorageTagExtrude>; public: VTKM_ARRAY_HANDLE_SUBCLASS( ArrayHandleExtrudeCoords, (ArrayHandleExtrudeCoords), (vtkm::cont::ArrayHandle, internal::StorageTagExtrude>)); ArrayHandleExtrudeCoords(const StorageType& storage) : Superclass(storage) { } vtkm::Id GetNumberOfPointsPerPlane() const { return (this->GetStorage().GetLength() / 2); } vtkm::Int32 GetNumberOfPlanes() const { return this->GetStorage().GetNumberOfPlanes(); } bool GetUseCylindrical() const { return this->GetStorage().GetUseCylindrical(); } const vtkm::cont::ArrayHandle& GetArray() const { return this->GetStorage().Array; } }; template vtkm::cont::ArrayHandleExtrudeCoords make_ArrayHandleExtrudeCoords( const vtkm::cont::ArrayHandle arrHandle, vtkm::Int32 numberOfPlanes, bool cylindrical) { using StorageType = vtkm::cont::internal::Storage, internal::StorageTagExtrude>; auto storage = StorageType(arrHandle, numberOfPlanes, cylindrical); return ArrayHandleExtrudeCoords(storage); } template vtkm::cont::ArrayHandleExtrudeCoords make_ArrayHandleExtrudeCoords( const T* array, vtkm::Id length, vtkm::Int32 numberOfPlanes, bool cylindrical, vtkm::CopyFlag copy = vtkm::CopyFlag::Off) { using StorageType = vtkm::cont::internal::Storage, internal::StorageTagExtrude>; if (copy == vtkm::CopyFlag::Off) { return ArrayHandleExtrudeCoords(StorageType(array, length, numberOfPlanes, cylindrical)); } else { auto storage = StorageType( vtkm::cont::make_ArrayHandle(array, length, vtkm::CopyFlag::On), numberOfPlanes, cylindrical); return ArrayHandleExtrudeCoords(storage); } } template vtkm::cont::ArrayHandleExtrudeCoords make_ArrayHandleExtrudeCoords( const std::vector& array, vtkm::Int32 numberOfPlanes, bool cylindrical, vtkm::CopyFlag copy = vtkm::CopyFlag::Off) { if (!array.empty()) { return make_ArrayHandleExtrudeCoords( &array.front(), static_cast(array.size()), numberOfPlanes, cylindrical, copy); } else { // Vector empty. Just return an empty array handle. return ArrayHandleExtrudeCoords(); } } } } // end namespace vtkm::cont //============================================================================= // Specializations of serialization related classes /// @cond SERIALIZATION namespace vtkm { namespace cont { template struct SerializableTypeString> { static VTKM_CONT const std::string& Get() { static std::string name = "AH_ExtrudeCoords<" + SerializableTypeString::Get() + ">"; return name; } }; } } // vtkm::cont namespace mangled_diy_namespace { template struct Serialization> { private: using Type = vtkm::cont::ArrayHandleExtrudeCoords; public: static VTKM_CONT void save(BinaryBuffer& bb, const Type& ah) { vtkmdiy::save(bb, ah.GetNumberOfPlanes()); vtkmdiy::save(bb, ah.GetUseCylindrical()); vtkmdiy::save(bb, ah.GetArray()); } static VTKM_CONT void load(BinaryBuffer& bb, Type& ah) { vtkm::Int32 numberOfPlanes; bool isCylindrical; vtkm::cont::ArrayHandle array; vtkmdiy::load(bb, numberOfPlanes); vtkmdiy::load(bb, isCylindrical); vtkmdiy::load(bb, array); ah = vtkm::cont::make_ArrayHandleExtrudeCoords(array, numberOfPlanes, isCylindrical); } }; } // diy /// @endcond SERIALIZATION #endif