4

QtでCGALを使用してボロノイ図を描いています。CGAL::Voronoi_diagram_2<DT,AT,AP>顔が必要なので使いました。これはコード例です:

for(Face_iterator f = VD.faces_begin(); f != VD.faces_end(); f++)
    {
        Ccb_halfedge_circulator ec_start = (f)->ccb();
        Ccb_halfedge_circulator ec = ec_start;
        do {
            if (!ec->has_source())
            {
            }
            else
                QpolyF << QPointF(((Halfedge_handle)ec)->source()->point().x(), ((Halfedge_handle)ec)->source()->point().y());
        } while ( ++ec != ec_start );
        VectPolygon.push_back(QpolyF);
        QpolyF.clear();}

ソースまたはターゲットが無限にある光線をクリップする必要があります。Cropped_voronoi_from_delaunay を使用してボロノイを生成すると、面ではなくセグメントのみが得られます。これらはtypedefです:

typedef K::Line_2                                           Line_2;
typedef CGAL::Delaunay_triangulation_2<K>                   Delaunay_triangulation_2;
typedef Delaunay_triangulation_2::Face_iterator             dt_Face_iterator;
typedef Delaunay_triangulation_2::Edge_circulator           dt_Edge_circulator;

// typedefs for defining the adaptor
typedef CGAL::Exact_predicates_inexact_constructions_kernel                  K;
typedef CGAL::Delaunay_triangulation_2<K>                                    DT;
typedef CGAL::Delaunay_triangulation_adaptation_traits_2<DT>                 AT;
typedef CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<DT> AP;
typedef CGAL::Voronoi_diagram_2<DT,AT,AP>                                    VD;


// typedef for the result type of the point location
typedef AT::Site_2                    Site_2;
typedef AT::Point_2                   Point_2;

typedef VD::Locate_result               Locate_result;
typedef VD::Vertex_handle               Vertex_handle;
typedef VD::Face_handle                 Face_handle;
typedef VD::Face_iterator               Face_iterator;
typedef VD::Halfedge_handle             Halfedge_handle;
typedef VD::Ccb_halfedge_circulator     Ccb_halfedge_circulator;
4

3 に答える 3

2

CGALでそれが可能であることは知っていますが、今のところ回避策を見つけました。Qt では、QPolygon クラスに交差するポリゴンを見つける機能があります。Qpolygon::intersected(yourPolygon). これは結果です:

長方形にトリミングされたボロノイ図

于 2013-07-12T07:09:23.020 に答える
2

ここにいくつかの実験的なコードがあります: http://code.google.com/p/cgal-voronoi-croppingボロノイ図を四角形にトリミングし、結果は HDS になります。test ディレクトリの main.cpp を参照してください

于 2014-05-23T08:59:47.023 に答える