0

我正在尝试使用 boost::geometry::model:polygon ,但我无法让它工作,我还发现里面还有其他东西:

#include <boost/geometry/geometry.hpp>

称为polygon_2d

我不知道我需要哪一个以及如何使用它。

我尝试编写以下代码:

double points[][2] = {{2.0, 1.3}, {4.1, 3.0}, {5.3, 2.6}, {2.9, 0.7}, {2.0, 1.3}};
model::polygon<model::d2::point_xy<double> > poly;
append(poly, points);

但不幸的是它不起作用,我收到以下编译错误:

boost::mpl::assertion:_failed : cannot convert parameter 1 from 'boost::mpl::failed**** (_cdecl boost::geometry::traits::point_type<Geometry>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE

我的最终目标是创建一个多边形并检查点是否在他体内..

提前致谢

编辑:附加功能期望(Geometry& geometry, RangeOrPoint const& range_or_point);

4

1 回答 1

1

double points[][2] 不是点范围。你可以std::vector<model::d2::point_xy<double> >改用。

请参阅示例: http: //www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/append.html 这里boost::tuple<>用作一个点。注意使用BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS宏来适应tuple<>点的概念。

使用这些函数,您可以访问多边形的环:

http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/access/exterior_ring/exterior_ring_1.html

http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/access/interior_rings/interior_rings_1.html

于 2014-04-15T20:04:55.567 回答