Error when clipping an open path with a closed path
Polygon and line clipping and offsetting library (C++, C#, Delphi)
Brought to you by:
angusj
For some non trivial open paths, the diff (clip) between an open line and a closed polygon can give some bad open lines as result.
As an example, 3 files are given, the first one is a gnuplot script for visualisation of the paths, the second and third are 2 examples of paths with the resulting data of the clipper "Execute".
My (python) code for evaluating the clipping of the open path:
c = ClipperLib.Clipper()
c.AddPath(clipper_path, ClipperLib.PolyType.ptSubject, False) # open path
c.AddPaths(clipper_polygons_path, ClipperLib.PolyType.ptClip, True) # closed polygon
polytree = ClipperLib.PolyTree()
c.Execute(ClipperLib.ClipType.ctDifference,
polytree,
ClipperLib.PolyFillType.pftNonZero,
ClipperLib.PolyFillType.pftNonZero)
paths = ClipperLib.PathVector()
ClipperLib.OpenPathsFromPolyTree(polytree, paths)
return paths
Anonymous