OpenMesh 删除网格顶点

 

OpenMesh 提供了 delete_vertex() 函数来实现从网格中删除顶点,在删除掉顶点的同时,所有与该顶点相连的边也同时被删除。

OpenMesh 官方文档 中给的顶点删除函数声明如下:

void OpenMesh::PolyConnectivity::delete_vertex(VertexHandle _vh, bool _delete_isolated_vertices = true)

Mark vertex and all incident edges and faces deleted.

Items marked deleted will be removed by garbageCollection().

Attention: Needs the Attributes::Status attribute for vertices, edges and faces.

 

需要注意的是,在删除几何元素前,需要获取网格顶点、边和面的状态属性,并在删除结束后释放。所有正确的删除网格顶点的代码如下:

 

MyMesh mesh;
vector<MyMesh::VertexHandle>    delete_vh;     //删除顶点的集合
if (!mesh.has_vertex_status())  mesh.request_vertex_status();
if (!mesh.has_face_status())    mesh.request_face_status();
if (!mesh.has_edge_status())    mesh.request_edge_status();

for (auto vit=mesh.vertices_begin(); vit!=mesh.vertices_end(); vit++)
{
    if (find(delete_vh.begin(), delete_vh.end(), vit.handle()) ==delete_vh.end())
    {
        mesh.delete_vertex(vit.handle(), true);
    }
}
mesh.garbage_collection();

if (mesh.has_vertex_status())  mesh.release_vertex_status();
if (mesh.has_face_status())    mesh.release_face_status();
if (mesh.has_edge_status())    mesh.release_edge_status();

 

转载于:https://www.cnblogs.com/VVingerfly/p/4661871.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值