从edge_iterator获取vertex_handle

cde*_*ker 9 c++ delaunay triangulation cgal

我在Delaunay三角剖分中为边缘的每个端点获取vertex_handle时遇到了一些困难.自从我在几个小时内对抗这个问题后,我想也许你们其中一个人可以帮我解决这个显而易见的微不足道的问题:

#include <iostream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>

using namespace std;

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Point Point;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Vertex_handle Vertex;

int main(){
  Point p;
  Triangulation t;
  while(cin >> p)
    t.insert(p);

  // Iterate over edges
  for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
    // Get a vertex from the edge
    Vertex vs = ei->source();
  }
}
Run Code Online (Sandbox Code Playgroud)

根据取消引用Edge_iterator的文档,我应该得到一个Edge_handle,而Edge_handle应该有成员source()和target()来简单地获取端点,但是它不会编译并且似乎是错误的.像上面那样去反射会给我一对<>,它没有那些成员函数.

知道我做错了什么吗?

bjo*_*rnz 10

取消引用Edge_iteratorEdge根据文档给出一个.

Edge 定义如下: typedef std::pair<Face_handle,int> Edge;

取消引用Face_handle会给你一个面孔.

边连接的两个顶点可以通过以下方式访问:

  for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
    // Get a vertex from the edge
    Triangulation::Face& f = *(ei->first);
    int i = ei->second;
    Vertex vs = f.vertex(f.cw(i));
    Vertex vt = f.vertex(f.ccw(i));
  }
Run Code Online (Sandbox Code Playgroud)

我不知道它对你的任务是否有帮助,但是可以访问这样的点:

for (Edge_iterator it = m_tri.edges_begin(); it != m_tri.edges_end(); ++it)
{
    Triangulation::Segment seg = m_tri.segment( *it );

    Triangulation::Point p0 = seg.point(0);
    Triangulation::Point p1 = seg.point(1);
    // ...
}
Run Code Online (Sandbox Code Playgroud)

CGAL文档让我感到困惑......我很好奇你找到的地方eh->source()eh->target()电话,我找不到它:-)