views:

204

answers:

2

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.

A: 

The edges provide the indices of the vertices on the face. The face of a triangulation has only 3 vertices in CGAL. Edges are a triplet; (face, i, j). You can get the i-th (either 0, 1, or 2) vertex of a face using the vertex(i) method.. So, to get the vertices, use:

v1 = eit->first->vertex(eit->second);
v2 = eit->first->vertex(eit->third);
tixxit
Thanks... But, third is not a member of eit... this is Constrained_triangulation_2... CGAL 3.4I have updated my question with a possible solution. Is there a better way to do this?
Vulcan Eager
Hrmm. You can try using the ccw and cw to get the 2nd vertex: eit->first->vertex(ct.ccw(eit->second)), but the way you did seems to be a perfectly fine way of doing it, and probably better.
tixxit
A: 

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.

Vulcan Eager