zoukankan      html  css  js  c++  java
  • 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();
  • 相关阅读:
    乘法相关
    hdu 1211 RSA (逆元)
    hdu 1811 Rank of Tetris (拓扑 & 并查集)
    hdu 2153 仙人球的残影
    hdu 1426 Sudoku Killer (dfs)
    hdu 2510 符号三角形 (DFS+打表)
    zoj 1002 Fire Net (二分匹配)
    hdu 1172 猜数字
    hdu 1728 逃离迷宫 (bfs)
    《Effective C++》笔记:III(转载)
  • 原文地址:https://www.cnblogs.com/VVingerfly/p/4661871.html
Copyright © 2011-2022 走看看