As far as I know, boost polygon is represented as a STL vector. This is not convenient for when a new point needs to be added at a specific index of the polygon, as this is linear complexity.
Is there a way how to make boost use a list representation or otherwise solve the problem of adding a point to an index of the polygon in constant time?
The whole point of the Boost Geometry Design Rationale is to program to concepts, not models.
The default model of a polygon you describe indeed uses std::vector
, but you can use any model - including your own types or third party types, given some adaption.
So, without further ado, use the builtin model with a list:
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <list>
int main() {
using namespace boost::geometry;
using Point = model::d2::point_xy<double>;
model::polygon<Point, true, true, std::list> p;
}