public void InsideOutsidePoints() { { // a square with a hole (outside is ccw inside is cw) // __________ // | _____ | // | | | | // | |____| | // |________| string partOutlineString = "x:0, y:0,x:1000, y:0,x:1000, y:1000,x:0, y:1000,|x:100, y:100,x:0, y:900,x:900, y:900,x:900, y:0,|"; Polygons boundaryPolygons = PolygonsHelper.CreateFromString(partOutlineString); AvoidCrossingPerimeters testHarness = new AvoidCrossingPerimeters(boundaryPolygons); Assert.IsTrue(testHarness.PointIsInsideBoundary(new IntPoint(1, 1))); } // Here is a test case that was failing. { // Looks a little like this // _____ // | | // | O | // | O | // |___| string partOutlineString = "x:90501, y:80501,x:109500, y:80501,x:109500, y:119500,x:90501, y:119500,|x:97387, y:104041,x:95594, y:105213,x:94278, y:106903,x:93583, y:108929,x:93583, y:111071,x:94278, y:113097,x:95594, y:114787,x:97387, y:115959,x:99464, y:116485,x:101598, y:116307,x:103559, y:115447,x:105135, y:113996,x:106154, y:112113,x:106507, y:110000,x:106154, y:107887,x:105135, y:106004,x:103559, y:104553,x:101598, y:103693,x:99464, y:103515,|x:97387, y:84042,x:95594, y:85214,x:94278, y:86904,x:93583, y:88930,x:93583, y:91072,x:94278, y:93098,x:95594, y:94788,x:97387, y:95960,x:99464, y:96486,x:101598, y:96308,x:103559, y:95448,x:105135, y:93997,x:106154, y:92114,x:106507, y:90001,x:106154, y:87888,x:105135, y:86005,x:103559, y:84554,x:101598, y:83694,x:99464, y:83516,|"; Polygons boundaryPolygons = PolygonsHelper.CreateFromString(partOutlineString); IntPoint startPoint = new IntPoint(95765, 114600); IntPoint endPoint = new IntPoint(99485, 96234); AvoidCrossingPerimeters testHarness = new AvoidCrossingPerimeters(boundaryPolygons); { IntPoint startPointInside = startPoint; testHarness.MovePointInsideBoundary(ref startPointInside); IntPoint endPointInside = endPoint; testHarness.MovePointInsideBoundary(ref endPointInside); Assert.IsTrue(testHarness.PointIsInsideBoundary(startPointInside)); Assert.IsTrue(testHarness.PointIsInsideBoundary(endPointInside)); Polygon insidePath = new Polygon(); testHarness.CreatePathInsideBoundary(startPointInside, endPointInside, insidePath); Assert.IsTrue(insidePath.Count > 10); // It needs to go around the cicle so it needs many points (2 is a definate fail). } { Polygon insidePath = new Polygon(); testHarness.CreatePathInsideBoundary(startPoint, endPoint, insidePath); Assert.IsTrue(insidePath.Count > 12); // two more than the last test to get the points in the right place } } }
private static double GetAngleForData(string islandToFillString, string layerSupportingIslandString, string debugName) { Polygons islandToFill = PolygonsHelper.CreateFromString(islandToFillString); SliceLayer prevLayer = new SliceLayer(); prevLayer.Islands = new List <LayerIsland>(); LayerIsland part = new LayerIsland(); part.IslandOutline = PolygonsHelper.CreateFromString(layerSupportingIslandString); prevLayer.Islands.Add(part); prevLayer.Islands[0].BoundingBox.Calculate(prevLayer.Islands[0].IslandOutline); double bridgeAngle; bool foundBridgeAngle = prevLayer.BridgeAngle(islandToFill, out bridgeAngle, debugName); return(bridgeAngle); }
private static double GetAngleForData(string outlineString, string partOutlineString, string debugName) { Polygons outline = PolygonsHelper.CreateFromString(outlineString); SliceLayer prevLayer = new SliceLayer(); prevLayer.parts = new List <SliceLayerPart>(); SliceLayerPart part = new SliceLayerPart(); part.TotalOutline = PolygonsHelper.CreateFromString(partOutlineString); prevLayer.parts.Add(part); prevLayer.parts[0].BoundingBox.Calculate(prevLayer.parts[0].TotalOutline); double bridgeAngle; Bridge.BridgeAngle(outline, prevLayer, out bridgeAngle, debugName); return(bridgeAngle); }
public void CorrectNumberOfTops() { // 3 top layers and no bottom layers { // A simple cube that should have enough bottom layers string inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"; Polygons inset0Outline = PolygonsHelper.CreateFromString(inset0OutlineString); int numLayers = 10; ExtruderLayers extruder = CreateLayerData(inset0Outline, numLayers); GenerateLayers(extruder, 400, 0, 3); Assert.IsTrue(extruder.OnlyHasTop(9)); Assert.IsTrue(extruder.OnlyHasSolidInfill(8)); Assert.IsTrue(extruder.OnlyHasSolidInfill(7)); Assert.IsTrue(extruder.OnlyHasInfill(6)); } // 3 top layers and 1 bottom layer { string inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"; Polygons inset0Outline = PolygonsHelper.CreateFromString(inset0OutlineString); int numLayers = 10; ExtruderLayers extruder = CreateLayerData(inset0Outline, numLayers); GenerateLayers(extruder, 400, 3, 1); Assert.IsTrue(extruder.OnlyHasBottom(0)); Assert.IsTrue(extruder.OnlyHasSolidInfill(1)); Assert.IsTrue(extruder.OnlyHasSolidInfill(2)); Assert.IsTrue(extruder.OnlyHasInfill(3)); } // 3 top layers and 3 bottom layers { string inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"; Polygons inset0Outline = PolygonsHelper.CreateFromString(inset0OutlineString); int numLayers = 10; ExtruderLayers extruder = CreateLayerData(inset0Outline, numLayers); GenerateLayers(extruder, 400, 3, 3); Assert.IsTrue(extruder.OnlyHasBottom(0)); Assert.IsTrue(extruder.OnlyHasSolidInfill(1)); Assert.IsTrue(extruder.OnlyHasSolidInfill(2)); Assert.IsTrue(extruder.OnlyHasInfill(3)); } }
public void CorrectNumberOfTops() { // 3 top layers and no bottom layers { // A simple cube that should have enough bottom layers string inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"; Polygons inset0Outline = PolygonsHelper.CreateFromString(inset0OutlineString); int numLayers = 10; SliceVolumeStorage layerData = CreateLayerData(inset0Outline, numLayers); GenerateLayers(layerData, 400, 0, 3); Assert.IsTrue(OnlyHasTop(layerData, 9)); Assert.IsTrue(OnlyHasSolidInfill(layerData, 8)); Assert.IsTrue(OnlyHasSolidInfill(layerData, 7)); Assert.IsTrue(OnlyHasInfill(layerData, 6)); } // 3 top layers and 1 bottom layer { string inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"; Polygons inset0Outline = PolygonsHelper.CreateFromString(inset0OutlineString); int numLayers = 10; SliceVolumeStorage layerData = CreateLayerData(inset0Outline, numLayers); GenerateLayers(layerData, 400, 3, 1); Assert.IsTrue(OnlyHasBottom(layerData, 0)); Assert.IsTrue(OnlyHasSolidInfill(layerData, 1)); Assert.IsTrue(OnlyHasSolidInfill(layerData, 2)); Assert.IsTrue(OnlyHasInfill(layerData, 3)); } // 3 top layers and 3 bottom layers { string inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"; Polygons inset0Outline = PolygonsHelper.CreateFromString(inset0OutlineString); int numLayers = 10; SliceVolumeStorage layerData = CreateLayerData(inset0Outline, numLayers); GenerateLayers(layerData, 400, 3, 3); Assert.IsTrue(OnlyHasBottom(layerData, 0)); Assert.IsTrue(OnlyHasSolidInfill(layerData, 1)); Assert.IsTrue(OnlyHasSolidInfill(layerData, 2)); Assert.IsTrue(OnlyHasInfill(layerData, 3)); } }
public void TestCorrectSupportLayer() { // test the supports for a simple cube in the air { ConfigSettings config = new ConfigSettings(); config.LayerThickness = .5; config.SupportXYDistanceFromObject = 0; config.SupportInterfaceLayers = 0; config.MinimizeSupportColumns = false; List <Polygons> partOutlines = new List <Polygons>(); for (int i = 0; i < 5; i++) { partOutlines.Add(new Polygons()); } Polygons cubeOutline = PolygonsHelper.CreateFromString("x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"); for (int i = 0; i < 5; i++) { partOutlines.Add(cubeOutline); } ExtruderLayers layerData = CreateLayerData(partOutlines); NewSupport supportGenerator = new NewSupport(config, new List <ExtruderLayers>() { layerData }, 0); Polygons cubeOutlineResults = PolygonsHelper.CreateFromString("x:200, y:200,x:9800, y:200,x:9800, y:9800,x:200, y:9800,|"); // check the all part outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, }; CheckLayers(supportGenerator.insetPartOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the potential support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, cubeOutlineResults, null, null, null, null, null }; CheckLayers(supportGenerator.allPotentialSupportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the required support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, cubeOutlineResults, null, null, null, null, null }; CheckLayers(supportGenerator.allRequiredSupportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the generated support outlines { List <int> polygonsCounts = new List <int> { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, null, null, null, null, null }; CheckLayers(supportGenerator.supportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the interface support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, null, null, null, null, null }; CheckLayers(supportGenerator.interfaceLayers, polygonsCounts, polygon0Counts, poly0Paths); } } // test the supports for a cube that is 1/2 width just under the main part { ConfigSettings config = new ConfigSettings(); config.SupportInterfaceLayers = 0; config.LayerThickness = .5; config.SupportXYDistanceFromObject = .1; // 14 XXXXXXXXXXXXXXXXXXXX // 13 XXXXXXXXXXXXXXXXXXXX // 12 XXXXXXXXXXXXXXXXXXXX // 11 XXXXXXXXXXXXXXXXXXXX // 10 XXXXXXXXXXXXXXXXXXXX // 9 XXXXXXXXXX <- interface layer // 8 XXXXXXXXXX <- interface layer // 7 XXXXXXXXXX ^ - requires support // 6 XXXXXXXXXX // 5 XXXXXXXXXX // 4 <- interface layer // 3 <- interface layer // 2 ^ - requires support // 1 // 0 List <Polygons> partOutlines = new List <Polygons>(); for (int i = 0; i < 5; i++) { partOutlines.Add(new Polygons()); } Polygons halfCubeOutline = PolygonsHelper.CreateFromString("x:0, y:0,x:5000, y:0,x:5000, y:10000,x:0, y:10000,|"); Polygons halfCubeOutlineResults = halfCubeOutline.Offset(-200); for (int i = 0; i < 5; i++) { partOutlines.Add(halfCubeOutline); } Polygons cubeOutline = PolygonsHelper.CreateFromString("x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"); Polygons cubeOutlineResults = cubeOutline.Offset(-200); for (int i = 0; i < 5; i++) { partOutlines.Add(cubeOutline); } ExtruderLayers layerData = CreateLayerData(partOutlines); NewSupport supportGenerator = new NewSupport(config, new List <ExtruderLayers>() { layerData }, 1); // check the all part outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, halfCubeOutlineResults, halfCubeOutlineResults, halfCubeOutlineResults, halfCubeOutlineResults, halfCubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, }; CheckLayers(supportGenerator.insetPartOutlines, polygonsCounts, polygon0Counts, poly0Paths); } Polygons layer9Support = PolygonsHelper.CreateFromString("x:5000, y:200,x:9800, y:200,x:9800, y:9800,x:5000, y:9800,|"); // check the potential support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, halfCubeOutlineResults, null, null, null, null, layer9Support, null, null, null, null, null }; CheckLayers(supportGenerator.allPotentialSupportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the required support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, halfCubeOutlineResults, null, null, null, null, layer9Support, null, null, null, null, null }; CheckLayers(supportGenerator.allRequiredSupportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } if (false) { // check the generated support outlines { List <int> polygonsCounts = new List <int> { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 4, 4, 4, 4, 4, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, cubeOutlineResults, null, null, null, null, null }; CheckLayers(supportGenerator.supportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the interface support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, null, null, null, null, null }; CheckLayers(supportGenerator.interfaceLayers, polygonsCounts, polygon0Counts, poly0Paths); } } } }
public void TestBottomLayerAirGap() { // test the supports for a cube that is 1/2 width just under the main part { ConfigSettings config = new ConfigSettings(); config.SupportInterfaceLayers = 2; config.LayerThickness = .5; config.SupportXYDistanceFromObject = .1; config.MinimizeSupportColumns = false; // 14 XXXXXXXXXX // 13 XXXXXXXXXX // 12 XXXXXXXXXX // 11 XXXXXXXXXX // 10 XXXXXXXXXX <- at air gap height // 9 <- interface layer // 8 <- interface layer // 7 ^ - requires support // 6 // 5 <- at air gap height // 4 XXXXXXXXXXXXXXXXXXXX // 3 XXXXXXXXXXXXXXXXXXXX // 1 XXXXXXXXXXXXXXXXXXXX // 1 XXXXXXXXXXXXXXXXXXXX // 0 XXXXXXXXXXXXXXXXXXXX List <Polygons> partOutlines = new List <Polygons>(); Polygons bottomCubeOutline = PolygonsHelper.CreateFromString("x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|"); Polygons bottomCubeOutlineResults = bottomCubeOutline.Offset(-200); for (int i = 0; i < 5; i++) { partOutlines.Add(bottomCubeOutline); } for (int i = 0; i < 5; i++) { partOutlines.Add(new Polygons()); } Polygons topCubeOutline = PolygonsHelper.CreateFromString("x:2500, y:2500,x:7500, y:2500,x:7500, y:7500,x:2500, y:7500,|"); Polygons topCubeOutlineResults = topCubeOutline.Offset(-200); for (int i = 0; i < 5; i++) { partOutlines.Add(topCubeOutline); } ExtruderLayers layerData = CreateLayerData(partOutlines); NewSupport supportGenerator = new NewSupport(config, new List <ExtruderLayers>() { layerData }, 1); // check the all part outlines { List <int> polygonsCounts = new List <int> { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, }; List <int> polygon0Counts = new List <int> { 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, }; List <Polygons> poly0Paths = new List <Polygons>() { bottomCubeOutlineResults, bottomCubeOutlineResults, bottomCubeOutlineResults, bottomCubeOutlineResults, bottomCubeOutlineResults, null, null, null, null, null, topCubeOutlineResults, topCubeOutlineResults, topCubeOutlineResults, topCubeOutlineResults, topCubeOutlineResults, }; CheckLayers(supportGenerator.insetPartOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the potential support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, null, null, null, null, topCubeOutlineResults, null, null, null, null, null }; CheckLayers(supportGenerator.allPotentialSupportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the required support outlines { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, null, null, null, null, topCubeOutlineResults, null, null, null, null, null }; CheckLayers(supportGenerator.allRequiredSupportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } { Polygons expectedSupportOutlines = topCubeOutlineResults.Offset(1000); // check the air gapped bottom support outlines (only 5) { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, expectedSupportOutlines, null, null, null, null, null, null }; CheckLayers(supportGenerator.airGappedBottomOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the generated support outlines (only 6 and 7) { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, null, expectedSupportOutlines, expectedSupportOutlines, null, null, null, null }; CheckLayers(supportGenerator.supportOutlines, polygonsCounts, polygon0Counts, poly0Paths); } // check the interface support outlines (8 and 9) { List <int> polygonsCounts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, }; List <int> polygon0Counts = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, }; List <Polygons> poly0Paths = new List <Polygons>() { null, null, null, null, null, null, null, null, expectedSupportOutlines, expectedSupportOutlines, null, null, null, null, null, }; CheckLayers(supportGenerator.interfaceLayers, polygonsCounts, polygon0Counts, poly0Paths); } } } }