7 #include "imstkCleanMesh.h" 8 #include "imstkLineMesh.h" 9 #include "imstkSurfaceMesh.h" 10 #include "imstkLogger.h" 11 #include "imstkGeometryUtilities.h" 13 #include <vtkCleanPolyData.h> 17 CleanMesh::CleanMesh()
20 setRequiredInputType<SurfaceMesh>(0);
23 setOutput(std::make_shared<SurfaceMesh>());
26 std::shared_ptr<SurfaceMesh>
27 CleanMesh::getOutputMesh()
const 29 return std::dynamic_pointer_cast<SurfaceMesh>(
getOutput(0));
41 std::shared_ptr<PointSet> inputMesh = std::dynamic_pointer_cast<
PointSet>(
getInput(0));
42 if (inputMesh ==
nullptr)
44 LOG(WARNING) <<
"No inputMesh to clean";
47 vtkSmartPointer<vtkPolyData> inputMeshVtk =
nullptr;
48 if (
auto lineMesh = std::dynamic_pointer_cast<LineMesh>(inputMesh))
52 else if (
auto surfMesh = std::dynamic_pointer_cast<SurfaceMesh>(inputMesh))
58 LOG(WARNING) <<
"Unsupported mesh type";
62 vtkNew<vtkCleanPolyData> filter;
63 filter->SetInputData(inputMeshVtk);
64 filter->SetTolerance(m_Tolerance);
65 filter->SetAbsoluteTolerance(m_AbsoluteTolerance);
66 filter->SetToleranceIsAbsolute(m_UseAbsolute);
69 if (std::dynamic_pointer_cast<LineMesh>(inputMesh) !=
nullptr)
73 else if (std::dynamic_pointer_cast<SurfaceMesh>(inputMesh) !=
nullptr)
Base class for all geometries represented by discrete points and elements The pointsets follow a pipe...
std::shared_ptr< LineMesh > copyToLineMesh(vtkSmartPointer< vtkPolyData > vtkMesh)
Converts vtk polydata into a imstk surface mesh.
vtkSmartPointer< vtkPolyData > copyToVtkPolyData(std::shared_ptr< LineMesh > imstkMesh)
Converts imstk line mesh into a vtk polydata.
std::shared_ptr< Geometry > getInput(size_t port=0) const
Returns input geometry given port, returns nullptr if doesn't exist.
void setInputMesh(std::shared_ptr< SurfaceMesh > inputMesh)
Required input, port 0.
void setNumOutputPorts(const size_t numPorts)
Get/Set the amount of output ports.
void requestUpdate() override
Users can implement this for the logic to be run.
std::shared_ptr< Geometry > getOutput(size_t port=0) const
Returns output geometry given port, returns nullptr if doesn't exist.
void setInput(std::shared_ptr< Geometry > inputGeometry, size_t port=0)
Set the input at the port.
std::shared_ptr< SurfaceMesh > copyToSurfaceMesh(vtkSmartPointer< vtkPolyData > vtkMesh)
Converts vtk polydata into a imstk surface mesh.
void setOutput(std::shared_ptr< Geometry > inputGeometry, const size_t port=0)
Set the output at the port.
void setNumInputPorts(const size_t numPorts)
Get/Set the amount of input ports.