9

それぞれに関連付けられたIDを持つ2Dポイントのセットがあります。(たとえば、ポイントが配列に格納されている場合、idは各ポイント0、....、n-1へのインデックスです)。

次に、これらの点のドロネー三角形分割を作成し、すべての有限エッジをリストします。エッジごとに、対応する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)
 {
     }
}
4

1 に答える 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();
于 2012-03-19T13:52:54.130 に答える