Search code examples
mathgeometry2dcomputational-geometrycgal

CGAL 3.4: How do I get end vertex co-ordinates from a Finite_edges_iterator?


Here is some code:

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
}

From the manual:

"The edges are not explicitly represented, they are only implicitly represented through the adjacency relations of two faces. Each edge has two implicit representations: the edge of a face f which is opposed to the vertex indexed i, can be represented as well as an edge of the neighbor(i) of f."

That's fine by me... but how do I get the end vertices of the edge using a CT::Finite_edges_iterator in the code given above?

Update: I managed to come up with this solution:

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

I am still looking for a better way to do this.


Solution

  • I managed to come up with this solution:

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

    I am still looking for a better way to do this.