如何使打开的 stl 文件水密

问题描述 投票:0回答:2

这里是新手!

我有一个不防水的STL文件,并且间隙很大,需要用修剪网格的紧密顶点来修复。

我按照this尝试使用open3d,但出现以下错误:“ValueError:向量太长”..

有什么办法可以让网格不漏水吗?我需要计算 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)

非常感谢任何帮助!

python numpy mesh open3d
2个回答
4
投票

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

我的网格实际上是由 2 个较小的网格组成的,因此我必须首先将它们合并在一起,然后使用 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()

0
投票

在 t.geometry 上使用 pyVista fill_holes() 可以获得相同的结果;此方法仅适用于可视化;在“固定”网格上调用 open3d get_volume() 函数/方法不会返回任何体积,因为该网格仍然不防水!我需要获得从点云生成的网格体积,没有 CAD 软件,只有 python 和所需的库。帮忙!?

© www.soinside.com 2019 - 2024. All rights reserved.