首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >trimesh.section face_index不映射到返回的Path3D?

trimesh.section face_index不映射到返回的Path3D?
EN

Stack Overflow用户
提问于 2020-10-06 13:40:54
回答 1查看 125关注 0票数 0

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

代码语言:javascript
复制
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似乎是无序的.给定一个特定的路径实体,我如何找到路径实体所放置的网格上的脸?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-08 16:37:03

我找到了可以用face_adjacency图移除的脸,但似乎必须有更好的方法来完成,因为对section的调用基本上已经完成了。

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64227066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档