此代码片段在 2D 版本中运行良好,但在 3D 版本中无法编译:
namespace bg = boost::geometry;
typedef bg::model::point<double, 3, bg::cs::cartesian> Point3D;
typedef bg::model::polygon<Point3D> Poly3D;
Poly3D p0, p1;
vector<Poly3D> result;
bg::read_wkt("POLYGON((0 0 0, 0 1 1, 1 0 0, 0 0 0))", p0);
bg::read_wkt("POLYGON((0 0 0.5, 0 11 0.5, 11 0 0.5, 0 0 0.5))", p1);
bg::intersection(p0, p1, result);
出现此模板错误:
1>C:\boost_1_54_0\boost/geometry/core/coordinate_dimension.hpp(89): error C2338: ( boost::mpl::equal_to < geometry::dimension<Geometry>, boost::mpl::int_<Dimensions> >::type::value )
...
谁能告诉我intersection
打电话有什么问题?我的应用是找到平面多边形的交集。我可以看到,一般情况下Poly3D
不必是平面的,所以它可能是这个错误的根源。有没有办法定义平面 3D 多边形类型?