如何在多边形索引处添加点? 以正确的索引插入点(2.5,7.5)。
输出:
((0,0),(0,5),(5,5),(5,0),(0,0),(2.5,7.5)))
-------------------▼
((0,0),(0,5),(2.5,7.5),(5,5),(5,0),(0,0)))
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
int main()
{
typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
polygon poly;
boost::geometry::append ( poly, point(0, 0) );
boost::geometry::append ( poly, point(0, 5) );
boost::geometry::append ( poly, point(5, 5) );
boost::geometry::append ( poly, point(5, 0) );
boost::geometry::append ( poly, point(0, 0) );
poly.outer().push_back( point(2.5, 7.5) );
std::cout << boost::geometry::dsv(poly) << std::endl;
return 0;
}