Search code examples
c++boostboost-geometry

Offsetting polygon using Boost.Geometry?


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://stackoverflow.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.


Solution

  • 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