Menu

#211 Error when clipping an open path with a closed path

*
open
nobody
None
1
2022-01-14
2022-01-14
Anonymous
No

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
3 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel