Example #1
0
        public void NoLayerChangeRetractions()
        {
            string infillSTL   = TestUtilities.GetStlPath("no_layer_change_retractions");
            string infillGCode = TestUtilities.GetTempGCodePath("no_layer_change_retractions.gcode");
            {
                // load a model that is correctly manifold
                var    config       = new ConfigSettings();
                string settingsPath = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "no_retractions_config.ini");
                config.ReadSettings(settingsPath);
                var processor = new FffProcessor(config);
                processor.SetTargetFile(infillGCode);
                processor.LoadStlFile(infillSTL);
                // slice and save it
                processor.DoProcessing();
                processor.Finalize();

                string[] gcodeContents = TestUtilities.LoadGCodeFile(infillGCode);

                int numLayers = TestUtilities.LayerCount(gcodeContents);
                for (int i = 1; i < numLayers - 2; i++)
                {
                    string[] layer            = TestUtilities.GetGCodeForLayer(gcodeContents, i);
                    int      totalRetractions = TestUtilities.CountRetractions(layer);
                    Assert.IsTrue(totalRetractions == 0);
                }
            }
        }
Example #2
0
        public void AlwaysRetractOnIslandChange()
        {
            string meshWithIslands  = TestUtilities.GetStlPath("comb");
            string gCodeWithIslands = TestUtilities.GetTempGCodePath("comb-box");

            {
                // load a model that has 3 islands
                ConfigSettings config = new ConfigSettings();
                // make sure no retractions are going to occur that are island crossing
                config.MinimumTravelToCauseRetraction = 2000;
                FffProcessor processor = new FffProcessor(config);
                processor.SetTargetFile(gCodeWithIslands);
                processor.LoadStlFile(meshWithIslands);
                // slice and save it
                processor.DoProcessing();
                processor.Finalize();

                string[] gcodeContents = TestUtilities.LoadGCodeFile(gCodeWithIslands);
                int      numLayers     = TestUtilities.CountLayers(gcodeContents);
                for (int i = 1; i < numLayers - 1; i++)
                {
                    string[] layer            = TestUtilities.GetGCodeForLayer(gcodeContents, i);
                    int      totalRetractions = TestUtilities.CountRetractions(layer);
                    Assert.IsTrue(totalRetractions == 6);
                }
            }
        }
        public void DualMaterialNoRetraction(int material)
        {
            GCodeExport.CheckForZeroPositions = false;
            string shortCubeName = "CubePoint2High";
            string shortCube     = TestUtilities.GetStlPath(shortCubeName);

            string outputGCodeFileName = TestUtilities.GetTempGCodePath($"CubeNoRetractions{material}");

            var config = new ConfigSettings();

            config.ExtruderCount       = 2;
            config.FirstLayerThickness = .2;
            config.LayerThickness      = .2;

            var processor = new FffProcessor(config);

            processor.SetTargetFile(outputGCodeFileName);
            for (int i = 0; i < material; i++)
            {
                string skipExtruder = TestUtilities.GetStlPath("TooSmallToPrint");

                processor.LoadStlFile(skipExtruder);
            }

            processor.LoadStlFile(shortCube);
            // slice and save it
            processor.DoProcessing();
            processor.Dispose();

            string[] gCodeContent = TestUtilities.LoadGCodeFile(outputGCodeFileName);

            // test layer count
            int layerCount = TestUtilities.LayerCount(gCodeContent);

            Assert.AreEqual(1, layerCount);

            int retractions = TestUtilities.CountRetractions(gCodeContent);

            Assert.AreEqual(1, retractions, $"Material {material} should have no retractions");
        }