Question

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.

Was it helpful?

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.

OTHER TIPS

I have using something like

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

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

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top