trimesh.section face_index 没有映射到返回的 Path3D?

trimesh.section face_index doesn't map to the returned Path3D?

我注意到 trimesh.section 方法 returns 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 似乎在路径的实体节点方面出现了乱序。给定一个特定的路径实体,我如何找到路径实体所在的网格上的面?

我能够使用 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)