【问题标题】:CGAL Voronoi Diagram for Segments段的 CGAL Voronoi 图
【发布时间】:2019-12-06 19:25:41
【问题描述】:

我使用 CGAL Segment_Delaunay_graph 为线段集合创建了 voronoi 图。我想提取与 voronoi 细胞相对应的 Segment_Delaunay_graph 的边缘。有用于此目的的方法 draw_dual() 和 draw_skeleton() ,但两者都包含一些我不想保留的额外边缘(并且 draw_skeleton 删除了一些我确实想要保留的边缘)。

这是显示问题的图像:

example voronoi diagram

黑线是输入。它们通常是由多个线段组成的组,首尾相连以形成更长的线,尽管每个线段都像这样单独输入到 Segment_Delaunay_graph:

s 1677850.1951146198 466276.4198628192  1784307.2726912862 466276.4198628192
s 1784307.2726912862 466276.4198628192  1784307.2726912862 567677.3831007502
s 1784307.2726912862 567677.3831007502  1677850.1951146198 567677.3831007502

红线和蓝线由draw_dual() 输出。我想保留代表连接输入线周围 voronoi 单元边界的红线,但我不想保留蓝线。 是否可以根据 Segment_Delaunay_graph 中存储的信息过滤掉不需要的边缘?如果有,怎么做?

一些示例代码:

#include <iostream>
#include <fstream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Segment_Delaunay_graph_filtered_traits_2.h>
#include <CGAL/Segment_Delaunay_graph_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Segment_Delaunay_graph_filtered_traits_2<K>  Gt;
typedef CGAL::Segment_Delaunay_graph_2<Gt>             SDG2;

using namespace std;

int main()
{

    //read line segments from input file
    string inFile = "example-a.in";
    ifstream ifs(inFile);

    SDG2          sdg;
    SDG2::Site_2  site;

    std::vector<SDG2::Site_2> sites;
    while (ifs >> site) {
        sites.push_back(site);
    }

    ifs.close();

    //add line segments to diagram
    sdg.insert(sites.begin(), sites.end(), CGAL::Tag_true());

    //save voronoi edges to a file
    string outFile = "example-a.out";
    ofstream ofs(outFile);

    sdg.draw_dual(ofs);

    ofs.close();

}

【问题讨论】:

    标签: cgal


    【解决方案1】:

    我观察到你想保留的红线。它们是距离不是交汇点的站点很远的边缘吗?您可以设置距离阈值d,如果边缘到其最近站点的距离小于d,并且站点不是交汇点,则移除此边缘。

    【讨论】:

    • 感谢您的想法。我没有在 CGAL Segment_Delaunay_graph 中看到距离阈值选项。这个选项是 CGAL 内置的吗?
    • 你可以自己实现。只能通过设置 if (squared_distance( segment, v[i]->site()) 来保存边缘,其中 SDG2::Vertex_handle v[] = { e.first->vertex( sdg.ccw(e.second) ), e.first->vertex( sdg.cw(e.second) ), e.first->vertex( e.second ), sdg.tds().mirror_vertex(e.first, e.second) }; CGAL ::Segment_2 段(e.first,e.second);参考:compgeom.inf.usi.ch/doc_output/Segment_Delaunay_graph_Linf_2/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多