public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if ((renderInfo.CurrentRenderType & RenderType.Moves) == RenderType.Moves) { double movementLineWidth = 0.35 * renderInfo.LayerScale; RGBA_Bytes movementColor = new RGBA_Bytes(10, 190, 15); PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, movementLineWidth); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); if (end.x != start.x || end.y != start.y) { pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } else { pathStorage.Add(end.x + .01, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } graphics2D.Render(stroke, 0, movementColor); } }
public static PathStorage PolygonToPathStorage(Polygons polygons) { PathStorage output = new PathStorage(); foreach (Polygon polygon in polygons) { bool first = true; foreach (IntPoint point in polygon) { if (first) { output.Add(point.X, point.Y, ShapePath.FlagsAndCommand.CommandMoveTo); first = false; } else { output.Add(point.X, point.Y, ShapePath.FlagsAndCommand.CommandLineTo); } } output.ClosePolygon(); } output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop); return(output); }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if ((renderInfo.CurrentRenderType & RenderType.Extrusions) == RenderType.Extrusions) { double extrusionLineWidths = GetRadius(renderInfo.CurrentRenderType) * 2 * renderInfo.LayerScale; RGBA_Bytes extrusionColor = RGBA_Bytes.Black; if (extruderIndex > 0) { extrusionColor = MeshViewerWidget.GetMaterialColor(extruderIndex + 1); } if ((renderInfo.CurrentRenderType & RenderType.SpeedColors) == RenderType.SpeedColors) { extrusionColor = color; } PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); graphics2D.Render(stroke, 0, extrusionColor); } }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if (renderInfo.CurrentRenderType.HasFlag(RenderType.Extrusions)) { double extrusionLineWidths = GetExtrusionWidth(renderInfo.CurrentRenderType) * 2 * renderInfo.LayerScale; RGBA_Bytes extrusionColor = RGBA_Bytes.Black; if (extruderIndex > 0) { extrusionColor = MeshViewerWidget.GetMaterialColor(extruderIndex + 1); } if (renderInfo.CurrentRenderType.HasFlag(RenderType.SpeedColors)) { extrusionColor = color; } if (renderInfo.CurrentRenderType.HasFlag(RenderType.TransparentExtrusion)) { extrusionColor = new RGBA_Bytes(extrusionColor, 200); } // render the part using opengl Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL; if (graphics2DGl != null) { Vector3Float startF = this.GetStart(renderInfo); Vector3Float endF = this.GetEnd(renderInfo); Vector2 start = new Vector2(startF.x, startF.y); renderInfo.Transform.transform(ref start); Vector2 end = new Vector2(endF.x, endF.y); renderInfo.Transform.transform(ref end); graphics2DGl.DrawAALineRounded(start, end, extrusionLineWidths / 2, extrusionColor); } else { PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths / 2); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); graphics2D.Render(stroke, 0, extrusionColor); } } }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if ((renderInfo.CurrentRenderType & RenderType.Moves) == RenderType.Moves) { double movementLineWidth = 0.35 * renderInfo.LayerScale; RGBA_Bytes movementColor = new RGBA_Bytes(10, 190, 15); // render the part using opengl Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL; if (graphics2DGl != null) { Vector3Float startF = this.GetStart(renderInfo); Vector3Float endF = this.GetEnd(renderInfo); Vector2 start = new Vector2(startF.x, startF.y); renderInfo.Transform.transform(ref start); Vector2 end = new Vector2(endF.x, endF.y); renderInfo.Transform.transform(ref end); graphics2DGl.DrawAALineRounded(start, end, movementLineWidth, movementColor); } else { PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, movementLineWidth); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); if (end.x != start.x || end.y != start.y) { pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } else { pathStorage.Add(end.x + .01, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } graphics2D.Render(stroke, 0, movementColor); } } }
private PathStorage CombinePaths(IVertexSource a, IVertexSource b, ClipType clipType) { List <List <IntPoint> > aPolys = CreatePolygons(a); List <List <IntPoint> > bPolys = CreatePolygons(b); Clipper clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >(); clipper.Execute(clipType, intersectedPolys); PathStorage output = new PathStorage(); foreach (List <IntPoint> polygon in intersectedPolys) { bool first = true; foreach (IntPoint point in polygon) { if (first) { output.Add(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo); first = false; } else { output.Add(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo); } } output.ClosePolygon(); } output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop); return(output); }
public static PathStorage CreatePathStorage(List <List <IntPoint> > intersectedPolys, double scaling = 1000) { PathStorage output = new PathStorage(); foreach (List <IntPoint> polygon in intersectedPolys) { bool first = true; foreach (IntPoint point in polygon) { if (first) { output.Add(point.X / scaling, point.Y / scaling, ShapePath.FlagsAndCommand.CommandMoveTo); first = false; } else { output.Add(point.X / scaling, point.Y / scaling, ShapePath.FlagsAndCommand.CommandLineTo); } } output.ClosePolygon(); } return(output); }
private PathStorage CombinePaths(IVertexSource a, IVertexSource b, ClipType clipType) { List <List <IntPoint> > aPolys = VertexSourceToClipperPolygons.CreatePolygons(a); List <List <IntPoint> > bPolys = VertexSourceToClipperPolygons.CreatePolygons(b); Clipper clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >(); clipper.Execute(clipType, intersectedPolys); PathStorage output = VertexSourceToClipperPolygons.CreatePathStorage(intersectedPolys); output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop); return(output); }
private void CreateAndRenderPathing(Graphics2D graphics2D, Polygons polygonsToPathAround, Polygons travelPolysLine) { Polygons travelPolygons = CreateTravelPath(polygonsToPathAround, travelPolysLine); PathStorage travelPath = VertexSourceToClipperPolygons.CreatePathStorage(travelPolygons); travelPath.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop); graphics2D.Render(new Stroke(travelPath), pathColor); //graphics2D.Render(optomizedTravelPath, optomizedPpathColor); foreach (Polygon polygon in polygonsToPathAround) { for (int i = 0; i < polygon.Count; i++) { if (!polygon.IsVertexConcave(i)) { graphics2D.Circle(polygon[i].X, polygon[i].Y, 4, RGBA_Bytes.Green); } } } }