0

我注意到该trimesh.section方法返回 a Path3D,其中相交面的索引卡在路径的metadata['face_index']. 我还注意到面部索引的数量对应于路径实体节点的数量:

paths = inner.section(plane_origin=origin, plane_normal=norm)
assert(len([node for path in paths.entities for node in path.nodes]) == len(paths.metadata['face_index']))

但是,对于路径的实体节点,face_index 似乎是无序的。给定一个特定的路径实体,我如何在网格上找到路径实体所在的面?

4

1 回答 1

0

我能够使用 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)
于 2020-10-08T16:37:03.570 回答