Esempio n. 1
0
		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);
					}
				}
			}
		}
Esempio n. 2
0
		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);
					}
				}
			}
		}