如何修改boost::geometry::polygon中的顶点?
Boost Geometry多边形顶点修改问题
我使用以下代码从boost::geometry::polygon中获取顶点:
using namespace boost::geometry; using PointType = model::d2::point_xy<double>; using PolygonType = model::polygon<PointType, false>; // 顺时针排序 PolygonType poly; // 此处设置多个顶点 for(auto pos = 0; pos < num_points(poly); ++pos) { PointType pt = poly.outer()[pos]; // 此处对点进行操作 }
原本我找不到简便的方法修改多边形中特定顶点的值,误以为以下代码无法生效:
PointType new_pt{3, 3}; poly.outer()[pos] = new_pt;
实际上这段代码是有效的。
内容的提问来源于stack exchange,提问作者Andrew Bond
相关产品推荐
相关产品推荐

