Boost logo

Boost Users :

Subject: Re: [Boost-users] Geometry: modifiable?
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-07-23 07:25:41


Hi,

Jeremy Murphy wrote:
>
> Is there a generic way to modify geometry structurally? Say if I have
> a ring and I want to insert a new point? Or would I need to reach into
> the underlying container to make that kind of change?
> Thanks, cheers.
> Jeremy
>

It depends on your needs. Internally Boost.Geometry uses and therefore
requires 3 traits for mutable ranges (see here:
https://github.com/boostorg/geometry/blob/master/include/boost/geometry/core/mutable_range.hpp):
bg::traits::clear<>
bg::traits::push_back<>
bg::traits::resize<>
Or added in 1.56
bg::range::clear()
So if you'd like to contribute your work back to Boost.Geometry your
code should use them.

You may also use one of the provided functions:
- append()
(http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/append.html)
- assign_points()
(http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/assign/assign_points.html)

However if you're planning to implement some algorithm for your purpose
only you may use whatever methods you like.
e.g. model::ring<> has methods of std::vector<>.
But notice that if you do it this way, then you wouldn't be able to use
some other class adapted to the Ring concept.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net