boost::polygon模块实现多边形集合的测试程序
在计算几何中,我们经常需要处理多边形集合的相关问题,例如求交、求并、判断包含关系等。Boost库中提供了一个非常实用的polygon模块,可以方便地处理多边形集合的各种操作,并且兼容STL标准,使用十分方便。
下面给出一个简单的测试程序,用于演示boost::polygon模块的基本使用方法。
#include <iostream>
#include <vector>
#include "boost/polygon/polygon.hpp"
using namespace boost::polygon;
using namespace std;
// 定义一组多边形
typedef polygon_data<int> Polygon;
typedef polygon_traits<Polygon>::point_type Point;
typedef vector<Point> PointList;
typedef vector<Polygon> PolygonList;
void printPolygon(Polygon& poly) {
cout << "Polygon(";
for (auto it = begin_points(poly); it != end_points(poly); ++it) {
cout << "(" << it->x() << ", " << it->y() <<