Beispiel #1
0
        private void preSetup(int extrusionWidth)
        {
            skirtConfig.SetData(config.insidePerimetersSpeed, extrusionWidth, "SKIRT");
            inset0Config.SetData(config.outsidePerimeterSpeed, extrusionWidth, "WALL-OUTER");
            insetXConfig.SetData(config.insidePerimetersSpeed, extrusionWidth, "WALL-INNER");
            fillConfig.SetData(config.infillSpeed, extrusionWidth, "FILL", false);
            topFillConfig.SetData(config.topInfillSpeed, extrusionWidth, "TOP-FILL", false);
            bridgConfig.SetData(config.bridgeSpeed, extrusionWidth, "BRIDGE");
            supportNormalConfig.SetData(config.supportMaterialSpeed, extrusionWidth, "SUPPORT");
            supportInterfaceConfig.SetData(config.supportMaterialSpeed, extrusionWidth, "SUPPORT-INTERFACE");

            for (int extruderIndex = 0; extruderIndex < ConfigConstants.MAX_EXTRUDERS; extruderIndex++)
            {
                gcode.SetExtruderOffset(extruderIndex, config.extruderOffsets[extruderIndex], -config.zOffset_um);
            }

            gcode.SetOutputType(config.outputType);
            gcode.SetRetractionSettings(config.retractionOnTravel, config.retractionSpeed, config.retractionOnExtruderSwitch, config.minimumExtrusionBeforeRetraction, config.retractionZHop, config.wipeAfterRetraction, config.unretractExtraExtrusion);
            gcode.SetToolChangeCode(config.toolChangeCode);
        }
Beispiel #2
0
        public GCodePlanner(GCodeExport gcode, int travelSpeed, int retractionMinimumDistance_um, double perimeterStartEndOverlap = 0)
        {
            this.gcodeExport = gcode;
            travelConfig     = new GCodePathConfig("travelConfig");
            travelConfig.SetData(travelSpeed, 0, "travel");

            LastPosition         = gcode.GetPositionXY();
            totalPrintTime       = 0.0;
            forceRetraction      = false;
            currentExtruderIndex = gcode.GetExtruderIndex();
            this.retractionMinimumDistance_um = retractionMinimumDistance_um;

            this.perimeterStartEndOverlapRatio = Math.Max(0, Math.Min(1, perimeterStartEndOverlap));
        }
        public LayerGCodePlanner(ConfigSettings config, GCodeExport gcode, int travelSpeed, long retractionMinimumDistance_um, double perimeterStartEndOverlap = 0)
        {
            this.config = config;

            this.gcodeExport = gcode;
            travelConfig     = new GCodePathConfig("travelConfig", "travel");
            travelConfig.SetData(travelSpeed, 0);

            LastPosition         = gcode.GetPositionXY();
            forceRetraction      = false;
            currentExtruderIndex = gcode.GetExtruderIndex();
            this.retractionMinimumDistance_um = retractionMinimumDistance_um;

            this.perimeterStartEndOverlapRatio = Math.Max(0, Math.Min(1, perimeterStartEndOverlap));
        }
Beispiel #4
0
        public GCodePlanner(GCodeExport gcode, int travelSpeed, int retractionMinimumDistance_um)
        {
            this.gcodeExport = gcode;
            travelConfig     = new GCodePathConfig("travelConfig");
            travelConfig.SetData(travelSpeed, 0, "travel");

            LastPosition = gcode.GetPositionXY();
            outerPerimetersToAvoidCrossing = null;
            extrudeSpeedFactor             = 100;
            travelSpeedFactor    = 100;
            extraTime            = 0.0;
            totalPrintTime       = 0.0;
            forceRetraction      = false;
            alwaysRetract        = false;
            currentExtruderIndex = gcode.GetExtruderIndex();
            this.retractionMinimumDistance_um = retractionMinimumDistance_um;
        }
        public GCodePlanner(GCodeExport gcode, int travelSpeed, int retractionMinimumDistance_um, double perimeterStartEndOverlap = 0)
        {
            this.gcodeExport = gcode;
            travelConfig =  new GCodePathConfig("travelConfig");
            travelConfig.SetData(travelSpeed, 0, "travel");

            LastPosition = gcode.GetPositionXY();
            outerPerimetersToAvoidCrossing = null;
            extrudeSpeedFactor = 100;
            travelSpeedFactor = 100;
            extraTime = 0.0;
            totalPrintTime = 0.0;
            forceRetraction = false;
            alwaysRetract = false;
            currentExtruderIndex = gcode.GetExtruderIndex();
            this.retractionMinimumDistance_um = retractionMinimumDistance_um;

            this.perimeterStartEndOverlapRatio = Math.Max(0, Math.Min(1, perimeterStartEndOverlap));
        }
Beispiel #6
0
        public GCodePlanner(GCodeExport gcode, int travelSpeed, int retractionMinimumDistance_um, double perimeterStartEndOverlap = 0, bool mergeOverlappingLines = false)
        {
            this.mergeOverlappingLines = mergeOverlappingLines;
            this.gcodeExport           = gcode;
            travelConfig = new GCodePathConfig("travelConfig");
            travelConfig.SetData(travelSpeed, 0, "travel");

            LastPosition = gcode.GetPositionXY();
            outerPerimetersToAvoidCrossing = null;
            extrudeSpeedFactor             = 100;
            travelSpeedFactor    = 100;
            extraTime            = 0.0;
            totalPrintTime       = 0.0;
            forceRetraction      = false;
            alwaysRetract        = false;
            currentExtruderIndex = gcode.GetExtruderIndex();
            this.retractionMinimumDistance_um = retractionMinimumDistance_um;

            this.perimeterStartEndOverlapRatio = Math.Max(0, Math.Min(1, perimeterStartEndOverlap));
        }
Beispiel #7
0
        public void WriteRaftGCodeIfRequired(GCodeExport gcode, ConfigSettings config)
        {
            LayerDataStorage storage = this;

            if (config.ShouldGenerateRaft())
            {
                GCodePathConfig raftBaseConfig = new GCodePathConfig("raftBaseConfig");
                raftBaseConfig.SetData(config.FirstLayerSpeed, config.RaftBaseExtrusionWidth_um, "SUPPORT");

                GCodePathConfig raftMiddleConfig = new GCodePathConfig("raftMiddleConfig");
                raftMiddleConfig.SetData(config.RaftPrintSpeed, config.RaftInterfaceExtrusionWidth_um, "SUPPORT");

                GCodePathConfig raftSurfaceConfig = new GCodePathConfig("raftMiddleConfig");
                raftSurfaceConfig.SetData((config.RaftSurfacePrintSpeed > 0) ? config.RaftSurfacePrintSpeed : config.RaftPrintSpeed, config.RaftSurfaceExtrusionWidth_um, "SUPPORT");

                // create the raft base
                {
                    gcode.WriteComment("RAFT BASE");
                    LayerGCodePlanner layerPlanner = new LayerGCodePlanner(config, gcode, config.TravelSpeed, config.MinimumTravelToCauseRetraction_um, config.PerimeterStartEndOverlapRatio);
                    if (config.RaftExtruder >= 0)
                    {
                        // if we have a specified raft extruder use it
                        layerPlanner.SetExtruder(config.RaftExtruder);
                    }
                    else if (config.SupportExtruder >= 0)
                    {
                        // else preserve the old behavior of using the support extruder if set.
                        layerPlanner.SetExtruder(config.SupportExtruder);
                    }

                    gcode.CurrentZ = config.RaftBaseThickness_um;

                    gcode.LayerChanged(-3, config.RaftBaseThickness_um);

                    gcode.SetExtrusion(config.RaftBaseThickness_um, config.FilamentDiameter_um, config.ExtrusionMultiplier);

                    // write the skirt around the raft
                    layerPlanner.QueuePolygonsByOptimizer(storage.Skirt, null, raftBaseConfig, 0);

                    List <Polygons> raftIslands = storage.raftOutline.ProcessIntoSeparateIslands();
                    foreach (var raftIsland in raftIslands)
                    {
                        // write the outline of the raft
                        layerPlanner.QueuePolygonsByOptimizer(raftIsland, null, raftBaseConfig, 0);

                        Polygons raftLines = new Polygons();
                        Infill.GenerateLinePaths(raftIsland.Offset(-config.RaftBaseExtrusionWidth_um), raftLines, config.RaftBaseLineSpacing_um, config.InfillExtendIntoPerimeter_um, 0);

                        // write the inside of the raft base
                        layerPlanner.QueuePolygonsByOptimizer(raftLines, null, raftBaseConfig, 0);

                        if (config.RetractWhenChangingIslands)
                        {
                            layerPlanner.ForceRetract();
                        }
                    }

                    layerPlanner.WriteQueuedGCode(config.RaftBaseThickness_um);
                }

                // raft middle layers
                {
                    gcode.WriteComment("RAFT MIDDLE");
                    LayerGCodePlanner layerPlanner = new LayerGCodePlanner(config, gcode, config.TravelSpeed, config.MinimumTravelToCauseRetraction_um, config.PerimeterStartEndOverlapRatio);
                    gcode.CurrentZ = config.RaftBaseThickness_um + config.RaftInterfaceThicknes_um;
                    gcode.LayerChanged(-2, config.RaftInterfaceThicknes_um);
                    gcode.SetExtrusion(config.RaftInterfaceThicknes_um, config.FilamentDiameter_um, config.ExtrusionMultiplier);

                    Polygons raftLines = new Polygons();
                    Infill.GenerateLinePaths(storage.raftOutline, raftLines, config.RaftInterfaceLineSpacing_um, config.InfillExtendIntoPerimeter_um, 45);
                    layerPlanner.QueuePolygonsByOptimizer(raftLines, null, raftMiddleConfig, 0);

                    layerPlanner.WriteQueuedGCode(config.RaftInterfaceThicknes_um);
                }

                for (int raftSurfaceIndex = 1; raftSurfaceIndex <= config.RaftSurfaceLayers; raftSurfaceIndex++)
                {
                    gcode.WriteComment("RAFT SURFACE");
                    LayerGCodePlanner layerPlanner = new LayerGCodePlanner(config, gcode, config.TravelSpeed, config.MinimumTravelToCauseRetraction_um, config.PerimeterStartEndOverlapRatio);
                    gcode.CurrentZ = config.RaftBaseThickness_um + config.RaftInterfaceThicknes_um + config.RaftSurfaceThickness_um * raftSurfaceIndex;
                    gcode.LayerChanged(-1, config.RaftSurfaceThickness_um);
                    gcode.SetExtrusion(config.RaftSurfaceThickness_um, config.FilamentDiameter_um, config.ExtrusionMultiplier);

                    Polygons raftLines = new Polygons();
                    if (raftSurfaceIndex == config.RaftSurfaceLayers)
                    {
                        // make sure the top layer of the raft is 90 degrees offset to the first layer of the part so that it has minimum contact points.
                        Infill.GenerateLinePaths(storage.raftOutline, raftLines, config.RaftSurfaceLineSpacing_um, config.InfillExtendIntoPerimeter_um, config.InfillStartingAngle + 90);
                    }
                    else
                    {
                        Infill.GenerateLinePaths(storage.raftOutline, raftLines, config.RaftSurfaceLineSpacing_um, config.InfillExtendIntoPerimeter_um, 90 * raftSurfaceIndex);
                    }
                    layerPlanner.QueuePolygonsByOptimizer(raftLines, null, raftSurfaceConfig, 0);

                    layerPlanner.WriteQueuedGCode(config.RaftInterfaceThicknes_um);
                }
            }
        }
        public void WriteRaftGCodeIfRequired(GCodeExport gcode, ConfigSettings config)
        {
            LayerDataStorage storage = this;
            if (config.ShouldGenerateRaft())
            {
                GCodePathConfig raftBaseConfig = new GCodePathConfig("raftBaseConfig");
                raftBaseConfig.SetData(config.FirstLayerSpeed, config.RaftBaseExtrusionWidth_um, "SUPPORT");

                GCodePathConfig raftMiddleConfig = new GCodePathConfig("raftMiddleConfig");
                raftMiddleConfig.SetData(config.RaftPrintSpeed, config.RaftInterfaceExtrusionWidth_um, "SUPPORT");

                GCodePathConfig raftSurfaceConfig = new GCodePathConfig("raftMiddleConfig");
                raftSurfaceConfig.SetData((config.RaftSurfacePrintSpeed > 0) ? config.RaftSurfacePrintSpeed : config.RaftPrintSpeed, config.RaftSurfaceExtrusionWidth_um, "SUPPORT");

                // create the raft base
                {
                    gcode.WriteComment("LAYER:-3");
                    gcode.WriteComment("RAFT BASE");
                    GCodePlanner gcodeLayer = new GCodePlanner(gcode, config.TravelSpeed, config.MinimumTravelToCauseRetraction_um, config.PerimeterStartEndOverlapRatio);
                    if (config.RaftExtruder >= 0)
                    {
                        // if we have a specified raft extruder use it
                        gcodeLayer.SetExtruder(config.RaftExtruder);
                    }
                    else if (config.SupportExtruder >= 0)
                    {
                        // else preserve the old behavior of using the support extruder if set.
                        gcodeLayer.SetExtruder(config.SupportExtruder);
                    }

                    gcode.setZ(config.RaftBaseThickness_um);
                    gcode.SetExtrusion(config.RaftBaseThickness_um, config.FilamentDiameter_um, config.ExtrusionMultiplier);

                    // write the skirt around the raft
                    gcodeLayer.QueuePolygonsByOptimizer(storage.skirt, raftBaseConfig);

                    List<Polygons> raftIslands = storage.raftOutline.ProcessIntoSeparatIslands();
                    foreach (var raftIsland in raftIslands)
                    {
                        // write the outline of the raft
                        gcodeLayer.QueuePolygonsByOptimizer(raftIsland, raftBaseConfig);

                        Polygons raftLines = new Polygons();
                        Infill.GenerateLinePaths(raftIsland, raftLines, config.RaftBaseLineSpacing_um, config.InfillExtendIntoPerimeter_um, 0);

                        // write the inside of the raft base
                        gcodeLayer.QueuePolygonsByOptimizer(raftLines, raftBaseConfig);

                        if (config.RetractWhenChangingIslands)
                        {
                            gcodeLayer.ForceRetract();
                        }
                    }

                    gcodeLayer.WriteQueuedGCode(config.RaftBaseThickness_um);
                }

                if (config.RaftFanSpeedPercent > 0)
                {
                    gcode.WriteFanCommand(config.RaftFanSpeedPercent);
                }

                // raft middle layers
                {
                    gcode.WriteComment("LAYER:-2");
                    gcode.WriteComment("RAFT MIDDLE");
                    GCodePlanner gcodeLayer = new GCodePlanner(gcode, config.TravelSpeed, config.MinimumTravelToCauseRetraction_um, config.PerimeterStartEndOverlapRatio);
                    gcode.setZ(config.RaftBaseThickness_um + config.RaftInterfaceThicknes_um);
                    gcode.SetExtrusion(config.RaftInterfaceThicknes_um, config.FilamentDiameter_um, config.ExtrusionMultiplier);

                    Polygons raftLines = new Polygons();
                    Infill.GenerateLinePaths(storage.raftOutline, raftLines, config.RaftInterfaceLineSpacing_um, config.InfillExtendIntoPerimeter_um, 45);
                    gcodeLayer.QueuePolygonsByOptimizer(raftLines, raftMiddleConfig);

                    gcodeLayer.WriteQueuedGCode(config.RaftInterfaceThicknes_um);
                }

                for (int raftSurfaceIndex = 1; raftSurfaceIndex <= config.RaftSurfaceLayers; raftSurfaceIndex++)
                {
                    gcode.WriteComment("LAYER:-1");
                    gcode.WriteComment("RAFT SURFACE");
                    GCodePlanner gcodeLayer = new GCodePlanner(gcode, config.TravelSpeed, config.MinimumTravelToCauseRetraction_um, config.PerimeterStartEndOverlapRatio);
                    gcode.setZ(config.RaftBaseThickness_um + config.RaftInterfaceThicknes_um + config.RaftSurfaceThickness_um * raftSurfaceIndex);
                    gcode.SetExtrusion(config.RaftSurfaceThickness_um, config.FilamentDiameter_um, config.ExtrusionMultiplier);

                    Polygons raftLines = new Polygons();
                    if (raftSurfaceIndex == config.RaftSurfaceLayers)
                    {
                        // make sure the top layer of the raft is 90 degrees offset to the first layer of the part so that it has minimum contact points.
                        Infill.GenerateLinePaths(storage.raftOutline, raftLines, config.RaftSurfaceLineSpacing_um, config.InfillExtendIntoPerimeter_um, config.InfillStartingAngle + 90);
                    }
                    else
                    {
                        Infill.GenerateLinePaths(storage.raftOutline, raftLines, config.RaftSurfaceLineSpacing_um, config.InfillExtendIntoPerimeter_um, 90 * raftSurfaceIndex);
                    }
                    gcodeLayer.QueuePolygonsByOptimizer(raftLines, raftSurfaceConfig);

                    gcodeLayer.WriteQueuedGCode(config.RaftInterfaceThicknes_um);
                }
            }
        }