public static Polyline[] Intersection(IEnumerable <Polyline> a, IEnumerable <Polyline> b) { Clipper clipper = new Clipper(Clipper.ioStrictlySimple); clipper.AddPaths(a.ToRegions(), PolyType.ptClip, true); clipper.AddPaths(b.ToRegions(), PolyType.ptSubject, true); PolyTree tree = new PolyTree(); clipper.Execute(ClipType.ctIntersection, tree); double height = b.First()[0].Z; return(tree.ToPolylines(height)); }
public static Polyline Offset(Polyline polyline, double distance) { if (polyline.Count < 2) { return(new Polyline()); } var region = polyline.ToRegion(); var offset = new ClipperOffset(); offset.AddPath(region, JoinType.jtRound, EndType.etClosedPolygon); PolyTree tree = new PolyTree(); offset.Execute(ref tree, distance / Tol); var height = polyline[0].Z; var first = tree.ToPolylines(height).MaxBy(p => p.Length).FirstOrDefault(); return(first ?? new Polyline(0)); }