c++clipperlib

Clipping Open Paths in Clipper Library


In Clipper, given an open path (black) and a closed polygon (blue), how can I clip the open path such that the clipped parts get completed using the polygon contours and, when possible, a single path remains instead of disjoint segments?
What Clipper operations can achieves this?

enter image description here

Note that the clipping polygon is not necessarily a rectangle like in the example, so the completed segments may be polylines themselves.


Solution

  • Based on this thread it is not possible to do so for open paths.

    However, if the open subject path can be closed with a closing path (which is not always guaranteed to be possible), then intersecting/clipping it and then removing the closing path segments will leave the desired results.