【问题标题】:CGAL: Iterate over all vertices of all facesCGAL:迭代所有面的所有顶点
【发布时间】:2018-08-10 15:29:27
【问题描述】:

我在 CGAL 中有一个 SurfaceMesh:

https://doc.cgal.org/latest/Surface_mesh/index.html

我了解如何迭代每个面,如示例所示:

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3                    Point;
typedef CGAL::Surface_mesh<Point>          Surface_mesh;
BOOST_FOREACH(boost::graph_traits<Surface_mesh>::face_descriptor fit, faces(mesh)){
  //do something here
}

这里,mesh 是一个 Surface_mesh。我完全不清楚 face_descriptor 是什么,以及如何使用它。当一个人有一个 face_descriptor 时,如何访问一个面的半边和顶点?具体来说,如何遍历半边的所有顶点,并获得它们的坐标?

【问题讨论】:

  • mesh.halfedge(fit) 应该给你一个半边的开始。您链接到的用户手册有一个带有vertices_around_face 的示例。也可以搜索point获得积分...
  • 您能否链接或复制该示例?
  • 查看示例doc.cgal.org/latest/Surface_mesh/index.html#circulators_example,它展示了如何枚举面边界上的顶点

标签: c++ mesh cgal


【解决方案1】:

Boost Graph Library 有一个概念Graph,它定义了vertex_descriptoredge_descriptor。它们是图形元素的标识符。在 CGAL 中,我们将其扩展到具有面和半边的图。 FaceGraph 概念解释了您可以使用 face_descriptor 做什么。在此页面中,您可以通过 Refines: 进入概念 HalfedgeGraph,它告诉您可以使用其他描述符做什么。

这些链接指向即将发布的 CGAL 版本的在线手册,其中我们改进了有关描述符的文档 - 因此您并不孤单。

【讨论】:

    【解决方案2】:

    一种解决方案是,对于每个面,遍历该面周围的顶点。

    以下代码的作用是什么:

    typedef CGAL::Surface_mesh<Point>    Mesh;
    typedef CGAL_Mesh::Face_index        face_descriptor;
    
    int i=0;
    BOOST_FOREACH(face_descriptor f, faces(mesh)){
        int j=0;
        CGAL::Vertex_around_face_iterator<Mesh> vbegin, vend;
        for(boost::tie(vbegin, vend) = vertices_around_face(mesh.halfedge(f), mesh);
                vbegin != vend;
                ++vbegin){
            j++;
            std::cout << "jth index of ith face: "<< *vbegin << std::endl;
        }
        i++;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      • 2011-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多