public void Render(LineSegment segment) { if (!homed) { Home(); Start(); } if (!this.headingKnown || (this.heading != segment.Heading)) { OrientCutter(segment); } Move(segment, "Move"); Plunge(); Cut(segment, "Cut"); Retract(); }
private void OrientCutter(LineSegment segment) { LineSegment orientSegment = new LineSegment(new Point(xScratchOrigin, yScratchOrigin), segment.Heading, 5); Move(orientSegment, "Move to cutter orientation area", true); Plunge(); Cut(orientSegment, "Orient cutter to heading of " + GCodeDouble(segment.Heading), true); Retract(); this.heading = orientSegment.Heading; this.headingKnown = true; }
private void Move(LineSegment segment, string comment, bool ignoreCutterDiameter = false) { if (this.zHeight != MoveHeight) throw new CutterException("Lockout on Move due to incorrect Z Height"); if (PreMoveDistance > 0) { var preMovePoint = MathHelper.CalcEndPoint(segment.Start, (segment.Heading + 180) % 360, PreMoveDistance); Write("G1 X" + GCodeDouble(preMovePoint.X) + " Y" + GCodeDouble(preMovePoint.Y) + " F" + GCodeInt(MoveSpeed), "PreMove point"); } double distance; if (ignoreCutterDiameter) distance = 0; else distance = (CutterDiameter / 2) - preStartDistance; var toolPoint = MathHelper.CalcEndPoint(segment.Start, segment.Heading, distance); Write("G1 X" + GCodeDouble(toolPoint.X) + " Y" + GCodeDouble(toolPoint.Y) + " F" + GCodeInt(MoveSpeed), comment); this.toolPoint.Update(toolPoint); this.cutterPoint.Update(segment.Start); }
private void Cut(LineSegment segment, string comment, bool ignoreCutterDiameter = false) { if ((segment.Start.X != this.cutterPoint.X) || (segment.Start.Y != this.cutterPoint.Y)) throw new CutterException("Lockout on Cut due to incorrect cutter position"); if (this.zHeight != CutHeight) throw new CutterException("Lockout on Cut due to incorrect Z Height"); double h2; if (ignoreCutterDiameter) h2 = segment.Length; else h2 = segment.Length + (CutterDiameter / 2) + PostEndDistance; var toolEndPoint = MathHelper.CalcEndPoint(segment.Start, segment.Heading, h2); Write("G1 X" + GCodeDouble(toolEndPoint.X) + " Y" + GCodeDouble(toolEndPoint.Y) + " F" + GCodeInt(CutSpeed), comment); this.toolPoint.Update(toolEndPoint); this.cutterPoint.Update(segment.End); }
public static void LineSegment(this Canvas canvas, StencilG.LineSegment lineSegment, double scale) { DrawLine(canvas, lineSegment.Start.X * scale, lineSegment.Start.Y * scale, lineSegment.End.X * scale, lineSegment.End.Y * scale, Colors.Black); }