Example #1
0
        private static ExtruderLayers CreateLayerData(Polygons inset0Outline, int numLayers)
        {
            var layerData = new ExtruderLayers
            {
                Layers = new List <SliceLayer>()
            };

            for (int i = 0; i < numLayers; i++)
            {
                var layer = new SliceLayer
                {
                    Islands = new List <LayerIsland>()
                };
                var part = new LayerIsland
                {
                    InsetToolPaths = new List <Polygons>()
                };
                part.InsetToolPaths.Add(inset0Outline);
                part.BoundingBox = new Aabb(inset0Outline);
                layer.Islands.Add(part);
                layerData.Layers.Add(layer);
            }

            return(layerData);
        }
Example #2
0
        private static ExtruderLayers CreateLayerData(List <Polygons> polygonLayers)
        {
            var layerData = new ExtruderLayers
            {
                Layers = new List <SliceLayer>()
            };

            foreach (var polygonLayer in polygonLayers)
            {
                var layer = new SliceLayer
                {
                    Islands = new List <LayerIsland>()
                };
                var part = new LayerIsland
                {
                    InsetToolPaths = new List <Polygons>()
                };
                part.InsetToolPaths.Add(polygonLayer);
                part.BoundingBox = new Aabb(polygonLayer);
                layer.Islands.Add(part);
                layerData.Layers.Add(layer);
            }

            return(layerData);
        }
Example #3
0
        private static (ExtruderLayers, NewSupport) CreateLayerData(ConfigSettings config,
                                                                    List <Polygons> totalLayerOutlines,
                                                                    List <Polygons> supportOutlines)
        {
            int numLayers   = totalLayerOutlines.Count;
            var layerData   = new ExtruderLayers();
            var supportData = new ExtruderLayers();

            layerData.Layers = new List <SliceLayer>();
            for (int layerIndex = 0; layerIndex < numLayers; layerIndex++)
            {
                SliceLayer layer = new SliceLayer();
                layer.AllOutlines = totalLayerOutlines[layerIndex];
                layerData.Layers.Add(layer);

                if (layerIndex < supportOutlines.Count)
                {
                    SliceLayer supportLayer = new SliceLayer();
                    supportLayer.AllOutlines = supportOutlines[layerIndex];
                    supportData.Layers.Add(supportLayer);
                }
            }

            var newSupport = new NewSupport(config, new List <ExtruderLayers>()
            {
                layerData
            }, supportData);

            return(layerData, newSupport);
        }
        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       = CLPolygonsExtensions.CreateFromString(inset0OutlineString);
                int            numLayers           = 10;
                ExtruderLayers extruder            = CreateLayerData(inset0Outline, numLayers);
                GenerateLayers(extruder, 400, 0, 3, 0);
                for (int i = 0; i < 7; i++)
                {
                    Assert.IsTrue(extruder.OnlyHasInfill(i));
                }
                Assert.IsTrue(extruder.OnlyHasFirstTop(7));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(8));
                Assert.IsTrue(extruder.OnlyHasTop(9));
            }

            // 3 bottom layers and 1 top layer
            {
                string         inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|";
                Polygons       inset0Outline       = CLPolygonsExtensions.CreateFromString(inset0OutlineString);
                int            numLayers           = 10;
                ExtruderLayers extruder            = CreateLayerData(inset0Outline, numLayers);
                GenerateLayers(extruder, 400, 3, 1, 0);
                Assert.IsTrue(extruder.OnlyHasBottom(0));
                for (int i = 1; i < 3; i++)
                {
                    Assert.IsTrue(extruder.OnlyHasSolidInfill(i));
                }
                for (int i = 3; i < 9; i++)
                {
                    Assert.IsTrue(extruder.OnlyHasInfill(i));
                }
                Assert.IsTrue(extruder.OnlyHasTop(9));
            }

            // 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       = CLPolygonsExtensions.CreateFromString(inset0OutlineString);
                int            numLayers           = 10;
                ExtruderLayers extruder            = CreateLayerData(inset0Outline, numLayers);
                GenerateLayers(extruder, 400, 3, 3, 0);
                Assert.IsTrue(extruder.OnlyHasBottom(0));
                for (int i = 1; i < 3; i++)
                {
                    Assert.IsTrue(extruder.OnlyHasSolidInfill(i));
                }
                for (int i = 3; i < 7; i++)
                {
                    Assert.IsTrue(extruder.OnlyHasInfill(i));
                }
                Assert.IsTrue(extruder.OnlyHasFirstTop(7));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(8));
                Assert.IsTrue(extruder.OnlyHasTop(9));
            }
        }
Example #5
0
        private static void GenerateLayers(ExtruderLayers extruder, int extrusionWidthUm, int bottomLayers, int topLayers, long infillExtendIntoPerimeter_um)
        {
            int numLayers = extruder.Layers.Count;

            for (int layerIndex = 0; layerIndex < numLayers; layerIndex++)
            {
                extruder.GenerateTopAndBottoms(null, layerIndex, extrusionWidthUm, extrusionWidthUm, bottomLayers, topLayers, infillExtendIntoPerimeter_um);
            }
        }
        private static void GenerateLayers(ExtruderLayers extruder, int extrusionWidthUm, int bottomLayers, int topLayers)
        {
            int numLayers = extruder.Layers.Count;

            for (int layerIndex = 0; layerIndex < numLayers; layerIndex++)
            {
                extruder.GenerateTopAndBottoms(layerIndex, extrusionWidthUm, extrusionWidthUm, bottomLayers, topLayers);
            }
        }
Example #7
0
        private static ExtruderLayers CreateLayerData(List <Polygons> totalLayerOutlines)
        {
            int            numLayers = totalLayerOutlines.Count;
            ExtruderLayers layerData = new ExtruderLayers();

            layerData.Layers = new List <SliceLayer>();
            for (int layerIndex = 0; layerIndex < numLayers; layerIndex++)
            {
                SliceLayer layer = new SliceLayer();
                layer.AllOutlines = totalLayerOutlines[layerIndex];
                layerData.Layers.Add(layer);
            }
            return(layerData);
        }
Example #8
0
        public void CorrectNumberOfBottoms()
        {
            // 3 bottom layers and no top 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       partOutline         = CLPolygonsExtensions.CreateFromString(inset0OutlineString);
                int            numLayers           = 10;
                ExtruderLayers extruder            = CreateLayerData(partOutline, numLayers);
                GenerateLayers(extruder, 400, 3, 0, 0);
                Assert.IsTrue(extruder.OnlyHasBottom(0));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(1));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(2));
                Assert.IsTrue(extruder.OnlyHasInfill(3));
            }

            // 3 bottom layers and 1 top layer
            {
                string         inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|";
                Polygons       inset0Outline       = CLPolygonsExtensions.CreateFromString(inset0OutlineString);
                int            numLayers           = 10;
                ExtruderLayers extruder            = CreateLayerData(inset0Outline, numLayers);
                GenerateLayers(extruder, 400, 3, 1, 0);
                Assert.IsTrue(extruder.OnlyHasBottom(0));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(1));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(2));
                Assert.IsTrue(extruder.OnlyHasInfill(3));
            }

            // 3 bottom layers and 3 top layers
            {
                string         inset0OutlineString = "x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|";
                Polygons       inset0Outline       = CLPolygonsExtensions.CreateFromString(inset0OutlineString);
                int            numLayers           = 10;
                ExtruderLayers extruder            = CreateLayerData(inset0Outline, numLayers);
                GenerateLayers(extruder, 400, 3, 3, 0);
                Assert.IsTrue(extruder.OnlyHasBottom(0));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(1));
                Assert.IsTrue(extruder.OnlyHasSolidInfill(2));
                Assert.IsTrue(extruder.OnlyHasInfill(3));
            }
        }
Example #9
0
        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));
            }
        }
        private static ExtruderLayers CreateLayerData(Polygons inset0Outline, int numLayers)
        {
            ExtruderLayers layerData = new ExtruderLayers();
            layerData.Layers = new List<SliceLayer>();
            for (int i = 0; i < numLayers; i++)
            {
                SliceLayer layer = new SliceLayer();
                layer.Islands = new List<LayerIsland>();
                LayerIsland part = new LayerIsland();
                part.InsetToolPaths = new List<Polygons>();
                part.InsetToolPaths.Add(inset0Outline);
                part.BoundingBox = new Aabb(inset0Outline);
                layer.Islands.Add(part);
                layerData.Layers.Add(layer);
            }

            return layerData;
        }
 private static void GenerateLayers(ExtruderLayers extruder, int extrusionWidthUm, int bottomLayers, int topLayers)
 {
     int numLayers = extruder.Layers.Count;
     for (int layerIndex = 0; layerIndex < numLayers; layerIndex++)
     {
         extruder.GenerateTopAndBottoms(layerIndex, extrusionWidthUm, extrusionWidthUm, bottomLayers, topLayers);
     }
 }
Example #12
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);
                    }
                }
            }
        }
Example #13
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);
                    }
                }
            }
        }
Example #14
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;

                // 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>();
                List <Polygons> supportOutlines          = new List <Polygons>();
                Polygons        bottomCubeOutline        = CLPolygonsExtensions.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);
                    supportOutlines.Add(new Polygons());
                }

                Polygons topCubeOutline = CLPolygonsExtensions.CreateFromString("x:2500, y:2500,x:7500, y:2500,x:7500, y:7500,x:2500, y:7500,|");
                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(new Polygons());
                    supportOutlines.Add(topCubeOutline);
                }

                Polygons topCubeOutlineResults = topCubeOutline.Offset(-200);
                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(topCubeOutline);
                    supportOutlines.Add(new Polygons());
                }

                var            outputs          = CreateLayerData(config, partOutlines, supportOutlines);
                ExtruderLayers layerData        = outputs.Item1;
                NewSupport     supportGenerator = outputs.Item2;

                // 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);
                }

                {
                    Polygons expectedSupportOutlines = topCubeOutlineResults.Offset(200);
                    // 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.SparseSupportOutlines, 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);
                    }
                }
            }
        }
Example #15
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;

                Polygons cubeOutline = CLPolygonsExtensions.CreateFromString("x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|");

                List <Polygons> partOutlines    = new List <Polygons>();
                List <Polygons> supportOutlines = new List <Polygons>();
                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(new Polygons());
                    supportOutlines.Add(cubeOutline);
                }

                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(cubeOutline);
                    supportOutlines.Add(new Polygons());
                }

                var            outputs          = CreateLayerData(config, partOutlines, supportOutlines);
                ExtruderLayers layerData        = outputs.Item1;
                NewSupport     supportGenerator = outputs.Item2;

                Polygons cubeOutlineResults = CLPolygonsExtensions.CreateFromString("x:200, y:200,x:9800, y:200,x:9800, y:9800,x:200, y:9800,|");
                Polygons cubeInfillResults  = CLPolygonsExtensions.CreateFromString("x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|");

                // 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 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>()
                    {
                        cubeInfillResults, cubeInfillResults, cubeInfillResults, cubeInfillResults, cubeInfillResults, null, null, null, null, null
                    };
                    CheckLayers(supportGenerator.SparseSupportOutlines, 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

                Polygons halfCubeOutline = CLPolygonsExtensions.CreateFromString("x:0, y:0,x:5000, y:0,x:5000, y:10000,x:0, y:10000,|");
                Polygons cubeOutline     = CLPolygonsExtensions.CreateFromString("x:0, y:0,x:10000, y:0,x:10000, y:10000,x:0, y:10000,|");

                List <Polygons> supportOutlines = new List <Polygons>();
                List <Polygons> partOutlines    = new List <Polygons>();
                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(new Polygons());
                    supportOutlines.Add(cubeOutline);
                }

                Polygons halfCubeOutlineResults = halfCubeOutline.Offset(-200);
                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(halfCubeOutline);
                    supportOutlines.Add(cubeOutline);
                }

                Polygons cubeOutlineResults = cubeOutline.Offset(-200);
                for (int i = 0; i < 5; i++)
                {
                    partOutlines.Add(cubeOutline);
                }

                var            outputs          = CreateLayerData(config, partOutlines, supportOutlines);
                ExtruderLayers layerData        = outputs.Item1;
                NewSupport     supportGenerator = outputs.Item2;

                // 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 = CLPolygonsExtensions.CreateFromString("x:5000, y:200,x:9800, y:200,x:9800, y:9800,x:5000, y:9800,|");

                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.SparseSupportOutlines, 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);
                    }
                }
            }
        }