public void AllMovesRequiringRetractionDoRetraction(string baseFileName, string settingsIniFile = "") { string stlToLoad = TestUtilities.GetStlPath(baseFileName + ".stl"); // check that default is support printed with extruder 0 string gcodeToCreate = TestUtilities.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 = TestUtilities.LoadGCodeFile(gcodeToCreate); int layerCount = TestUtilities.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 = TestUtilities.GetGCodeForLayer(gcodeContents, layerIndex); int movementIndex = 0; foreach (MovementInfo movement in TestUtilities.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(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); }
public void CanSetExtruderForSupportMaterial() { string baseFileName = "Support Material 2 Bars"; string stlToLoad = TestUtilities.GetStlPath(baseFileName + ".stl"); string supportToLoad = TestUtilities.GetStlPath("2BarsSupport.stl"); // check that default is support printed with extruder 0 { string gcodeToCreate = TestUtilities.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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support is printed with extruder 0 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 1; config.SupportExtruder = 1; // from a 0 based index // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support is printed with extruder 1 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b_.gcode"); ConfigSettings config = new ConfigSettings(); config.SupportExtruder = 1; config.ExtruderCount = 2; // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); // we have to have a mesh for every extruder processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support interface is printed with extruder 0 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 1; config.SupportInterfaceExtruder = 1; // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support interface is printed with extruder 1 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 2; config.SupportInterfaceExtruder = 1; // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); // we have to have a mesh for every extruder processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 0)); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support and interface can be set separately { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b2i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 1; config.SupportExtruder = 1; config.SupportInterfaceExtruder = 2; // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support and interface can be set separately { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b2i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 2; config.SupportExtruder = 1; config.SupportInterfaceExtruder = 2; // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); // we have to have a mesh for every extruder processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support and interface can be set separately { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b2i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 3; config.SupportExtruder = 1; config.SupportInterfaceExtruder = 2; // this is a hack, but it is the signaling mechanism for support config.BooleanOperations = "S"; FffProcessor processor = new FffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); // we have to have a mesh for every extruder processor.LoadStlFile(stlToLoad); processor.LoadStlFile(stlToLoad); processor.LoadStlFile(supportToLoad); // slice and save it processor.DoProcessing(); processor.Finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 2)); } }
public void CanSetExtruderForSupportMaterial() { string baseFileName = "Support Material 2 Bars"; string stlToLoad = TestUtilities.GetStlPath(baseFileName + ".stl"); // check that default is support printed with extruder 0 { string gcodeToCreate = TestUtilities.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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support is printed with extruder 0 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 1; config.SupportExtruder = 1; // from a 0 based index config.GenerateSupport = true; fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(gcodeToCreate); processor.LoadStlFile(stlToLoad); // slice and save it processor.DoProcessing(); processor.finalize(); string[] gcodeContents = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support is printed with extruder 1 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b_.gcode"); ConfigSettings config = new ConfigSettings(); config.SupportExtruder = 1; config.ExtruderCount = 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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support interface is printed with extruder 0 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 1; 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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support interface is printed with extruder 1 { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 2; 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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 0)); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support and interface can be set separately { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b2i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 1; 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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support and interface can be set separately { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b2i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 2; 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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsFalse(TestUtilities.UsesExtruder(gcodeContents, 2)); } // check that support and interface can be set separately { string gcodeToCreate = TestUtilities.GetTempGCodePath(baseFileName + "_1b2i_.gcode"); ConfigSettings config = new ConfigSettings(); config.ExtruderCount = 3; 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 = TestUtilities.LoadGCodeFile(gcodeToCreate); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 1)); Assert.IsTrue(TestUtilities.UsesExtruder(gcodeContents, 2)); } }