コード例 #1
0
        public override JobCreateResult Create(PrinterInfo printerInfo)
        {
            Status = JobStatus.SavingToFile;
            JobCreateResult jobCreateResult = base.Create(printerInfo);

            if (jobCreateResult.Result == ProcessReturn.SUCCESS)
            {
                try
                {
                    using (var gcodeFileReader = new GCodeFileReader(GCodeFilename))
                    {
                        using (var gcodeFileWriter = new GCodeFileWriter(Details.jobParams.outputfile, true))
                        {
                            GCode nextLine;
                            while ((nextLine = gcodeFileReader.GetNextLine(true)) != null)
                            {
                                gcodeFileWriter.Write(nextLine);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    jobCreateResult.Result = ProcessReturn.FAILURE;
                }
            }
            return(jobCreateResult);
        }
コード例 #2
0
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            UpdateConfigurations(calibration, printerProfile.PrinterSizeConstants);
            var flag1    = true;
            var flag2    = true;
            var flag3    = false;
            var flag4    = false;
            var num1     = 0;
            var num2     = 0;
            var num3     = 0.0;
            var position = new Position();
            var num4     = (float)num3;
            var num5     = 0.0f;

            while (true)
            {
                GCode nextLine = input_reader.GetNextLine(false);
                if (nextLine != null)
                {
                    if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && !flag1)
                    {
                        if (nextLine.HasX || nextLine.HasY)
                        {
                            flag4 = true;
                        }

                        if (nextLine.HasZ)
                        {
                            nextLine.Z += entire_z_height_offset;
                        }

                        var num6 = !nextLine.HasX ? 0.0f : nextLine.X - position.relativeX;
                        var num7 = !nextLine.HasY ? 0.0f : nextLine.Y - position.relativeY;
                        var num8 = !nextLine.HasZ ? 0.0f : nextLine.Z - position.relativeZ;
                        var num9 = !nextLine.HasE ? 0.0f : nextLine.E - position.relativeE;
                        position.absoluteX += num6;
                        position.absoluteY += num7;
                        position.absoluteZ += num8;
                        position.absoluteE += num9;
                        position.relativeX += num6;
                        position.relativeY += num7;
                        position.relativeZ += num8;
                        position.relativeE += num9;
                        if (nextLine.hasF)
                        {
                            position.F = nextLine.F;
                        }

                        if (num8 > 1.40129846432482E-45 || num8 < -1.40129846432482E-45)
                        {
                            if (!flag3)
                            {
                                num2 = 1;
                            }
                            else
                            {
                                ++num2;
                            }

                            flag2 = num2 == 0 || num2 == 1;
                        }
                        var num10 = (float)Math.Sqrt(num6 * (double)num6 + num7 * (double)num7);
                        var num11 = 1;
                        if (num10 > 2.0)
                        {
                            num11 = (int)(num10 / 2.0);
                        }

                        var num12 = position.absoluteX - num6;
                        var num13 = position.absoluteY - num7;
                        var num14 = position.relativeX - num6;
                        var num15 = position.relativeY - num7;
                        var num16 = position.relativeZ - num8;
                        var num17 = position.relativeE - num9;
                        var num18 = num6 / num10;
                        var num19 = num7 / num10;
                        var num20 = num8 / num10;
                        var num21 = num9 / num10;
                        if (num9 > 0.0)
                        {
                            flag3 = true;
                        }

                        var num22 = flag2 ? 1 : 0;
                        if (num9 > 0.0)
                        {
                            for (var index = 1; index < num11 + 1; ++index)
                            {
                                float x;
                                float y;
                                float num23;
                                float num24;
                                float num25;
                                float num26;
                                if (index == num11)
                                {
                                    x     = position.absoluteX;
                                    y     = position.absoluteY;
                                    num23 = position.relativeX;
                                    num24 = position.relativeY;
                                    num25 = position.relativeZ;
                                    num26 = position.relativeE;
                                }
                                else
                                {
                                    x     = num12 + index * 2f * num18;
                                    y     = num13 + index * 2f * num19;
                                    num23 = num14 + index * 2f * num18;
                                    num24 = num15 + index * 2f * num19;
                                    num25 = num16 + index * 2f * num20;
                                    num26 = num17 + index * 2f * num21;
                                }
                                var adjustmentRequired = GetHeightAdjustmentRequired(x, y);
                                if (index != num11)
                                {
                                    var code = new GCode
                                    {
                                        G = nextLine.G
                                    };
                                    if (nextLine.HasX)
                                    {
                                        code.X = (float)(position.relativeX - (double)num6 + (num23 - (double)num14));
                                    }

                                    if (nextLine.HasY)
                                    {
                                        code.Y = (float)(position.relativeY - (double)num7 + (num24 - (double)num15));
                                    }

                                    if (nextLine.hasF && index == 1)
                                    {
                                        code.F = nextLine.F;
                                    }

                                    if (flag4)
                                    {
                                        code.Z = (float)(position.relativeZ - (double)num8 + (num25 - (double)num16)) + adjustmentRequired;
                                    }
                                    else if (nextLine.HasZ && (num8 > 1.40129846432482E-45 || num8 < -1.40129846432482E-45))
                                    {
                                        code.Z = (float)(position.relativeZ - (double)num8 + (num25 - (double)num16));
                                    }

                                    code.E = (float)(position.relativeE - (double)num9 + (num26 - (double)num17)) + num4;
                                    output_writer.Write(code);
                                }
                                else
                                {
                                    if (flag4)
                                    {
                                        if (nextLine.HasZ)
                                        {
                                            nextLine.Z += adjustmentRequired;
                                        }
                                        else
                                        {
                                            nextLine.Z = num16 + num8 + adjustmentRequired;
                                        }
                                    }
                                    nextLine.E += num4;
                                }
                                num5 = num26;
                            }
                        }
                        else
                        {
                            if (flag4)
                            {
                                var num23 = flag2 ? 1 : 0;
                                var adjustmentRequired = GetHeightAdjustmentRequired(position.absoluteX, position.absoluteY);
                                if (nextLine.HasZ)
                                {
                                    nextLine.Z += adjustmentRequired;
                                }
                                else
                                {
                                    nextLine.Z = position.relativeZ + adjustmentRequired;
                                }
                            }
                            if (nextLine.HasE)
                            {
                                nextLine.E += num4;
                            }

                            num5 = position.relativeE;
                        }
                    }
                    else if (nextLine.HasG && nextLine.G == 92)
                    {
                        if (nextLine.HasE)
                        {
                            position.relativeE = nextLine.E;
                        }

                        if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                        {
                            if (nextLine.HasX)
                            {
                                position.relativeX = nextLine.X;
                            }

                            if (nextLine.HasY)
                            {
                                position.relativeY = nextLine.Y;
                            }

                            if (nextLine.HasZ)
                            {
                                position.relativeZ = nextLine.Z;
                            }
                        }
                        if (!nextLine.HasE && !nextLine.HasX && (!nextLine.HasY && !nextLine.HasZ))
                        {
                            position.relativeE = 0.0f;
                            if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                            {
                                position.relativeX = 0.0f;
                                position.relativeY = 0.0f;
                                position.relativeZ = 0.0f;
                            }
                        }
                    }
                    else if (nextLine.HasG && nextLine.G == 90)
                    {
                        flag1 = false;
                    }
                    else if (nextLine.HasG && nextLine.G == 91)
                    {
                        flag1 = true;
                    }
                    else if (nextLine.HasG && nextLine.G == 28)
                    {
                        position.relativeX = position.absoluteX = 54f;
                        position.relativeY = position.absoluteY = 50f;
                    }
                    output_writer.Write(nextLine);
                    ++num1;
                }
                else
                {
                    break;
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: BackLashPreprocessor.cs プロジェクト: urish/M3D
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            var backlashX = calibration.BACKLASH_X;
            var backlashY = calibration.BACKLASH_Y;
            var flag      = true;
            var position  = new Position();
            var num1      = 1000f;

            BackLashPreprocessor.Direction direction1 = BackLashPreprocessor.Direction.Neither;
            BackLashPreprocessor.Direction direction2 = BackLashPreprocessor.Direction.Neither;
            var num2 = 0.0f;
            var num3 = 0.0f;

            for (GCode nextLine = input_reader.GetNextLine(false); nextLine != null; nextLine = input_reader.GetNextLine(false))
            {
                if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && !flag)
                {
                    if (nextLine.hasF)
                    {
                        num1 = nextLine.F;
                    }

                    var num4 = !nextLine.HasX ? 0.0f : nextLine.X - position.relativeX;
                    var num5 = !nextLine.HasY ? 0.0f : nextLine.Y - position.relativeY;
                    var num6 = !nextLine.HasZ ? 0.0f : nextLine.Z - position.relativeZ;
                    var num7 = !nextLine.HasE ? 0.0f : nextLine.E - position.relativeE;
                    BackLashPreprocessor.Direction direction3 = num4 <= 1.40129846432482E-45 ? num4 >= -1.40129846432482E-45 ? direction1 : BackLashPreprocessor.Direction.Negative : BackLashPreprocessor.Direction.Positive;
                    BackLashPreprocessor.Direction direction4 = num5 <= 1.40129846432482E-45 ? num5 >= -1.40129846432482E-45 ? direction2 : BackLashPreprocessor.Direction.Negative : BackLashPreprocessor.Direction.Positive;
                    var code = new GCode
                    {
                        G = nextLine.G
                    };
                    if (direction3 != direction1 && direction1 != BackLashPreprocessor.Direction.Neither || direction4 != direction2 && direction2 != BackLashPreprocessor.Direction.Neither)
                    {
                        if (direction3 != direction1 && direction1 != BackLashPreprocessor.Direction.Neither)
                        {
                            num2 += direction3 == BackLashPreprocessor.Direction.Positive ? backlashX : -backlashX;
                        }

                        if (direction4 != direction2 && direction2 != BackLashPreprocessor.Direction.Neither)
                        {
                            num3 += direction4 == BackLashPreprocessor.Direction.Positive ? backlashY : -backlashY;
                        }

                        var num8 = position.relativeX + num2;
                        var num9 = position.relativeY + num3;
                        code.X = num8;
                        code.Y = num9;
                        code.F = calibration.BACKLASH_SPEED;
                        output_writer.Write(code);
                        nextLine.F = num1;
                    }
                    if (nextLine.HasX)
                    {
                        nextLine.X += num2;
                    }

                    if (nextLine.HasY)
                    {
                        nextLine.Y += num3;
                    }

                    position.relativeX += num4;
                    position.relativeY += num5;
                    position.relativeZ += num6;
                    position.relativeE += num7;
                    if (nextLine.hasF)
                    {
                        position.F = nextLine.F;
                    }

                    position.absoluteX += num4;
                    position.absoluteY += num5;
                    position.absoluteZ += num6;
                    position.absoluteE += num7;
                    direction1          = direction3;
                    direction2          = direction4;
                }
                else if (nextLine.HasG && nextLine.G == 92)
                {
                    if (nextLine.HasE)
                    {
                        position.relativeE = nextLine.E;
                    }

                    if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                    {
                        if (nextLine.HasX)
                        {
                            position.relativeX = nextLine.X;
                        }

                        if (nextLine.HasY)
                        {
                            position.relativeY = nextLine.Y;
                        }

                        if (nextLine.HasZ)
                        {
                            position.relativeZ = nextLine.Z;
                        }
                    }
                    if (!nextLine.HasE && !nextLine.HasX && (!nextLine.HasY && !nextLine.HasZ))
                    {
                        position.relativeE = 0.0f;
                        if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                        {
                            position.relativeX = 0.0f;
                            position.relativeY = 0.0f;
                            position.relativeZ = 0.0f;
                        }
                    }
                }
                else if (nextLine.HasG && nextLine.G == 90)
                {
                    flag = false;
                }
                else if (nextLine.HasG && nextLine.G == 91)
                {
                    flag = true;
                }
                else if (nextLine.HasG && nextLine.G == 28)
                {
                    position.relativeX = position.absoluteX = 54f;
                    position.relativeY = position.absoluteY = 50f;
                }
                output_writer.Write(nextLine);
            }
            return(true);
        }
コード例 #4
0
        private bool ProcessGCode_HelperLayerComments(GCodeFileReader input_reader, GCodeFileWriter output_writer, JobDetails jobdetails, InternalPrinterProfile printerProfile, InitialPrintPreProcessorData initial_print_settings)
        {
            var   flag1 = false;
            var   num1  = 0;
            var   num2  = 0;
            var   flag2 = false;
            var   flag3 = false;
            var   flag4 = false;
            var   flag5 = false;
            var   useFanPreprocessor = jobdetails.jobParams.options.use_fan_preprocessor;
            GCode nextLine;

            while ((nextLine = input_reader.GetNextLine(false)) != null)
            {
                if (nextLine.orig.StartsWith(";LAYER:"))
                {
                    if (nextLine.ToString().ToLower().Contains(";layer:-"))
                    {
                        flag5 = true;
                    }

                    flag1 = true;
                    flag2 = true;
                }
                else if (nextLine.HasZ & flag3 && !flag1)
                {
                    output_writer.Write(new GCode(";LAYER:" + num1++));
                    flag2 = true;
                }
                else if (nextLine.HasG)
                {
                    if (nextLine.G == 90)
                    {
                        flag3 = true;
                    }
                    else if (nextLine.G == 91)
                    {
                        flag3 = false;
                    }
                }
                if (!(nextLine.orig.ToLower() == "t0") && nextLine.orig.ToLower().IndexOf(" t0 ") <= -1 && (!nextLine.hasM || nextLine.M != 104 && nextLine.M != 109) && (!useFanPreprocessor || !nextLine.hasM || nextLine.M != 106 && nextLine.M != 107))
                {
                    var flag6 = false;
                    if (nextLine.orig.StartsWith(";LAYER:"))
                    {
                        output_writer.Write(nextLine);
                        flag6 = true;
                    }
                    if (flag2)
                    {
                        int num3;
                        switch (num2)
                        {
                        case 0:
                            var layerTemperature = (float)initial_print_settings.FirstRaftLayerTemperature;
                            output_writer.Write(new GCode("M109 S" + layerTemperature.ToString()));
                            output_writer.Write(new GCode("G90"));
                            BoundingBox bounds = printerProfile.PrinterSizeConstants.WarningRegion.bounds_list[0];
                            output_writer.Write(new GCode(PrinterCompatibleString.Format("G0 X{0} Y{1} Z0.5 F3600", (float)((double)bounds.max.x - 1.0), (float)(((double)bounds.min.y + (double)bounds.max.y) / 2.0 + 10.0))));
                            output_writer.Write(new GCode("G91                  ;Go relative"));
                            output_writer.Write(new GCode(PrinterCompatibleString.Format("G0 E{0} F{1}          ;prime the nozzle", initial_print_settings.PrimeAmount, 72f)));
                            output_writer.Write(new GCode("G4 S0"));
                            output_writer.Write(new GCode("G92 E0               ;reset E"));
                            output_writer.Write(new GCode("G90                  ;Go absolute"));
                            goto label_22;

                        case 1:
                            num3 = initial_print_settings.SecondRaftResetTemp ? 1 : 0;
                            break;

                        default:
                            num3 = 0;
                            break;
                        }
                        var num4 = flag5 ? 1 : 0;
                        if ((num3 & num4) != 0)
                        {
                            var filamentTemperature = (float)jobdetails.jobParams.filament_temperature;
                            output_writer.Write(new GCode(";Reset to the ideal temperature"));
                            output_writer.Write(new GCode("M104 S" + filamentTemperature.ToString()));
                            flag4 = true;
                        }
label_22:
                        ++num2;
                        flag2 = false;
                    }
                    if (!flag4 && (flag5 && nextLine.ToString().ToLower() == ";layer:0" || !flag5 && num2 > 2 || num2 > 4))
                    {
                        var filamentTemperature = (float)jobdetails.jobParams.filament_temperature;
                        output_writer.Write(new GCode(";Reset to the ideal temperature"));
                        output_writer.Write(new GCode("M104 S" + filamentTemperature.ToString()));
                        flag4 = true;
                    }
                    if (!flag6)
                    {
                        output_writer.Write(nextLine);
                    }
                }
            }
            return(true);
        }
コード例 #5
0
ファイル: AbstractPreprocessedJob.cs プロジェクト: urish/M3D
        private AbstractPreprocessedJob.PrintJobWarning GatherInitialInformation(string filename, InternalPrinterProfile printerProfile)
        {
            GCodeFileReader gcodeFileReader;

            try
            {
                gcodeFileReader = new GCodeFileReader(filename);
                if (!gcodeFileReader.IsOpen)
                {
                    throw new Exception(string.Format("Unable to open file: {0}", filename));
                }
            }
            catch (ThreadAbortException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception("PrinterJob.GatherInitialInformation ", ex);
            }
            EstimatedFilamentUsed = 0.0f;
            if (gcodeFileReader != null)
            {
                var   boundsCheckXy = Details.jobParams.options.bounds_check_xy;
                var   flag          = false;
                var   p             = new Vector3D(float.NaN, float.NaN, float.NaN);
                GCode nextLine;
                while ((nextLine = gcodeFileReader.GetNextLine(false)) != null)
                {
                    if (nextLine.HasG)
                    {
                        if (nextLine.G == 90)
                        {
                            flag = true;
                        }
                        else if (nextLine.G == 91)
                        {
                            flag = false;
                        }
                        else if (((nextLine.G == 0 ? 1 : (nextLine.G == 1 ? 1 : 0)) & (flag ? 1 : 0)) != 0)
                        {
                            if (nextLine.HasE)
                            {
                                if (flag)
                                {
                                    EstimatedFilamentUsed = nextLine.E;
                                }
                                else
                                {
                                    EstimatedFilamentUsed += nextLine.E;
                                }
                            }
                            if (nextLine.HasZ)
                            {
                                p.z = nextLine.Z;
                                if (nextLine.Z < (double)Details.bounds.min.z)
                                {
                                    Details.bounds.min.z = nextLine.Z;
                                }

                                if (nextLine.Z > (double)Details.bounds.max.z)
                                {
                                    Details.bounds.max.z = nextLine.Z;
                                }
                            }
                            if (boundsCheckXy)
                            {
                                if (nextLine.HasX)
                                {
                                    p.x = nextLine.X;
                                    if (nextLine.X < (double)Details.bounds.min.x)
                                    {
                                        Details.bounds.min.x = nextLine.X;
                                    }

                                    if (nextLine.X > (double)Details.bounds.max.x)
                                    {
                                        Details.bounds.max.x = nextLine.X;
                                    }
                                }
                                if (nextLine.HasY)
                                {
                                    p.y = nextLine.Y;
                                    if (nextLine.Y < (double)Details.bounds.min.y)
                                    {
                                        Details.bounds.min.y = nextLine.Y;
                                    }

                                    if (nextLine.Y > (double)Details.bounds.max.y)
                                    {
                                        Details.bounds.max.y = nextLine.Y;
                                    }
                                }
                            }
                            if (!printerProfile.PrinterSizeConstants.PrintableRegion.InRegionNaN(p))
                            {
                                gcodeFileReader.Close();
                                return(AbstractPreprocessedJob.PrintJobWarning.Error_OutOfBounds);
                            }
                        }
                        if (nextLine != null && nextLine.ToString().IndexOf("ideal temp:") > -1)
                        {
                            Details.ideal_temperature = (int)float.Parse(Regex.Match(nextLine.ToString(), "ideal temp:([-.0-9]+)").Groups[1].Value);
                        }
                    }
                    if (nextLine != null && nextLine.ToString().IndexOf("ideal temp:") > -1)
                    {
                        Details.ideal_temperature = (int)float.Parse(Regex.Match(nextLine.ToString(), "ideal temp:([-.0-9]+)").Groups[1].Value);
                    }
                }
                gcodeFileReader.Close();
                if (Details.jobParams.filament_type == FilamentSpool.TypeEnum.ABS && (Details.bounds.max.x - (double)Details.bounds.min.x > printerProfile.PrinterSizeConstants.ABSWarningDim || Details.bounds.max.y - (double)Details.bounds.min.y > printerProfile.PrinterSizeConstants.ABSWarningDim || Details.bounds.max.z - (double)Details.bounds.min.z > printerProfile.PrinterSizeConstants.ABSWarningDim))
                {
                    return(AbstractPreprocessedJob.PrintJobWarning.Warning_ABS_Size);
                }
            }
            return(AbstractPreprocessedJob.PrintJobWarning.Job_OK);
        }
コード例 #6
0
ファイル: BondingPreprocessor.cs プロジェクト: urish/M3D
        internal override bool ProcessGCode(GCodeFileReader input_reader, GCodeFileWriter output_writer, Calibration calibration, JobDetails jobdetails, InternalPrinterProfile printerProfile)
        {
            var wave_step       = 0;
            var num1            = 0;
            var flag1           = true;
            var flag2           = true;
            var flag3           = false;
            var num2            = 0;
            var num3            = 0.0;
            var position        = new Position();
            var num4            = (float)num3;
            var num5            = 0.0f;
            var firstLayerTemp  = jobdetails.jobParams.preprocessor.bonding.FirstLayerTemp;
            var secondLayerTemp = jobdetails.jobParams.preprocessor.bonding.SecondLayerTemp;

            while (true)
            {
                GCode nextLine = input_reader.GetNextLine(false);
                if (nextLine != null)
                {
                    if (!jobdetails.jobParams.options.use_wave_bonding)
                    {
                        output_writer.Write(nextLine);
                    }
                    else
                    {
                        if (nextLine.ToString().Contains(";LAYER:"))
                        {
                            int num6;
                            try
                            {
                                num6 = int.Parse(nextLine.ToString().Substring(7));
                            }
                            catch (Exception ex)
                            {
                                num6 = 0;
                                ErrorLogger.LogException("Exception in BondingPreProcessor.ProcessGcode " + ex.Message, ex);
                            }
                            if (num6 < num1)
                            {
                                num1 = num6;
                            }

                            flag2 = num6 == num1;
                        }
                        if (nextLine.HasG && (nextLine.G == 0 || nextLine.G == 1) && !flag1)
                        {
                            if (nextLine.HasX || nextLine.HasY)
                            {
                                flag3 = true;
                            }

                            var num6 = !nextLine.HasX ? 0.0f : nextLine.X - position.relativeX;
                            var num7 = !nextLine.HasY ? 0.0f : nextLine.Y - position.relativeY;
                            var num8 = !nextLine.HasZ ? 0.0f : nextLine.Z - position.relativeZ;
                            var num9 = !nextLine.HasE ? 0.0f : nextLine.E - position.relativeE;
                            position.absoluteX += num6;
                            position.absoluteY += num7;
                            position.absoluteZ += num8;
                            position.absoluteE += num9;
                            position.relativeX += num6;
                            position.relativeY += num7;
                            position.relativeZ += num8;
                            position.relativeE += num9;
                            if (nextLine.hasF)
                            {
                                position.F = nextLine.F;
                            }

                            var num10 = (float)Math.Sqrt(num6 * (double)num6 + num7 * (double)num7);
                            var num11 = 1;
                            if (num10 > 1.25)
                            {
                                num11 = (int)(num10 / 1.25);
                            }

                            var num12 = position.absoluteX - num6;
                            var num13 = position.absoluteY - num7;
                            var num14 = position.relativeX - num6;
                            var num15 = position.relativeY - num7;
                            var num16 = position.relativeZ - num8;
                            var num17 = position.relativeE - num9;
                            var num18 = num6 / num10;
                            var num19 = num7 / num10;
                            var num20 = num8 / num10;
                            var num21 = num9 / num10;
                            if (flag2 && num9 > 0.0)
                            {
                                for (var index = 1; index < num11 + 1; ++index)
                                {
                                    float num22;
                                    float num23;
                                    float num24;
                                    float num25;
                                    if (index == num11)
                                    {
                                        var absoluteX = (double)position.absoluteX;
                                        var absoluteY = (double)position.absoluteY;
                                        num22 = position.relativeX;
                                        num23 = position.relativeY;
                                        num24 = position.relativeZ;
                                        num25 = position.relativeE;
                                    }
                                    else
                                    {
                                        num22 = num14 + index * 1.25f * num18;
                                        num23 = num15 + index * 1.25f * num19;
                                        num24 = num16 + index * 1.25f * num20;
                                        num25 = num17 + index * 1.25f * num21;
                                    }
                                    var num26 = num25 - (double)num5;
                                    if (index != num11)
                                    {
                                        var code = new GCode
                                        {
                                            G = nextLine.G
                                        };
                                        if (nextLine.HasX)
                                        {
                                            code.X = (float)(position.relativeX - (double)num6 + (num22 - (double)num14));
                                        }

                                        if (nextLine.HasY)
                                        {
                                            code.Y = (float)(position.relativeY - (double)num7 + (num23 - (double)num15));
                                        }

                                        if (nextLine.hasF && index == 1)
                                        {
                                            code.F = nextLine.F;
                                        }

                                        if (flag3)
                                        {
                                            code.Z = (float)(position.relativeZ - (double)num8 + (num24 - (double)num16)) + CurrentAdjustmentsZ(ref wave_step);
                                        }
                                        else if (nextLine.HasZ && (num8 > 1.40129846432482E-45 || num8 < -1.40129846432482E-45))
                                        {
                                            code.Z = (float)(position.relativeZ - (double)num8 + (num24 - (double)num16));
                                        }

                                        code.E = (float)(position.relativeE - (double)num9 + (num25 - (double)num17)) + num4;
                                        output_writer.Write(code);
                                    }
                                    else
                                    {
                                        if (flag3)
                                        {
                                            if (nextLine.HasZ)
                                            {
                                                nextLine.Z += CurrentAdjustmentsZ(ref wave_step);
                                            }
                                            else
                                            {
                                                nextLine.Z = num16 + num8 + CurrentAdjustmentsZ(ref wave_step);
                                            }
                                        }
                                        nextLine.E += num4;
                                    }
                                    num5 = num25;
                                }
                            }
                        }
                        else if (nextLine.HasG && nextLine.G == 92)
                        {
                            if (nextLine.HasE)
                            {
                                position.relativeE = nextLine.E;
                            }

                            if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                            {
                                if (nextLine.HasX)
                                {
                                    position.relativeX = nextLine.X;
                                }

                                if (nextLine.HasY)
                                {
                                    position.relativeY = nextLine.Y;
                                }

                                if (nextLine.HasZ)
                                {
                                    position.relativeZ = nextLine.Z;
                                }
                            }
                            if (!nextLine.HasE && !nextLine.HasX && (!nextLine.HasY && !nextLine.HasZ))
                            {
                                position.relativeE = 0.0f;
                                if (printerProfile.OptionsConstants.G92WorksOnAllAxes)
                                {
                                    position.relativeX = 0.0f;
                                    position.relativeY = 0.0f;
                                    position.relativeZ = 0.0f;
                                }
                            }
                        }
                        else if (nextLine.HasG && nextLine.G == 90)
                        {
                            flag1 = false;
                        }
                        else if (nextLine.HasG && nextLine.G == 91)
                        {
                            flag1 = true;
                        }

                        output_writer.Write(nextLine);
                        ++num2;
                    }
                }
                else
                {
                    break;
                }
            }
            return(true);
        }