2017-09-08 3 views
3

보로 노이 다이어그램을 사용하여 모서리 점 (볼록 선체의 경계에있는 점)을 추출하고 싶습니다. 무한한 셀에 경계 사이트 지점이 있지만 이터레이터를 사용하여 해당 정보에 어떻게 액세스 할 수 있습니까?보로 노이 다이어그램 (CGAL 사용) : 가장자리 점 만 추출 (볼록 선체)

솔루션

VD vd; 
//initialise your voronoi diagram 
VD::Face_iterator it = vd.faces_begin(), beyond = vd.faces_end(); 
for (int f = 0; it != beyond; ++f, ++it) 
{ 
    std::cout << "Face " << f << ": \n"; 
    if (it->is_unbounded()) 
    { 
    // it's a boundary point 
    } 
} 

답변

0

읽기 CGAL 2D Delaunay Triangulation: How to get edges as vertex id pairs, 마음에 가진 보로 노이와 들로네의 관계는이 example 확인 :이 답변으로 문제가 해결되지 않는 경우

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 
#include <CGAL/Delaunay_triangulation_2.h> 
#include <fstream> 
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 
typedef CGAL::Delaunay_triangulation_2<K> Triangulation; 
typedef Triangulation::Edge_iterator Edge_iterator; 
typedef Triangulation::Point   Point; 
int main() 
{ 
    std::ifstream in("data/voronoi.cin"); 
    std::istream_iterator<Point> begin(in); 
    std::istream_iterator<Point> end; 
    Triangulation T; 
    T.insert(begin, end); 
    int ns = 0; 
    int nr = 0; 
    Edge_iterator eit =T.edges_begin(); 
    for (; eit !=T.edges_end(); ++eit) { 
    CGAL::Object o = T.dual(eit); 
    if (CGAL::object_cast<K::Segment_2>(&o)) {++ns;} 
    else if (CGAL::object_cast<K::Ray_2>(&o)) {++nr;} 
    } 
    std::cout << "The Voronoi diagram has " << ns << " finite edges " 
     << " and " << nr << " rays" << std::endl; 
    return 0; 
} 

을하고 영감을 얻을 그것으로 주위에 놀아 라.

관련 문제