python - 如何使打开的 STL 文件防水

标签 python numpy mesh open3d

这里是新手!

我有一个不防水的 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)

非常感谢任何帮助!

最佳答案

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

我的网格实际上是由 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()

关于python - 如何使打开的 STL 文件防水,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64804792/

相关文章:

python - numpy trapz 行为在 x 值处具有双重定义的 y 值(冲突点)

java - LibGDX 检测鼠标点击网格三角形

python - 无法保存Qt绘图的状态

带套接字的 python 聊天室无法按预期工作

python - 当Python中簇数为2时,我的图没有显示结果

python - 寻找离散函数的全局最小值

python - 将默认的日期时间对象值赋予 pandas.to_datetime()

python - 转换数据文件 'X' 'Y' 'Z' 'data' 格式

javascript - Three.js:尝试渲染自定义网格(菱形十二面体)?

OpenGL 2D Evaluator Mesh 无法设置更大