我能够使用 face_adjacency 图找到要删除的面孔,但似乎必须有更好的方法来做到这一点,因为工作基本上已经在调用中完成section
:
paths = inner.section(plane_origin=origin, plane_normal=norm)
# find the closed path entity with a centroid nearest to the plane origin
nearest, idx = _find_nearest_closed_path(origin, paths)
face_adjacency = trimesh.graph.face_adjacency(inner.faces[paths.metadata['face_index']])
graph = nx.Graph()
graph.add_edges_from(face_adjacency)
ccs = list(nx.connected_components(graph))
nearest, idx = _find_nearest_closed_path(origin, paths)
# making a big assumption that the connected_components are in the same order as the Path3D entities...
remove_faces = paths.metadata['face_index'][np.asarray(list(ccs[idx]))]
mask = np.full(inner.faces.shape[0], True, dtype=bool)
mask[remove_faces] = False
# update the mesh
inner.update_faces(mask)