2024-10-01 11:41:19 发布
网友
我有一个高分辨率的三角形网格,大约有200万个三角形。我想将三角形和顶点的数量减少到大约10000个,同时尽可能保持其一般形状。在
我知道这可以在Matlab中使用reducepatch实现。另一种选择是qslim包。在VTK中还有抽取功能,它有python接口,所以从技术上讲,在python中也是可能的。Meshlab可能在python中也可用(?)。在
如何在python中进行这种网格抽取?我们将不胜感激。在
我建议您使用vtkQuadricDecimation,输出模型的质量在视觉上比使用vtkDecimatePro要好(没有适当的设置)。在
decimate = vtkQuadricDecimation() decimate.SetInputData(inputPoly) decimate.SetTargetReduction(0.9)
其中最重要的一点是在保存STL时使用二进制表示:
这里是一个最小的python原型,从它的c++等价vtk示例(http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Decimation)翻译而来,正如MrPedru22所建议的那样。在
from vtk import (vtkSphereSource, vtkPolyData, vtkDecimatePro) def decimation(): sphereS = vtkSphereSource() sphereS.Update() inputPoly = vtkPolyData() inputPoly.ShallowCopy(sphereS.GetOutput()) print("Before decimation\n" " -\n" "There are " + str(inputPoly.GetNumberOfPoints()) + "points.\n" "There are " + str(inputPoly.GetNumberOfPolys()) + "polygons.\n") decimate = vtkDecimatePro() decimate.SetInputData(inputPoly) decimate.SetTargetReduction(.10) decimate.Update() decimatedPoly = vtkPolyData() decimatedPoly.ShallowCopy(decimate.GetOutput()) print("After decimation \n" " -\n" "There are " + str(decimatedPoly.GetNumberOfPoints()) + "points.\n" "There are " + str(decimatedPoly.GetNumberOfPolys()) + "polygons.\n") if __name__ == "__main__": decimation()
我建议您使用vtkQuadricDecimation,输出模型的质量在视觉上比使用vtkDecimatePro要好(没有适当的设置)。在
其中最重要的一点是在保存STL时使用二进制表示:
^{pr2}$这里是一个最小的python原型,从它的c++等价vtk示例(http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Decimation)翻译而来,正如MrPedru22所建议的那样。在
相关问题 更多 >
编程相关推荐