Geometry: modifiable?
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
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...): 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/referen...) - assign_points() (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/referen...) 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.
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
You may use one of the provided functions: - append() (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/referen...) - assign_points() (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/referen...) - clear() (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/referen...) And in case you wanted to modify only one ring of a Polygon, there are also: - exterior_ring() (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/referen...) - interior_rings() (http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/referen...) Regards, Adam
Hey Adam, thanks again for your generous and helpful answers. At the moment I'm copying the geometry into a different data structure so that I can easily modify it as I couldn't see a way to easily do insertions with the generic API. Jeremy
participants (2)
-
Adam Wulkiewicz
-
Jeremy Murphy