未能使用boost :: geometry :: model :: polygon

问题描述 投票:0回答:1

我正在尝试使用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);

c++ boost boost-geometry
1个回答
1
投票

双点[] [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<>用作Point。注意使用BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS宏来使tuple<>适应Point概念。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.