我正在尝试将一个空间划分为一组多边形,其中每个多边形大约是一组输入点中的一个的 voroni 元胞。
我试图为此目的使用 Boost::Voroni,但是使用这个库的输出很复杂,需要很多额外的努力才能得到我想要的。
我想知道是否有人知道从 BOOST::voroni 图表中获取我想要的内容的最佳方法,或者是否有人知道一个比直接获取我正在寻找的内容更简单的库?
这里有一些代码展示了我正在尝试做的事情,
voronoi_diagram< float > vd;
construct_voronoi( gridPointPos.begin(), gridPointPos.end(), &vd );
int index = 0;
for (voronoi_diagram<float>::const_cell_iterator it = vd.cells().begin();
it != vd.cells().end(); ++it, ++index ) {
// if the voroni cell has infinite edges,
// then clip them to a finite length
// extract the voroni vertices of this cell
// create a boost polygon from the extracted edges
}
因为 boost 对于我的需求来说过于笼统和复杂,所以我更喜欢一个库或算法来简单地完成所有这些,只返回多边形集。我有哪些选择?
最佳答案
您可以尝试我在 PHP 中实现的用于 delaunay 三角剖分的 bowyer-watson 增量算法,它还可以找到 voronoi 图。您可以在 codeplex.com ( http://voronoi.codeplex.com/ ) 下载它。
关于c++ - 给定一组点,使用 voroni 近似将空间分割成多边形区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30881372/