1
votes

The Boost Polygon library states that it is possible to offset polygons(symmetrically ).But I haven't found any method in the API or example of how to do it .Anyone can confirm that Boost geometry can do it? Also I have found this question :

https://stackguides.com/questions/7668331/outline-of-a-polygon-in-boost Which seems to be asking the similar question. Please keep in mind that libs like Polygon Clipper can do it wonderfully but my point of interest in Boost is that it is fast and it supports floats. Thanks for help.

UPDATE: I am talking about both Boost geometry and polygons library because I am not sure which one contains or lacks this feature.

3
Are you talking about the polygon library or the geometry library? You use both words. The geometry library has the algorithm buffer which may be what you mean by "offset". If not, please clarify. - Peter
Yes ,you are right. In fact I don't know which one is correct because I found no info or example of the usage. - Michael IV
Let me rephrase. What do you mean by "symmetrically offset"? - Peter
I mean that the offset distance from any point on the polygon edge is the same. In other words under "offset" I mean outline :) - Michael IV

3 Answers

5
votes

According to the boost doc: Boost buffer algorithm This is not currently available for general polygons: "The current implemetation only enlarges a box, which is not defined by OGC. A next version of the library will contain a more complete implementation"

2
votes

The relevant functions are resize and its variants bloat and shrink.

2
votes

Using boost geometry, the function you want is called buffer. From the docs:

buffer

Calculates the buffer of a geometry.

Description

The free function buffer calculates the buffer (a polygon being the spatial point set collection within a specified maximum distance from a geometry) of a geometry.

http://www.boost.org/doc/libs/1_49_0/libs/geometry/doc/html/geometry/reference/algorithms.html