CGAL 2D Delaunay Triangulation:如何获取边作为顶点id对 [英] CGAL 2D Delaunay Triangulation: How to get edges as vertex id pairs

查看:1226
本文介绍了CGAL 2D Delaunay Triangulation:如何获取边作为顶点id对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组2D点,每个点都有一个相关的ID。 (例如,如果点被存储在数组中,则id是到每个点0,...,n-1的索引)。

I have a set of 2D points each with an associated id. (e.g. if the points are stored in an array, the id is the index into each point 0,....,n-1 ).

现在我创建Delaunay这些点的三角形,并想列出所有的有限边。对于每个边,我想有由相应的2个顶点表示的点的ids。示例:如果在点0和点2之间存在边缘,则(0,2)。这可能吗?

Now I create a Delaunay triangulation of these points and want to list down all the finite edges. For each edge, I would like to have the ids of the points represented by corresponding 2 vertices. Example: if there's an edge between point 0 and point 2 then (0,2). Is this 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)
 {
     }
}


推荐答案

首先你需要使用一个顶点类型,在这些示例中。然后边是包含面部句柄的对,以及与边缘相对的面中的顶点的索引。

First you need to use a vertex type with info as in these examples. Then an edge is a pair containing a handle to a face as well as the index of the vertex in the face that is opposite to the edge.

如果你有: / p>

if you have:

Delaunay::Edge e=*it;

您正在寻找的是:

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

这篇关于CGAL 2D Delaunay Triangulation:如何获取边作为顶点id对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆