4

Related Question:
An algorithm for inflating/deflating (offsetting, buffering) polygons

The difference is that I'm searching for a way to inflate a given polyline into a polygon:

polyline with a box around

I've got the following input:

  • List of 2D Points which form the polyline (bright green in the sketch)
  • Width of the line

The output should be a polygon which shows how the line looks expanded by the width.

I originally thought I could use Boost::Geometry::buffer for that, unfortunately it just seems to support boxes for now. A solution using Boost::Geometry or GDAL/OGR would be preffered.

UPDATE:
I chose to use the Clipper Library and its OffsetPolyLines function. As soon as Boost Geometry is released with Polyline-Buffer support I'll switch to Boost (as everything else runs with Boost in my software).

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
MOnsDaR
  • 8,401
  • 8
  • 49
  • 70
  • It somehow looks like [Straight skeleton](http://en.wikipedia.org/wiki/Straight_skeleton), but with the inverse process. – Cyril Aug 27 '13 at 12:50

2 Answers2

3

I understand that the OP was preferring a solution in Boost::Geometry or GDAL/OGR but, in case others are following this thread, my Clipper library can also do polyline offsetting. (The soon to be released version 6 that's already in the SourceForge repository simplifies this and it now supports open path (polyline) clipping too.)

Angus Johnson
  • 4,565
  • 2
  • 26
  • 28
  • This is the solution I'll be using until Boost releases their enhanced Buffer algorithm. On a sidenote: Clipper does not seem to be Windows-compatible as declspec(dllexport) is missing. I added those and everything runs fine with VC90 and VC100 on Windows 7. – MOnsDaR Aug 28 '13 at 05:20
  • I confess I'm somewhat of a C++ newbie, but ISTM that declspec(dllexport) isn't required if you compile the source directly into your application. Are you really suggesting that I should include this to all the header functions?? Also, if you're just starting with Clipper I strongly recommend using ver 6 (from the SF repository) since it's a major update with a particular focus on supporting open paths (polylines). – Angus Johnson Aug 28 '13 at 06:17
  • Yes, I use the newest version from SF and OffsetPolyLines works fine. If you want to create a dynamic library (DLL) on Windows you need to use dllexport. It is not needed for static libraries. I'll send a patch to you next week. – MOnsDaR Aug 28 '13 at 13:51
  • 1
    OffsetPolyLines has been replaced with OffsetPaths in version 6. – Angus Johnson Aug 28 '13 at 15:51
2

Boost.Geometry extension (from Trunk) can do this. It is not yet released. It can buffer around polygons, polygons, points, and multi-geometries. You can specify sharp corners (miter) or rounded corners. It is not yet perfect, but lines as your sample above should not give any problems.

The released version (1.54) does not have this yet, and also the next one will not have it yet. So for now you have to use the Trunk (from SVN)

Barend Gehrels
  • 1,047
  • 6
  • 8