我注意到,trimesh.section方法返回一个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似乎是无序的.给定一个特定的路径实体,我如何找到路径实体所放置的网格上的脸?
发布于 2020-10-08 16:37:03
我找到了可以用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)https://stackoverflow.com/questions/64227066
复制相似问题