Mesh clipping along a plane

263 Views Asked by At

Image I would like to ask if anyone knows how to get the intersection points between the plane and the triangle-mesh or change their color (like in the photo). I know that by using this function (clip_plane() frome open3d) the intersection between mesh and plane will produced and a new mesh is saved. but is there any direct methods to get the Points too. Also, if the mesh was watertight before, how can i close it again afterwards? I tried the function fill_holes() with hole_size: float = 100000000 but unfortunately the mesh remains open. Are there any other methods ?

clip_plane()
fill_holes()

I expected a watertight mesh with intersection points with the plane like in the image

1

There are 1 best solutions below

0
Lady Be Good On

It is impossible the paint the points in space because your points are not continuous. Instead, you can color the triangles that has distance less than a threshold value. Also you can follow the same approach, iterate through each points and check if its Euclidian distance is less than a value; then you can give it a color as well. Following snippet should give you a direction:

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)

I am not familiar with python API, but you are welcome for further clarification if answer is not clear.