如何使打开的stl文件不漏水

2024-05-16 03:37:57 发布

您现在位置:Python中文网/ 问答频道 /正文

这里是新手

我有一个STL文件,它不是无懈可击的,间隙很大,需要用修剪网格的闭合顶点来修复

我尝试使用open3d,方法是跟随this,但我有以下错误:“ValueError:vector太长”

有没有办法使网格防水?我需要计算CoM和惯性矩阵,但如果我的网格不是水密/封闭表面,则值将不正确

对于open3d,首先我上传了stl文件,将其转换为numpy,然后使用以下代码:

        pcd = o3d.geometry.PointCloud()
        pcd.points = o3d.utility.Vector3dVector(DataNP)
        o3d.io.write_point_cloud("testinggggg.ply", pcd)
        poisson_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=8, width=0, scale=1.1, linear_fit=False)[0]
        bbox = pcd.get_axis_aligned_bounding_box()
        p_mesh_crop = poisson_mesh.crop(bbox)
        o3d.io.write_triangle_mesh("output_testinggggg.ply", dec_mesh)

非常感谢您的帮助


Tags: 文件iocloud网格writepointpoissonply
1条回答
网友
1楼 · 发布于 2024-05-16 03:37:57

我已设法使网不漏水。我将在这里发布,以防将来有人遇到麻烦

我的网格实际上是由两个较小的网格组成的,因此我必须首先将它们合并在一起,然后使用VTK库来清理网格并填充孔。这使我的网格防水,我可以计算我需要的一切

代码如下:

input1 = vtk.vtkPolyData()
input2 = vtk.vtkPolyData()


input1.DeepCopy(Data1.GetOutput())
input2.DeepCopy(Data2.GetOutput())

# Append the two meshes 
appendFilter = vtk.vtkAppendPolyData()

appendFilter.AddInputData(input1)
appendFilter.AddInputData(input2)

appendFilter.Update()

#  Remove any duplicate points.
cleanFilter = vtk.vtkCleanPolyData()
cleanFilter.SetInputConnection(appendFilter.GetOutputPort())
cleanFilter.Update()


# newData = cleanFilter

fill = vtk.vtkFillHolesFilter()
fill.SetInputConnection(appendFilter.GetOutputPort())   
fill.SetHoleSize(100)    
fill.Update()

相关问题 更多 >