【发布时间】:2019-12-06 19:25:41
【问题描述】:
我使用 CGAL Segment_Delaunay_graph 为线段集合创建了 voronoi 图。我想提取与 voronoi 细胞相对应的 Segment_Delaunay_graph 的边缘。有用于此目的的方法 draw_dual() 和 draw_skeleton() ,但两者都包含一些我不想保留的额外边缘(并且 draw_skeleton 删除了一些我确实想要保留的边缘)。
这是显示问题的图像:
黑线是输入。它们通常是由多个线段组成的组,首尾相连以形成更长的线,尽管每个线段都像这样单独输入到 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