4

此代码片段在 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 多边形类型?

4

1 回答 1

3

嗯。编译器告诉您调用的算法对 3 维无效......程序员明确表示了这一点(area.hpp):

    BOOST_CONCEPT_ASSERT( (geometry::concept::AreaStrategy<Strategy>) );
    assert_dimension<Ring, 2>();

所以。是的。不能intersection用于跨越两个平面多边形。我很确定通过一些数学运算,您可以进行两个预测,这将导致两个交叉点一起为您提供所需的信息。

于 2014-01-23T23:41:07.923 回答