2012-03-13 16 views
5

私はそれぞれに関連付けられたIDを持つ2D点のセットを持っています。 (例えば、点が配列に格納されている場合、idは各点0、...、n-1へのインデックスです)。CGAL 2D Delaunay三角形分割:頂点のIDのペアとしてエッジを取得する方法

これらの点のDelaunay三角測量を作成し、すべての有限の辺をリストしたいと思います。各辺について、対応する2頂点で表される点の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) 
{ 
    } 
} 

答えて

7

まず、these examplesのような情報を持つ頂点タイプを使用する必要があります。次に、エッジとは、フェースのハンドルと、エッジの反対側のフェースの頂点のインデックスを含むペアです。

あなたが持っている場合:あなたが探している

Delaunay::Edge e=*it; 

指標は以下のとおりです。

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

sloriot:非常に役立ちます。ありがとう。 – 911

+0

だからクリア!ありがとうございました。 – LoveMeow

関連する問題