Getting vertex_handle from edge_iterator

It's pretty hard for me to get the vertex_handle command for each of the endpoints of an edge in a Delaunay triangulation. Since I bogged my head several times against this, I thought that maybe one of you guys could help me with this apparently trivial problem:

#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(); } } 

According to the documentation dereferencing Edge_iterator, I should get Edge_handle and Edge_handle should have source () and target () members to just get the endpoints, but it will not compile and seems to be wrong. Derefencing, as above, will give me a pair <> that does not have these member functions.

Any idea what I'm doing wrong?

+8
c ++ cgal triangulation delaunay
source share
1 answer

Dereferencing Edge_iterator will give you Edge as per the documentation .

Edge defined as follows: typedef std::pair<Face_handle,int> Edge;

Dereferencing Face_handle will give you Face .

The two vertices to which the edge joins can be accessed:

  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)); } 

I do not know if the quest is useful to you, but has access to such points:

 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); // ... } 

The CGAL documentation is confusing ... I'm curious where you found the calls eh->source() and eh->target() , I could not find it eh->target()

+9
source share

All Articles