public int LastLayerWithChange(ConfigSettings config)
        {
            int numLayers             = Extruders[0].Layers.Count;
            int firstExtruderWithData = -1;

            for (int checkLayer = numLayers - 1; checkLayer >= 0; checkLayer--)
            {
                for (int extruderToCheck = 0; extruderToCheck < config.MaxExtruderCount(); extruderToCheck++)
                {
                    if ((extruderToCheck < Extruders.Count && Extruders[extruderToCheck].Layers[checkLayer].AllOutlines.Count > 0) ||
                        (config.SupportExtruder == extruderToCheck && support != null && support.HasNormalSupport(checkLayer)) ||
                        (config.SupportInterfaceExtruder == extruderToCheck && support != null && support.HasInterfaceSupport(checkLayer)))
                    {
                        if (firstExtruderWithData == -1)
                        {
                            firstExtruderWithData = extruderToCheck;
                        }
                        else
                        {
                            if (firstExtruderWithData != extruderToCheck)
                            {
                                return(checkLayer);
                            }
                        }
                    }
                }
            }

            return(-1);
        }
Esempio n. 2
0
        public void PrimeOnWipeTower(int extruderIndexIn, int layerIndex, GCodePlanner gcodeLayer, GCodePathConfig fillConfig, ConfigSettings config, bool airGapped)
        {
            if (!HaveWipeTower(config) ||
                layerIndex > LastLayerWithChange(config) + 1)
            {
                return;
            }

            //If we changed extruder, print the wipe/prime tower for this nozzle;
            Polygons fillPolygons = new Polygons();

            int extruderIndex = airGapped ? config.MaxExtruderCount() + extruderIndexIn : extruderIndexIn;

            GenerateWipeTowerInfill(extruderIndex, this.wipeTower, fillPolygons, fillConfig.lineWidth_um, config);
            gcodeLayer.QueuePolygons(fillPolygons, fillConfig);

            extrudersThatHaveBeenPrimed[extruderIndex] = true;
        }
        public void GenerateWipeTowerInfill(int extruderIndex, Polygons partOutline, Polygons outputfillPolygons, long extrusionWidth_um, ConfigSettings config)
        {
            Polygons outlineForExtruder = partOutline.Offset(-extrusionWidth_um * extruderIndex);

            long insetPerLoop = extrusionWidth_um * config.MaxExtruderCount();

            while (outlineForExtruder.Count > 0)
            {
                for (int polygonIndex = 0; polygonIndex < outlineForExtruder.Count; polygonIndex++)
                {
                    Polygon newInset = outlineForExtruder[polygonIndex];
                    newInset.Add(newInset[0]);                     // add in the last move so it is a solid polygon
                    outputfillPolygons.Add(newInset);
                }
                outlineForExtruder = outlineForExtruder.Offset(-insetPerLoop);
            }

            outputfillPolygons.Reverse();
        }
        public void CreateWipeTower(int totalLayers, ConfigSettings config)
        {
            if (config.WipeTowerSize_um < 1 ||
                LastLayerWithChange(config) == -1)
            {
                return;
            }

            extrudersThatHaveBeenPrimed = new bool[config.MaxExtruderCount()];

            Polygon wipeTowerShape = new Polygon();

            wipeTowerShape.Add(new IntPoint(this.modelMin.X - 3000, this.modelMax.Y + 3000));
            wipeTowerShape.Add(new IntPoint(this.modelMin.X - 3000, this.modelMax.Y + 3000 + config.WipeTowerSize_um));
            wipeTowerShape.Add(new IntPoint(this.modelMin.X - 3000 - config.WipeTowerSize_um, this.modelMax.Y + 3000 + config.WipeTowerSize_um));
            wipeTowerShape.Add(new IntPoint(this.modelMin.X - 3000 - config.WipeTowerSize_um, this.modelMax.Y + 3000));

            this.wipeTower.Add(wipeTowerShape);
            this.wipePoint = new IntPoint(this.modelMin.X - 3000 - config.WipeTowerSize_um / 2, this.modelMax.Y + 3000 + config.WipeTowerSize_um / 2);
        }
        public void EnsureWipeTowerIsSolid(int layerIndex, GCodePlanner gcodeLayer, GCodePathConfig fillConfig, ConfigSettings config)
        {
            if (layerIndex >= LastLayerWithChange(config) ||
                extrudersThatHaveBeenPrimed == null)
            {
                return;
            }

            // print all of the extruder loops that have not already been printed
            for (int extruderIndex = 0; extruderIndex < config.MaxExtruderCount(); extruderIndex++)
            {
                if (!extrudersThatHaveBeenPrimed[extruderIndex])
                {
                    // write the loops for this extruder, but don't change to it. We are just filling the prime tower.
                    PrimeOnWipeTower(extruderIndex, 0, gcodeLayer, fillConfig, config);
                }

                // clear the history of printer extruders for the next layer
                extrudersThatHaveBeenPrimed[extruderIndex] = false;
            }
        }
        int LastLayerWithChange(ConfigSettings config)
        {
            int numLayers = Extruders[0].Layers.Count;
            int firstExtruderWithData = -1;
            for (int checkLayer = numLayers - 1; checkLayer >= 0; checkLayer--)
            {
                for (int extruderToCheck = 0; extruderToCheck < config.MaxExtruderCount(); extruderToCheck++)
                {
                    if((extruderToCheck < Extruders.Count && Extruders[extruderToCheck].Layers[checkLayer].AllOutlines.Count > 0)
                        || (config.SupportExtruder == extruderToCheck && support != null && support.HasNormalSupport(checkLayer) )
                        || (config.SupportInterfaceExtruder == extruderToCheck && support != null && support.HasInterfaceSupport(checkLayer)) )
                    {
                        if(firstExtruderWithData == -1)
                        {
                            firstExtruderWithData = extruderToCheck;
                        }
                        else
                        {
                            if(firstExtruderWithData != extruderToCheck)
                            {
                                return checkLayer;
                            }
                        }
                    }
                }
            }

            return -1;
        }
        public void GenerateWipeTowerInfill(int extruderIndex, Polygons partOutline, Polygons outputfillPolygons, long extrusionWidth_um, ConfigSettings config)
        {
            Polygons outlineForExtruder = partOutline.Offset(-extrusionWidth_um * extruderIndex);

            long insetPerLoop = extrusionWidth_um * config.MaxExtruderCount();
            while (outlineForExtruder.Count > 0)
            {
                for (int polygonIndex = 0; polygonIndex < outlineForExtruder.Count; polygonIndex++)
                {
                    Polygon newInset = outlineForExtruder[polygonIndex];
                    newInset.Add(newInset[0]); // add in the last move so it is a solid polygon
                    outputfillPolygons.Add(newInset);
                }
                outlineForExtruder = outlineForExtruder.Offset(-insetPerLoop);
            }

            outputfillPolygons.Reverse();
        }
        public void EnsureWipeTowerIsSolid(int layerIndex, GCodePlanner gcodeLayer, GCodePathConfig fillConfig, ConfigSettings config)
        {
            if(layerIndex >= LastLayerWithChange(config)
                || extrudersThatHaveBeenPrimed == null)
            {
                return;
            }

            // print all of the extruder loops that have not already been printed
            for (int extruderIndex = 0; extruderIndex < config.MaxExtruderCount(); extruderIndex++)
            {
                if (!extrudersThatHaveBeenPrimed[extruderIndex])
                {
                    // write the loops for this extruder, but don't change to it. We are just filling the prime tower.
                    PrimeOnWipeTower(extruderIndex, 0, gcodeLayer, fillConfig, config);
                }

                // clear the history of printer extruders for the next layer
                extrudersThatHaveBeenPrimed[extruderIndex] = false;
            }
        }
        public void CreateWipeTower(int totalLayers, ConfigSettings config)
        {
            if (config.WipeTowerSize_um < 1
                || LastLayerWithChange(config) == -1)
            {
                return;
            }

            extrudersThatHaveBeenPrimed = new bool[config.MaxExtruderCount()];

            Polygon wipeTowerShape = new Polygon();
            wipeTowerShape.Add(new IntPoint(this.modelMin.x - 3000, this.modelMax.y + 3000));
            wipeTowerShape.Add(new IntPoint(this.modelMin.x - 3000, this.modelMax.y + 3000 + config.WipeTowerSize_um));
            wipeTowerShape.Add(new IntPoint(this.modelMin.x - 3000 - config.WipeTowerSize_um, this.modelMax.y + 3000 + config.WipeTowerSize_um));
            wipeTowerShape.Add(new IntPoint(this.modelMin.x - 3000 - config.WipeTowerSize_um, this.modelMax.y + 3000));

            this.wipeTower.Add(wipeTowerShape);
            this.wipePoint = new IntPoint(this.modelMin.x - 3000 - config.WipeTowerSize_um / 2, this.modelMax.y + 3000 + config.WipeTowerSize_um / 2);
        }