首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在pymeshlab中选择一个顶点数组?

如何在pymeshlab中选择一个顶点数组?
EN

Stack Overflow用户
提问于 2021-07-17 03:29:22
回答 1查看 575关注 0票数 1

我想从网格中删除存储在NumPy数组中的一些顶点。如何根据顶点索引或坐标在pymeshlab中选择这些顶点?谢谢!

代码语言:javascript
复制
import pymeshlab
from scipy.spatial import KDTree

def remove_background(subdir, ms):
    # load joint points
    joint_arr = load_joint_points(subdir)

    # get a reference to the current mesh
    m = ms.current_mesh()

    # get numpy arrays of vertices of the current mesh
    vertex_array_matrix = m.vertex_matrix()
    print(f'total # of vertices: {m.vertex_number()}')

    # create a KD tree of the joint points
    tree = KDTree(joint_arr)

    selected_vertices = []

    for vertex in vertex_array_matrix:
        # if the closest joint pt is farther than 500mm from the vertex, add the vertex to list
        dd, ii = tree.query(vertex, k=1)
        if(dd > 500):
            selected_vertices.append(vertex)

    print(f"delete {len(selected_vertices)} vertices")
    
    #how to select 'selected vertices' in pymeshlab?

    ms.delete_selected_vertices()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-21 08:18:14

!可以使用使用条件选择滤波器的索引有条件地选择顶点。

代码语言:javascript
复制
import pymeshlab as ml
ms = ml.MeshSet()
# just create a simple mesh for example
ms.sphere(subdiv=0)
# select the vertex with index 0
ms.conditional_vertex_selection(condselect="vi==0") 
# delete selected stuff
ms.delete_selected_vertices() 

更好的是,你可以做所有的背景移除在肉糜室内。如果您有两个网格/点云( A B ),并且希望从B中删除所有接近A的顶点(小于给定阈值),则只需加载两个网格,就可以使用Hausdorff距离滤波器,它将存储到A的每个顶点的“质量”中--距离E 113B<代码>E 214的最近顶点的距离;然后,您可以通过测试质量再次使用条件选择筛选器。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68417158

复制
相关文章

相似问题

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