CGAL 2D Delaunay Triangulation: how to get edges as pairs of vertex identifiers

I have a set of 2D points, each of which has an associated identifier. (for example, if points are stored in an array, the identifier is the index at each point 0, ...., n-1).

Now I am creating a Delaunay triangulation of these points and want to list all the trailing edges. For each edge, I would like to have the IDs of the points represented by the corresponding two vertices. Example: if there is a point between point 0 and point 2, then (0,2). Is it possible?

#include <vector>
#include <CGAL\Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL\Delaunay_triangulation_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Delaunay;
typedef K::Point_2 Point;

 void load_points(std::vector<Point>& rPoints)
 {
  rPoints.push_back(Point(10,10));   // first point
  rPoints.push_back(Point(60,10));   // second point
  rPoints.push_back(Point(30,40));   // third point
  rPoints.push_back(Point(40,80));   // fourth point
 }

void main()
{
 std::vector<Point> points;
 load_points(points);

 Delaunay dt;
 dt.insert(points.begin(),points.end());

 for(Delaunay::Finite_edges_iterator it = dt.finite_edges_begin(); it != dt.finite_edges_end(); ++it)
 {
     }
}
+5
source share
1 answer

, . , , , .

:

Delaunay::Edge e=*it;

:

int i1= e.first->vertex( (e.second+1)%3 )->info();
int i2= e.first->vertex( (e.second+2)%3 )->info();
+7

All Articles