使用boost::polygon模块进行多边形切割和voronoi图计算是常见的操作,为了验证这些功能是否正常运作,我们需要编写一些测试程序。下面是一个简单的程序示例,用于创建两个矩形,并计算它们的voronoi图:
#include <iostream>
#include <boost/polygon/voronoi.hpp>
using namespace boost::polygon;
typedef voronoi_diagram<double> VD;
typedef VD::edge_type Edge;
typedef VD::vertex_type Vertex;
int main() {
// 创建多边形
polygon_90_set<double> poly;
rectangle_data<double> rect1(0, 0, 10, 10);
rectangle_data<double> rect2(5, 5, 15, 15);
poly.insert(rect1);
poly.insert(rect2);
// 计算voronoi图
VD vd;
construct_voronoi(poly.begin(), poly.end(), &vd);
// 打印图形信息
std::cout << "Voronoi图有" << vd.num_edges() <&