【问题标题】:CGAL 3.4: How do I get end vertex co-ordinates from a Finite_edges_iterator?CGAL 3.4:如何从 Finite_edges_iterator 获取结束顶点坐标?
【发布时间】:2010-01-22 05:45:34
【问题描述】:

这里有一些代码:

struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};

typedef CGAL::Triangulation_vertex_base_2<K>               Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K>     Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb>        TDS;
typedef CGAL::Exact_predicates_tag                         Itag;
typedef CGAL::Constrained_triangulation_2<K, TDS, Itag>    CT;
typedef CT::Point                                          Point;

for (CT::Finite_edges_iterator eit = ct.finite_edges_begin();
    eit != ct.finite_edges_end(); ++eit){
    // TODO: list vertex co-ordinates here
}

来自manual

"边没有显式表示,它们只是通过两个面的邻接关系隐式表示。每条边有两种隐式表示:与索引为i的顶点相对的面f的边可以表示为以及 f 的邻居(i)的一条边。”

这对我来说很好......但是如何在上面给出的代码中使用CT::Finite_edges_iterator 获得边缘的末端顶点?

更新: 我设法想出了这个解决方案:

Segment s = ct.segment(eit);
const Point& p1 = s.point(0);
const Point& p2 = s.point(1);

我仍在寻找更好的方法来做到这一点。

【问题讨论】:

  • 我认为你的做法很好。

标签: math geometry 2d computational-geometry cgal


【解决方案1】:

我设法想出了这个解决方案:

Segment s = ct.segment(eit);
const Point& p1 = s.point(0);
const Point& p2 = s.point(1);

我仍在寻找更好的方法来做到这一点。

【讨论】:

    【解决方案2】:

    我用过类似的东西

    Triangulation::Vertex_handle fVertex = eit->first->vertex(Triangulation::ccw(eit->second));

    Triangulation::Vertex_handle sVertex = eit->first->vertex(Triangulation::cw(eit->second));

    【讨论】:

      【解决方案3】:

      边提供面上顶点的索引。三角剖分的面在 CGAL 中只有 3 个顶点。边是三元组; (脸,我,j)。你可以get the i-th (either 0, 1, or 2) vertex of a face using the vertex(i) method.。因此,要获取顶点,请使用:

      v1 = eit->first->vertex(eit->second);
      v2 = eit->first->vertex(eit->third);
      

      【讨论】:

      • 谢谢...但是,third 不是 eit 的成员...这是 Constrained_triangulation_2... CGAL 3.4 我已经用可能的解决方案更新了我的问题。有没有更好的方法来做到这一点?
      • 嗯。您可以尝试使用 ccw 和 cw 来获取第二个顶点:eit->first->vertex(ct.ccw(eit->second)),但是您所做的方式似乎是一种非常好的方式,并且可能更好。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      • 2012-01-18
      • 2018-06-24
      • 1970-01-01
      • 2011-06-17
      • 1970-01-01
      相关资源
      最近更新 更多