2017-09-08 11 views
3

ボロノイ図を使用してエッジポイント(凸包の境界の端にあるポイント)を抽出します。私は無制限のセルに境界サイトポイントが含まれていることを知っていますが、イテレータを使用してその情報にどのようにアクセスできますか?CGOLを使用したボロノイ図:エッジポイントのみを抽出する(凸包)

ソリューション

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; 
} 

を、そしてインスピレーションを得ますそれによって、そして周りを遊ぶ。

関連する問題