Hi,
I’m trying to decimate a mesh because I have far too many triangles for the mesh to be useable.
So far I have been using:
def Decimation(meshname):
reader = vtk.vtkSTLReader()
reader.SetFileName(meshname)
reader.Update()
polydata = reader.GetOutput()
print("Before ",meshname, " decimation\n"
"-----------------\n"
"There are " + str(polydata.GetNumberOfPoints()) + "points.\n"
"There are " + str(polydata.GetNumberOfPolys()) + "polygons.\n")
decimate = vtkDecimatePro()
decimate.SetInputData(polydata)
decimate.SetTargetReduction(.90)
decimate.PreserveTopologyOn()
decimate.Update()
decimatedPoly = vtkPolyData()
decimatedPoly.ShallowCopy(decimate.GetOutput())
print("After ",meshname, " decimation \n"
"-----------------\n"
"There are " + str(decimatedPoly.GetNumberOfPoints()) + "points.\n"
"There are " + str(decimatedPoly.GetNumberOfPolys()) + "polygons.\n")
stlWriter = vtkSTLWriter()
stlWriter.SetFileName(meshname)
stlWriter.SetFileTypeToBinary()
stlWriter.SetInputConnection(decimate.GetOutputPort())
stlWriter.Write()
Decimation("Output\\Meshes\\Tmesh.stl")
Decimation("Output\\Meshes\\Cmesh.stl")
This seems to work though the resultant mesh is very ugly:
Is there a way to make the mesh more consistent?