コード例 #1
0
        public void AllMovesRequiringRetractionDoRetraction()
        {
            string baseFileName = "ab retraction test";
            string stlToLoad    = TestUtlities.GetStlPath(baseFileName + ".stl");

            // check that default is support printed with extruder 0
            {
                string gcodeToCreate = TestUtlities.GetTempGCodePath(baseFileName + "_retract_" + ".gcode");

                ConfigSettings config = new ConfigSettings();
                config.RetractionZHop = 5;
                config.MinimumTravelToCauseRetraction   = 2;
                config.MinimumExtrusionBeforeRetraction = 0;
                config.FirstLayerExtrusionWidth         = .5;
                fffProcessor processor = new fffProcessor(config);
                processor.SetTargetFile(gcodeToCreate);
                processor.LoadStlFile(stlToLoad);
                // slice and save it
                processor.DoProcessing();
                processor.finalize();

                string[] gcodeContents = TestUtlities.LoadGCodeFile(gcodeToCreate);
                int      layerCount    = TestUtlities.CountLayers(gcodeContents);
                bool     firstPosition = true;
                for (int i = 0; i < layerCount; i++)
                {
                    string[]     layerGCode   = TestUtlities.GetGCodeForLayer(gcodeContents, i);
                    MovementInfo lastMovement = new MovementInfo();
                    foreach (MovementInfo movement in TestUtlities.Movements(layerGCode))
                    {
                        if (!firstPosition)
                        {
                            bool isTravel = lastMovement.extrusion == movement.extrusion;
                            if (isTravel)
                            {
                                Vector3 lastPosition = lastMovement.position;
                                lastPosition.z = 0;
                                Vector3 currenPosition = movement.position;
                                currenPosition.z = 0;
                                double xyLength = (lastPosition - currenPosition).Length;
                                if (xyLength > config.MinimumTravelToCauseRetraction)
                                {
                                    Assert.IsTrue(movement.position.z > lastMovement.position.z);
                                }
                            }
                        }

                        lastMovement  = movement;
                        firstPosition = false;
                    }
                }
                Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 1));
                Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 2));
            }
        }
コード例 #2
0
        public void CanSetExtruderForSupportMaterial()
        {
            string baseFileName = "Support Material 2 Bars";
            string stlToLoad    = TestUtlities.GetStlPath(baseFileName + ".stl");

            // check that default is support printed with extruder 0
            {
                string gcodeToCreate = TestUtlities.GetTempGCodePath(baseFileName + "_0_" + ".gcode");

                ConfigSettings config    = new ConfigSettings();
                fffProcessor   processor = new fffProcessor(config);
                processor.SetTargetFile(gcodeToCreate);
                processor.LoadStlFile(stlToLoad);
                // slice and save it
                processor.DoProcessing();
                processor.finalize();

                string[] gcodeContents = TestUtlities.LoadGCodeFile(gcodeToCreate);
                Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 1));
                Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 2));
            }

            // check that support is printed with extruder 1
            {
                string gcodeToCreate = TestUtlities.GetTempGCodePath(baseFileName + "_1b_" + ".gcode");

                ConfigSettings config = new ConfigSettings();
                config.SupportExtruder = 1;
                config.GenerateSupport = true;
                fffProcessor processor = new fffProcessor(config);
                processor.SetTargetFile(gcodeToCreate);
                processor.LoadStlFile(stlToLoad);
                // slice and save it
                processor.DoProcessing();
                processor.finalize();

                string[] gcodeContents = TestUtlities.LoadGCodeFile(gcodeToCreate);
                Assert.IsTrue(TestUtlities.UsesExtruder(gcodeContents, 1));
                Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 2));
            }

            // check that support interface is printed with extruder 1
            {
                string gcodeToCreate = TestUtlities.GetTempGCodePath(baseFileName + "_1i_" + ".gcode");

                ConfigSettings config = new ConfigSettings();
                config.SupportInterfaceExtruder = 1;
                config.GenerateSupport          = true;
                fffProcessor processor = new fffProcessor(config);
                processor.SetTargetFile(gcodeToCreate);
                processor.LoadStlFile(stlToLoad);
                // slice and save it
                processor.DoProcessing();
                processor.finalize();

                string[] gcodeContents = TestUtlities.LoadGCodeFile(gcodeToCreate);
                Assert.IsTrue(TestUtlities.UsesExtruder(gcodeContents, 1));
                Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 2));
            }

            // check that support and interface can be set separately
            {
                string gcodeToCreate = TestUtlities.GetTempGCodePath(baseFileName + "_1b2i_" + ".gcode");

                ConfigSettings config = new ConfigSettings();
                config.SupportExtruder          = 1;
                config.SupportInterfaceExtruder = 2;
                config.GenerateSupport          = true;
                fffProcessor processor = new fffProcessor(config);
                processor.SetTargetFile(gcodeToCreate);
                processor.LoadStlFile(stlToLoad);
                // slice and save it
                processor.DoProcessing();
                processor.finalize();

                string[] gcodeContents = TestUtlities.LoadGCodeFile(gcodeToCreate);
                Assert.IsTrue(TestUtlities.UsesExtruder(gcodeContents, 1));
                Assert.IsTrue(TestUtlities.UsesExtruder(gcodeContents, 2));
            }
        }
コード例 #3
0
        public void AllMovesRequiringRetractionDoRetraction(string baseFileName, string settingsIniFile = "")
        {
            string stlToLoad = TestUtlities.GetStlPath(baseFileName + ".stl");

            // check that default is support printed with extruder 0
            string gcodeToCreate = TestUtlities.GetTempGCodePath(baseFileName + "_retract_.gcode");

            ConfigSettings config = new ConfigSettings();

            if (settingsIniFile == "")
            {
                config.MinimumTravelToCauseRetraction   = 2;
                config.MinimumExtrusionBeforeRetraction = 0;
                config.MergeOverlappingLines            = false;
                config.FirstLayerExtrusionWidth         = .5;
            }
            else
            {
                config.ReadSettings(settingsIniFile);
            }

            // this is what we detect
            config.RetractionZHop = 5;

            fffProcessor processor = new fffProcessor(config);

            processor.SetTargetFile(gcodeToCreate);
            processor.LoadStlFile(stlToLoad);
            // slice and save it
            processor.DoProcessing();
            processor.finalize();

            string[]     gcodeContents       = TestUtlities.LoadGCodeFile(gcodeToCreate);
            int          layerCount          = TestUtlities.CountLayers(gcodeContents);
            bool         firstPosition       = true;
            MovementInfo lastMovement        = new MovementInfo();
            MovementInfo lastExtrusion       = new MovementInfo();
            bool         lastMoveIsExtrusion = true;

            for (int layerIndex = 0; layerIndex < layerCount; layerIndex++)
            {
                string[] layerGCode    = TestUtlities.GetGCodeForLayer(gcodeContents, layerIndex);
                int      movementIndex = 0;
                foreach (MovementInfo movement in TestUtlities.Movements(layerGCode, lastMovement))
                {
                    if (!firstPosition)
                    {
                        bool isTravel = lastMovement.extrusion == movement.extrusion;
                        if (isTravel)
                        {
                            Vector3 lastPosition = lastMovement.position;
                            lastPosition.z = 0;
                            Vector3 currenPosition = movement.position;
                            currenPosition.z = 0;
                            double xyLength = (lastPosition - currenPosition).Length;
                            if (xyLength > config.MinimumTravelToCauseRetraction &&
                                lastMoveIsExtrusion)
                            {
                                Assert.GreaterOrEqual(movement.position.z, lastExtrusion.position.z);
                            }

                            lastMoveIsExtrusion = false;
                        }
                        else
                        {
                            lastMoveIsExtrusion = true;
                            lastExtrusion       = movement;
                        }

                        lastMoveIsExtrusion = !isTravel;
                    }

                    lastMovement  = movement;
                    firstPosition = false;
                    movementIndex++;
                }
            }

            // make sure we don't switch extruders
            Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 1));
            Assert.IsFalse(TestUtlities.UsesExtruder(gcodeContents, 2));
        }