public void AllPerimetersGoInPolgonDirection() { string thinWallsSTL = TestUtlities.GetStlPath("ThinWallsRect.stl"); string thinWallsGCode = TestUtlities.GetTempGCodePath("ThinWallsRect.stl"); { // load a model that is correctly manifold ConfigSettings config = new ConfigSettings(); config.ExpandThinWalls = true; fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(thinWallsGCode); processor.LoadStlFile(thinWallsSTL); // slice and save it processor.DoProcessing(); processor.finalize(); string[] thinWallsGCodeContent = TestUtlities.LoadGCodeFile(thinWallsGCode); int layerCount = TestUtlities.CountLayers(thinWallsGCodeContent); for (int i = 2; i < layerCount - 2; i++) { var layerGCode = TestUtlities.GetGCodeForLayer(thinWallsGCodeContent, i); var polygons = TestUtlities.GetExtrusionPolygons(layerGCode, 1000); foreach (var polygon in polygons) { Assert.AreEqual(1, polygon.GetWindingDirection()); } } } }
public void AllInsidesBeforeAnyOutsides() { string thinAttachStlFile = TestUtlities.GetStlPath("Thin Attach"); string thinAttachGCodeFile = TestUtlities.GetTempGCodePath("Thin Attach.gcode"); ConfigSettings config = new ConfigSettings(); config.NumberOfPerimeters = 2; config.InfillPercent = 0; config.NumberOfTopLayers = 0; config.FirstLayerExtrusionWidth = .4; config.NumberOfBottomLayers = 0; fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(thinAttachGCodeFile); processor.LoadStlFile(thinAttachStlFile); // slice and save it processor.DoProcessing(); processor.finalize(); string[] gcode = TestUtlities.LoadGCodeFile(thinAttachGCodeFile); // should look like this // ____________ ____________ // | _______ | | _______ | // | | | | | | | | // | | | |___| | | | // | | | ____ | | | // | |______| | | |______| | // |__________| |__________| MovementInfo movement = new MovementInfo(); { // check layer 1 string[] layer1Info = TestUtlities.GetGCodeForLayer(gcode, 1); Polygons layer1Polygons = TestUtlities.GetExtrusionPolygons(layer1Info, ref movement); // make sure there are 5 Assert.IsTrue(layer1Polygons.Count == 3); // make sure they are in the right order (two inner polygons print first) Assert.IsTrue(layer1Polygons[0].MinX() > layer1Polygons[1].MinX()); Assert.IsTrue(layer1Polygons[0].MinX() > layer1Polygons[2].MinX()); } { // check layer 2 string[] layer2Info = TestUtlities.GetGCodeForLayer(gcode, 2); Polygons layer2Polygons = TestUtlities.GetExtrusionPolygons(layer2Info, ref movement); // make sure there are 3 Assert.IsTrue(layer2Polygons.Count == 3); // make sure they are in the right order (two inner polygons print first) Assert.IsTrue(layer2Polygons[0].MinX() > layer2Polygons[1].MinX()); Assert.IsTrue(layer2Polygons[0].MinX() > layer2Polygons[2].MinX()); } }
public void OuterPerimeterFirstCorrect() { string box20MmStlFile = TestUtlities.GetStlPath("20mm-box"); string boxGCodeFile = TestUtlities.GetTempGCodePath("20mm-box-perimeter.gcode"); ConfigSettings config = new ConfigSettings(); config.NumberOfPerimeters = 3; config.OutsidePerimetersFirst = true; config.InfillPercent = 0; config.NumberOfTopLayers = 0; config.NumberOfBottomLayers = 0; fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(boxGCodeFile); processor.LoadStlFile(box20MmStlFile); // slice and save it processor.DoProcessing(); processor.finalize(); string[] gcode = TestUtlities.LoadGCodeFile(boxGCodeFile); MovementInfo movement = new MovementInfo(); { // check layer 1 string[] layer1Info = TestUtlities.GetGCodeForLayer(gcode, 1); Polygons layer1Polygons = TestUtlities.GetExtrusionPolygons(layer1Info, ref movement); // make sure there are 3 Assert.IsTrue(layer1Polygons.Count == 3); // make sure they are in the right order (first layer is outside in) Assert.IsTrue(layer1Polygons[0].MinX() < layer1Polygons[1].MinX()); } { // check layer 2 string[] layer2Info = TestUtlities.GetGCodeForLayer(gcode, 2); Polygons layer2Polygons = TestUtlities.GetExtrusionPolygons(layer2Info, ref movement); // make sure there are 3 Assert.IsTrue(layer2Polygons.Count == 3); // make sure they are in the right order (other layers are inside out) Assert.IsTrue(layer2Polygons[0].MinX() < layer2Polygons[1].MinX()); } }
public void OuterPerimeterFirstCorrect() { string box20MmStlFile = TestUtlities.GetStlPath("20mm-box"); string boxGCodeFile = TestUtlities.GetTempGCodePath("20mm-box-perimeter.gcode"); ConfigSettings config = new ConfigSettings(); config.NumberOfPerimeters = 3; config.InfillPercent = 0; fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(boxGCodeFile); processor.LoadStlFile(box20MmStlFile); // slice and save it processor.DoProcessing(); processor.finalize(); string[] gcode = TestUtlities.LoadGCodeFile(boxGCodeFile); { // check layer 0 string[] layer0Info = TestUtlities.GetGCodeForLayer(gcode, 0); List <Polygons> layer0Polygons = TestUtlities.GetExtrusionPolygons(layer0Info); // make sure there are 3 Assert.IsTrue(layer0Polygons.Count == 3); // make sure they are in the right order (first layer is outside in) } { // check layer 1 string[] layer1Info = TestUtlities.GetGCodeForLayer(gcode, 1); List <Polygons> layer1Polygons = TestUtlities.GetExtrusionPolygons(layer1Info); // make sure there are 3 Assert.IsTrue(layer1Polygons.Count == 3); // make sure they are in the right order (other layers are inside out) } }
public void DoHas2WallRingsAllTheWayUp(string fileName, int expectedLayerCount, bool checkRadius = false) { string stlFile = TestUtlities.GetStlPath(fileName); string gCodeFile = TestUtlities.GetTempGCodePath(fileName + ".gcode"); ConfigSettings config = new ConfigSettings(); config.InfillPercent = 0; config.NumberOfPerimeters = 1; config.FirstLayerExtrusionWidth = .2; config.LayerThickness = .2; config.NumberOfBottomLayers = 0; config.NumberOfTopLayers = 0; fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(gCodeFile); processor.LoadStlFile(stlFile); // slice and save it processor.DoProcessing(); processor.finalize(); string[] gcodeLines = TestUtlities.LoadGCodeFile(gCodeFile); int layerCount = TestUtlities.CountLayers(gcodeLines); Assert.IsTrue(layerCount == expectedLayerCount); MovementInfo movement = new MovementInfo(); for (int i = 0; i < layerCount - 5; i++) { string[] layerInfo = TestUtlities.GetGCodeForLayer(gcodeLines, i); if (i > 0) { Polygons layerPolygons = TestUtlities.GetExtrusionPolygons(layerInfo, ref movement); Assert.IsTrue(layerPolygons.Count == 2); if (checkRadius) { Assert.IsTrue(layerPolygons[0].Count > 10); Assert.IsTrue(layerPolygons[1].Count > 10); if (false) { foreach (var polygon in layerPolygons) { double radiusForPolygon = polygon[0].LengthMm(); foreach (var point in polygon) { Assert.AreEqual(radiusForPolygon, point.LengthMm(), 15); } } } } } else { TestUtlities.GetExtrusionPolygons(layerInfo, ref movement); } } }