public List <LineStrip> GetRouts() { GL.PushMatrix(); Slice lastPolygon = null; foreach (var p in polygons) { var routLast = p.GetLines(Slice.LineType.Outside).First(s => true); routLast.Vertices.Add(routLast.Vertices[0]); routLast.Vertices.Reverse(); Slice obliterate = new Slice(p); obliterate.Offset(-toolRadius * cleanRoutFactor); var routFirst = PathTree.ObliterateSlice(obliterate, toolRadius * 2.0f, true); if (lastPolygon == null) { lastPolygon = p; } bool first = true; foreach (var rout in routFirst) { first = true; foreach (var point in rout.Vertices) { AddRoutPoint(lastPolygon, point, first); first = false; } } first = true; foreach (var point in routLast.Vertices) { AddRoutPoint(p, point, first); first = false; } lastPolygon = p; } GL.PopMatrix(); return(routs); }
private static List <LineStrip> RoutAreasWithHolesHelper(Slice polygons, float toolRadius, float cleanPassFactor, List <Tabs> tabs, bool inside) { List <LineStrip> paths = new List <LineStrip>(); Slice.LineType firstLineType = Slice.LineType.Hole; Slice.LineType lastLineType = Slice.LineType.Outside; float offset = toolRadius * cleanPassFactor; if (inside) { firstLineType = Slice.LineType.Outside; lastLineType = Slice.LineType.Hole; offset = -offset; } // The holes are the paths surrounding the final object - rout them last for the cleanest finish. // Also avoid any tabs that may exist on these paths. Slice lastPaths = new Slice(polygons.GetLines(firstLineType), polygons.Plane); var routLast = lastPaths.GetLines(Slice.LineType.All); foreach (var line in routLast) { var fixedLine = line; foreach (Tabs t in tabs) { fixedLine = t.AvoidTabs(fixedLine); } paths.Add(fixedLine); } // Compute the rest of the routs required to remove the material. Do these first - they will // be a distance away from the final product, so if forces push the bit around some, there's no issue. // Also avoid tabs on these paths. lastPaths.Offset(offset); Slice obliterate = new Slice(polygons.GetLines(lastLineType), polygons.Plane); if (inside) { obliterate.SubtractFrom(lastPaths); } else { obliterate.Subtract(lastPaths); } //DrawSlice(Color.Orange, Color.Red, obliterate); var lines = PathTree.ObliterateSlice(obliterate, toolRadius); foreach (var line in lines) { var fixedLine = line; foreach (Tabs t in tabs) { fixedLine = t.AvoidTabs(fixedLine); } paths.Insert(0, fixedLine); } return(paths); }