【问题标题】:boost::geometry 3D polygon intersection compilation errorsboost::geometry 3D 多边形相交编译错误
【发布时间】:2014-01-23 22:06:42
【问题描述】:

这段代码 sn-p 在 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 多边形类型?

【问题讨论】:

    标签: c++ boost boost-geometry


    【解决方案1】:

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

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

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

    【讨论】:

    • programmers made this explicitely clear - 在模板中明确明确,这本身就是一个非常混乱的符号;-)
    猜你喜欢
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多