CGAL 2D Delaunay Triangulation:如何将边缘表示为顶点ID对

9
我有一组带有关联id的2D点。(例如,如果这些点存储在数组中,则id是每个点0,....,n-1的索引。)
现在我创建了这些点的Delaunay三角剖分,并想列出所有有限边。对于每条边,我想要对应的两个顶点表示的点的id。例如:如果点0和点2之间有一条边,则为(0,2)。这是否可能?
#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)
 {
     }
}
1个回答

13

首先,你需要使用像这些示例中所示的带有信息的顶点类型。然后,一个边是一个包含对面的面的句柄以及与该边相反的面中顶点的索引的一对。

假设你有:

Delaunay::Edge e=*it;

你要查找的索引是:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接