/*========================================================================= Library: iMSTK Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, & Imaging in Medicine, Rensselaer Polytechnic Institute. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =========================================================================*/ #ifndef imstkVTKMeshIO_h #define imstkVTKMeshIO_h #include #include "vtkUnstructuredGrid.h" #include "vtkPolyData.h" #include "vtkPoints.h" #include "vtkCellArray.h" #include "vtkPointData.h" #include "imstkMeshIO.h" #include "imstkSurfaceMesh.h" #include "imstkTetrahedralMesh.h" #include "imstkHexahedralMesh.h" namespace imstk { /// /// \class VTKMeshIO /// /// \brief /// class VTKMeshIO { public: /// /// \brief Default constructor /// VTKMeshIO() = default; /// /// \brief Default destructor /// ~VTKMeshIO() = default; /// /// \brief /// static std::shared_ptr read(const std::string& filePath, MeshFileType meshType); /// /// \brief Writes the given mesh to the specified file path. /// static bool write(const std::shared_ptr imstkMesh, const std::string& filePath, const MeshFileType meshType); protected: /// /// \brief /// template static std::shared_ptr readVtkGenericFormatData(const std::string& filePath); /// /// \brief /// template static std::shared_ptr readVtkPolyData(const std::string& filePath); /// /// \brief Writes the given surfase mesh to given file path using the provided writer type /// template static bool writeVtkPolyData(const std::shared_ptr imstkMesh, const std::string& filePath); /// /// \brief Writes the given volumetric mesh to given file path /// static bool writeVtkUnstructuredGrid(const std::shared_ptr imstkMesh, const std::string& filePath); /// /// \brief /// template static std::shared_ptr readVtkUnstructuredGrid(const std::string& filePath); /// /// \brief /// static std::shared_ptr convertVtkPolyDataToSurfaceMesh(vtkPolyData* vtkMesh); /// /// \brief Converts imstk surface mesh into a vtk polydata suitable for writing to file /// static vtkPolyData* convertSurfaceMeshToVtkPolyData(std::shared_ptr imstkMesh); /// /// \brief Converts imstk tetrahedral mesh into a vtk unstructured grid suitable for writing to file /// static vtkUnstructuredGrid* convertTetrahedralMeshToVtkUnstructuredGrid(std::shared_ptr imstkMesh); /// /// \brief Converts imstk hexahedral mesh into a vtk unstructured grid suitable for writing to file /// static vtkUnstructuredGrid * convertHexahedralMeshToVtkUnstructuredGrid(std::shared_ptr imstkMesh); /// /// \brief /// static std::shared_ptr convertVtkUnstructuredGridToVolumetricMesh(vtkUnstructuredGrid* vtkMesh); /// /// \brief /// static void copyVerticesFromVtk(vtkPoints* points, StdVectorOfVec3d& vertices); /// /// \brief Copies vertices from imstk structure to VTK one /// static void copyVerticesToVtk(const StdVectorOfVec3d& vertices, vtkPoints* points); /// /// \brief Copies cells of the given dimension from imstk structure to VTK one /// template static void copyCellsToVtk(const std::vector>& cells, vtkCellArray* vtkCells); /// /// \brief /// template static void copyCellsFromVtk(vtkCellArray* vtkCells, std::vector>& cells); /// /// \brief /// static void copyPointData(vtkPointData* pointData, std::map& dataMap); }; } // imstk #endif // ifndef imstkVTKMeshIO_h