//============================================================================ // 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_CellSetExtrude_h #define vtk_m_cont_CellSetExtrude_h #include #include #include #include #include #include #include #include namespace vtkm { namespace cont { namespace detail { template struct CellSetExtrudeConnectivityChooser; template <> struct CellSetExtrudeConnectivityChooser { using ExecConnectivityType = vtkm::exec::ConnectivityExtrude; }; template <> struct CellSetExtrudeConnectivityChooser { using ExecConnectivityType = vtkm::exec::ReverseConnectivityExtrude; }; } // namespace detail class VTKM_CONT_EXPORT CellSetExtrude : public CellSet { public: VTKM_CONT CellSetExtrude(); VTKM_CONT CellSetExtrude(const vtkm::cont::ArrayHandle& conn, vtkm::Int32 numberOfPointsPerPlane, vtkm::Int32 numberOfPlanes, const vtkm::cont::ArrayHandle& nextNode, bool periodic); VTKM_CONT CellSetExtrude(const CellSetExtrude& src); VTKM_CONT CellSetExtrude(CellSetExtrude&& src) noexcept; VTKM_CONT CellSetExtrude& operator=(const CellSetExtrude& src); VTKM_CONT CellSetExtrude& operator=(CellSetExtrude&& src) noexcept; virtual ~CellSetExtrude() override; vtkm::Int32 GetNumberOfPlanes() const; vtkm::Id GetNumberOfCells() const override; vtkm::Id GetNumberOfPoints() const override; vtkm::Id GetNumberOfFaces() const override; vtkm::Id GetNumberOfEdges() const override; VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const; VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const; vtkm::UInt8 GetCellShape(vtkm::Id id) const override; vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id id) const override; void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override; std::shared_ptr NewInstance() const override; void DeepCopy(const CellSet* src) override; void PrintSummary(std::ostream& out) const override; void ReleaseResourcesExecution() override; const vtkm::cont::ArrayHandle& GetConnectivityArray() const { return this->Connectivity; } vtkm::Int32 GetNumberOfPointsPerPlane() const { return this->NumberOfPointsPerPlane; } const vtkm::cont::ArrayHandle& GetNextNodeArray() const { return this->NextNode; } bool GetIsPeriodic() const { return this->IsPeriodic; } template VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec& ids) const; VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle& ids) const; template using ExecConnectivityType = typename detail::CellSetExtrudeConnectivityChooser::ExecConnectivityType; vtkm::exec::ConnectivityExtrude PrepareForInput(vtkm::cont::DeviceAdapterId, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, vtkm::cont::Token&) const; vtkm::exec::ReverseConnectivityExtrude PrepareForInput(vtkm::cont::DeviceAdapterId, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, vtkm::cont::Token&) const; private: void BuildReverseConnectivity(); bool IsPeriodic; vtkm::Int32 NumberOfPointsPerPlane; vtkm::Int32 NumberOfCellsPerPlane; vtkm::Int32 NumberOfPlanes; vtkm::cont::ArrayHandle Connectivity; vtkm::cont::ArrayHandle NextNode; bool ReverseConnectivityBuilt; vtkm::cont::ArrayHandle RConnectivity; vtkm::cont::ArrayHandle ROffsets; vtkm::cont::ArrayHandle RCounts; vtkm::cont::ArrayHandle PrevNode; }; template CellSetExtrude make_CellSetExtrude(const vtkm::cont::ArrayHandle& conn, const vtkm::cont::ArrayHandleXGCCoordinates& coords, const vtkm::cont::ArrayHandle& nextNode, bool periodic = true) { return CellSetExtrude{ conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic }; } template CellSetExtrude make_CellSetExtrude(const std::vector& conn, const vtkm::cont::ArrayHandleXGCCoordinates& coords, const std::vector& nextNode, bool periodic = true) { return CellSetExtrude{ vtkm::cont::make_ArrayHandle(conn, vtkm::CopyFlag::On), static_cast(coords.GetNumberOfPointsPerPlane()), static_cast(coords.GetNumberOfPlanes()), vtkm::cont::make_ArrayHandle(nextNode, vtkm::CopyFlag::On), periodic }; } template CellSetExtrude make_CellSetExtrude(std::vector&& conn, const vtkm::cont::ArrayHandleXGCCoordinates& coords, std::vector&& nextNode, bool periodic = true) { return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)), static_cast(coords.GetNumberOfPointsPerPlane()), static_cast(coords.GetNumberOfPlanes()), vtkm::cont::make_ArrayHandleMove(std::move(nextNode)), periodic }; } } } // 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 = "CS_Extrude"; return name; } }; } } // vtkm::cont namespace mangled_diy_namespace { template <> struct Serialization { private: using Type = vtkm::cont::CellSetExtrude; public: static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs) { vtkmdiy::save(bb, cs.GetNumberOfPointsPerPlane()); vtkmdiy::save(bb, cs.GetNumberOfPlanes()); vtkmdiy::save(bb, cs.GetIsPeriodic()); vtkmdiy::save(bb, cs.GetConnectivityArray()); vtkmdiy::save(bb, cs.GetNextNodeArray()); } static VTKM_CONT void load(BinaryBuffer& bb, Type& cs) { vtkm::Int32 numberOfPointsPerPlane; vtkm::Int32 numberOfPlanes; bool isPeriodic; vtkm::cont::ArrayHandle conn; vtkm::cont::ArrayHandle nextNode; vtkmdiy::load(bb, numberOfPointsPerPlane); vtkmdiy::load(bb, numberOfPlanes); vtkmdiy::load(bb, isPeriodic); vtkmdiy::load(bb, conn); vtkmdiy::load(bb, nextNode); cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic }; } }; } // diy /// @endcond SERIALIZATION #endif // vtk_m_cont_CellSetExtrude.h