void emit_linear(GCodeLine line) { Debug.Assert(line.code == 1); double dx = 0, dy = 0; bool brelx = GCodeUtil.TryFindParamNum(line.parameters, "XI", ref dx); bool brely = GCodeUtil.TryFindParamNum(line.parameters, "YI", ref dy); LinearMoveData move = new LinearMoveData(new Vector2d(dx, dy)); if (brelx || brely) { listener.LinearMoveToRelative2d(move); return; } double x = 0, y = 0; bool absx = GCodeUtil.TryFindParamNum(line.parameters, "X", ref x); bool absy = GCodeUtil.TryFindParamNum(line.parameters, "Y", ref y); if (absx && absy) { listener.LinearMoveToAbsolute2d(move); return; } // [RMS] can we have this?? if (absx || absy) { System.Diagnostics.Debug.Assert(false); } }
public virtual void LinearMoveToAbsolute3d(LinearMoveData move) { if (ActivePath == null) { throw new Exception("GCodeToLayerPaths.LinearMoveToAbsolute3D: ActivePath is null!"); } // if we are doing a Z-move, convert to 3D path bool bZMove = (ActivePath.VertexCount > 0 && ActivePath.End.Position.z != move.position.z); if (bZMove) { ActivePath.ChangeType(ToolpathTypes.PlaneChange); } PrintVertex vtx = new PrintVertex( move.position, move.rate, PathDimensions, move.extrude.x); if (move.source != null) { vtx.Source = move.source; } ActivePath.AppendVertex(vtx, TPVertexFlags.None); }
public void LinearMoveToRelative2d(LinearMoveData move) { Vector2d P2 = P + move.position.xy; Complex.Add(new Segment2d(P, P2)); P = P2; }
public void LinearMoveToAbsolute2d(LinearMoveData move) { Vector2d P2 = move.position.xy; Complex.Add(new Segment2d(P, P2)); P = P2; }
public void LinearMoveToAbsolute3d(LinearMoveData move) { if (ActivePath == null) { throw new Exception("GCodeToLayerPaths.LinearMoveToAbsolute3D: ActivePath is null!"); } // if we are doing a Z-move, convert to 3D path bool bZMove = (ActivePath.VertexCount > 0 && ActivePath.End.z != move.position.z); if (bZMove) { ActivePathType = ToolpathTypes.PlaneChange; } ActivePath.AppendVertex(move.position); }
public virtual void LinearMoveToRelative2d(LinearMoveData move) { throw new NotImplementedException(); }
void emit_linear(GCodeLine line) { Debug.Assert(line.code == 0 || line.code == 1); double x = GCodeUtil.UnspecifiedValue, y = GCodeUtil.UnspecifiedValue, z = GCodeUtil.UnspecifiedValue; bool found_x = GCodeUtil.TryFindParamNum(line.parameters, "X", ref x); bool found_y = GCodeUtil.TryFindParamNum(line.parameters, "Y", ref y); bool found_z = GCodeUtil.TryFindParamNum(line.parameters, "Z", ref z); Vector3d newPos = (UseRelativePosition) ? Vector3d.Zero : CurPosition; if (found_x) { newPos.x = x; } if (found_y) { newPos.y = y; } if (found_z) { newPos.z = z; } if (UseRelativePosition) { CurPosition += newPos; } else { CurPosition = newPos; } // F is feed rate (this changes?) double f = 0; bool haveF = GCodeUtil.TryFindParamNum(line.parameters, "F", ref f); LinearMoveData move = new LinearMoveData( newPos, (haveF) ? f : GCodeUtil.UnspecifiedValue); bool is_travel = (line.code == 0); if (is_travel) { if (in_travel == false) { listener.BeginTravel(); in_travel = true; in_cut = false; } } else { if (in_cut == false) { listener.BeginCut(); in_travel = false; in_cut = true; } } move.source = line; Debug.Assert(in_travel || in_cut); listener.LinearMoveToAbsolute3d(move); }
public void LinearMoveToAbsolute2d(LinearMoveData move) { throw new NotImplementedException(); }
public void LinearMoveToRelative3d(LinearMoveData move) { throw new NotSupportedException(); }
public void LinearMoveToAbsolute3d(LinearMoveData move) { throw new NotSupportedException(); }
protected virtual void EmitLinear(GCodeLine line) { Debug.Assert(line.Code == 0 || line.Code == 1); double x = GCodeUtil.UnspecifiedValue, y = GCodeUtil.UnspecifiedValue, z = GCodeUtil.UnspecifiedValue; bool found_x = GCodeUtil.TryFindParamNum(line.Parameters, "X", ref x); bool found_y = GCodeUtil.TryFindParamNum(line.Parameters, "Y", ref y); bool found_z = GCodeUtil.TryFindParamNum(line.Parameters, "Z", ref z); Vector3d newPos = (UseRelativePosition) ? Vector3d.Zero : CurPosition; if (found_x) { newPos.x = x; } if (found_y) { newPos.y = y; } if (found_z) { newPos.z = z; } if (UseRelativePosition) { CurPosition += newPos; } else { CurPosition = newPos; } // F is feed rate (this changes?) double f = 0; bool haveF = GCodeUtil.TryFindParamNum(line.Parameters, "F", ref f); // A is extrusion stepper. E is also "current" stepper. double a = 0; bool haveA = GCodeUtil.TryFindParamNum(line.Parameters, "A", ref a); if (haveA == false) { haveA = GCodeUtil.TryFindParamNum(line.Parameters, "E", ref a); } if (UseRelativeExtruder) { a = ExtrusionA + a; } LinearMoveData move = new LinearMoveData( newPos, (haveF) ? f : GCodeUtil.UnspecifiedValue, (haveA) ? GCodeUtil.Extrude(a) : GCodeUtil.UnspecifiedPosition); if (haveA == false) { // if we do not have extrusion, this is a travel move if (in_travel == false) { listener.BeginTravel(); in_travel = true; in_extrude = false; } } else if (in_retract) { // if we are in retract, we stay in until we see forward movement Debug.Assert(in_travel); Debug.Assert(a <= LastRetractA + 0.001); if (MathUtil.EpsilonEqual(a, LastRetractA, 0.00001)) { in_retract = false; listener.BeginDeposition(); in_extrude = true; in_travel = false; ExtrusionA = a; } } else if (a < ExtrusionA) { // if extrusion moved backwards, we need to enter travel in_retract = true; LastRetractA = ExtrusionA; ExtrusionA = a; if (in_travel == false) { listener.BeginTravel(); in_travel = true; in_extrude = false; } } else { // if we are in travel, we need to begin extruding if (in_travel) { listener.BeginDeposition(); in_travel = false; in_extrude = true; } if (in_extrude == false) { // handle initialization cases listener.BeginDeposition(); in_extrude = true; } ExtrusionA = a; } move.source = line; Debug.Assert(in_travel || in_extrude); listener.LinearMoveToAbsolute3d(move); }