沿平面剪切网格

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

enter image description here我想问是否有人知道如何获取平面和三角形网格之间的交点或更改它们的颜色(如照片中所示)。我知道通过使用这个函数(

clip_plane()
frome open3d)将产生网格和平面之间的交集并保存新的网格。但有没有什么直接的方法可以得到积分呢? 另外,如果网格之前是不漏水的,之后如何才能再次关闭它? 我尝试了
fill_holes()
hole_size: float = 100000000
功能,但不幸的是网格仍然打开。还有其他方法吗?

clip_plane()
fill_holes()

我期望有一个与平面相交点的防水网格,如图所示

mesh intersection plane open3d
1个回答
0
投票

不可能在空间中绘制点,因为你的点不是连续的。相反,您可以为距离小于阈值的三角形着色。您也可以遵循相同的方法,迭代每个点并检查其欧几里得距离是否小于某个值;然后你也可以给它一个颜色。以下片段应该给您一个方向:

triangle_faces = np.asarray(mesh.triangles)

intersected_indices = []

for i, face in enumerate(triangle_faces):
    v0 = triangle_vertices[face[0]]
    v1 = triangle_vertices[face[1]]
    v2 = triangle_vertices[face[2]]

    distances = a * v0[0] + b * v0[1] + c * v0[2] + d, \
                a * v1[0] + b * v1[1] + c * v1[2] + d, \
                a * v2[0] + b * v2[1] + c * v2[2] + d

    if any(abs(dist) < 0.005 for dist in distances):
        intersected_indices.append(i)

我对python API不熟悉,但如果答案不清楚,欢迎您进一步澄清。

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