CGAL Voronoi图:将输入站点链接到面

时间:2014-10-14 15:08:42

标签: c++ cgal

我正在使用CGAL构建Voronoi图,如下所示:

//consider some points
std::vector<Point_2> points = read_input();

//throw points (i.e. Sites) into Voronoi diagram
VD vd;
for (std::vector<Point_2>::iterator it = points.begin(); it != points.end(); ++it) {
    vd.insert(*it);
}

现在,我想知道是否有办法检索原始网站所属的面孔:

for (VD::Site_iterator it = vd.sites_begin(); it != vd.sites_end(); ++it) {
    it->?!
}

从上面的迭代器的签名中,没有明显的链接到voronoi图的底层半边数据结构。我知道locate方法,但据我所知,定位在O(log(n))时间运行。因为我想查询所有站点,结果运行时将是O(n * log(n)),这看起来有点浪费。我有什么遗失的吗?

1 个答案:

答案 0 :(得分:2)

你可以通过迭代面并调用dual方法来反过来。

for (VD::Face_iterator fit=vd.faces_begin(),
                       fit_end=vd.faces_end();
                       fit!=fit_end;++fit)
{
  fit->dual()->point();
}