2012-03-13 1 views
5

나는 연관된 id를 가진 2D 점 집합을 가지고 있습니다. (예를 들어, 점이 배열에 저장되면 id는 각 점 0, ..., n-1에 대한 색인입니다).CGAL 2D Delaunay 삼각 측량 : 꼭지점 ID 쌍으로 모서리를 얻는 방법

이제 나는이 포인트의 델 로니 삼각 측량을 만들고 모든 유한 에지를 나열하려고합니다. 각 가장자리에 대해, 해당하는 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

관련 문제