Horizontal line segments in a open subject path are reversed in the solution
Polygon and line clipping and offsetting library (C++, C#, Delphi)
Brought to you by:
angusj
using ClipperLib;
using Path = List<IntPoint>;
using Paths = List<List<IntPoint>>;
Path subj = new Path();
subj.Add(new IntPoint(64332, 43978));
subj.Add(new IntPoint(63972, 43978));
//subj.Add(new IntPoint(63972, 43979)); change previous point? Not horizontal anymore
subj.Add(new IntPoint(63887, 43954));
subj.Add(new IntPoint(63887, 47093));
subj.Add(new IntPoint(63887, 47986));
Paths clip = new Paths(1);
clip.Add(new Path(4));
clip[0].Add(new IntPoint(60000, 47831));
clip[0].Add(new IntPoint(70000, 47831));
clip[0].Add(new IntPoint(70000, 40000));
clip[0].Add(new IntPoint(60000, 40000));
PolyTree solution = new PolyTree();
Clipper c = new Clipper();
c.AddPath(subj, PolyType.ptSubject, false);
c.AddPaths(clip, PolyType.ptClip, true);
c.Execute(ClipType.ctIntersection, solution);
Paths insidePath = Clipper.OpenPathsFromPolyTree(solution);
Hello Angus,
I discovered a bug when clipping open subject paths that contain a horizontal line segment. In the included example, the horizontal segment is reversed in the solution path. By changing the horizontal segment to a almost horizontal segment (Y+1), the order of the points in the solution becomes correct. Can you please have a look at this bug?
Anonymous
Im using the C# version of ClipperLib version 6.4.2
A (non-practical) workaround for the issue is to invert all Ys of all polygons, also of the results.
Thanks for the feedback, and I'm sorry it's taken me so long to reply.
Yes, there's a bug here that I hope to fix in the next few days. Cheers.