Ejemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            // import silkwormSettings file
            List<string> silkwormSettings = new List<string>();
            if (!DA.GetDataList(0, silkwormSettings)) return;

            List<GH_ObjectWrapper> things = new List<GH_ObjectWrapper>();
            if (!DA.GetDataList(1, things)) return;

            // import Silkworm Movement
            #endregion

            SilkwormUtility sUtil = new SilkwormUtility();
            Dictionary<string, string> Settings = sUtil.convertSettings(silkwormSettings);

            #region Optional Variables
            int shell = -999;
            if (!DA.GetData(4, ref shell)) { }
            double layerheight = -999;
            if (!DA.GetData(3, ref layerheight)) { }
            //bool detect = false;
            //if (!DA.GetData(5, ref detect)) { }
            List<Plane> sliceplanes = new List<Plane>();
            if (!DA.GetDataList(2, sliceplanes)) { }

            if (shell == -999)
            {
                shell = int.Parse(Settings["perimeters"]);
            }
            if (layerheight == -999)
            {
                layerheight = double.Parse(Settings["layer_height"]);
            }
            if (sliceplanes.Count<1)
            {
                sliceplanes.Add(Plane.WorldXY);
            }

            #endregion

            List<Brep> Breps = new List<Brep>();

            List<Mesh> Meshes = new List<Mesh>();

            SilkwormSkein skein = new SilkwormSkein();

            #region Sort Types
            foreach (GH_ObjectWrapper obj in things)
            {
                if (obj.Value is GH_Brep)
                {
                    Brep brep = null;
                    GH_Convert.ToBrep(obj.Value, ref brep, GH_Conversion.Both);

                    Breps.Add(brep);
                    continue;

                }

                if (obj.Value is GH_Mesh)
                {
                    Mesh mesh = null;
                    GH_Convert.ToMesh(obj.Value, ref mesh, GH_Conversion.Both);
                    Meshes.Add(mesh);

                    continue;
                }
            }
            #endregion

            if (Breps.Count>0)
            {

                skein = new SilkwormSkein(Settings, Breps, sliceplanes, shell, layerheight);
                skein.BrepSlice(false);

            }

            if (Meshes.Count > 0)
            {

                //TODO
            }

            //Reflect Errors and Warnings

                foreach (string message in skein.ErrorMessages)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, message);

                }
                foreach (string message in skein.WarningMessages)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, message);

                }

            List<Curve>[] openregions = skein.openRegions;

            List<Brep>[] rRegions = skein.Regions;
            List<Brep>[] rPerimeterR = skein.regionPerimeter;
            List<Brep>[]  rInfillR = skein.regionInfill;

            GH_Structure<GH_Brep> Regions = new GH_Structure<GH_Brep>();

            GH_Structure<GH_Curve> openRegions = new GH_Structure<GH_Curve>();

            #region Add Regions to GH_Structure

            if (rRegions.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < rRegions.Length; i++)
                {

                    if (rRegions[i] != null)
                        {
                    for (int j = 0; j < rRegions[i].Count; j++)
                    {

                            GH_Brep gShapes = new GH_Brep(rRegions[i][j]);
                            Regions.Insert(gShapes, new GH_Path(i, 0), j);
                        }

                    }
                }
            }
            if (rPerimeterR.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < rPerimeterR.Length; i++)
                {
            if (rPerimeterR[i] != null)
                        {
                    for (int j = 0; j < rPerimeterR[i].Count; j++)
                    {

                            GH_Brep gShapes = new GH_Brep(rPerimeterR[i][j]);
                            Regions.Insert(gShapes, new GH_Path(i, 1), j);
                        }

                    }
                }
            }
            if (rInfillR.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < rInfillR.Length; i++)
                {
            if (rInfillR[i] != null)
                        {
                    for (int j = 0; j < rInfillR[i].Count; j++)
                    {

                            GH_Brep gShapes = new GH_Brep(rInfillR[i][j]);
                            Regions.Insert(gShapes, new GH_Path(i, 2), j);
                        }

                    }
                }
            }

            if (openregions.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < openregions.Length; i++)
                {
            if (openregions[i] != null)
                        {
                    for (int j = 0; j < openregions[i].Count; j++)
                    {

                            GH_Curve gShapes = new GH_Curve(openregions[i][j]);
                            openRegions.Insert(gShapes, new GH_Path(i), j);
                        }

                    }
                }
            }
            //TODO
            //Add Overhang and Bridges

            #endregion

            #region Add Open Regions to GH_Structure
            if (openregions.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < openregions.Length; i++)
                {

                    for (int j = 0; j < openregions[i].Count; j++)
                    {

                        if (openregions[i][j] != null)
                        {

                            SilkwormSegment segment = new SilkwormSegment(openregions[i][j]);
                            Curve curve = segment.Pline.ToNurbsCurve();
                            GH_Curve gShapes = new GH_Curve(curve);
                            openRegions.Insert(gShapes, new GH_Path(i), j);
                        }

                    }
                }
            }
            #endregion

            #region OUTPUT

            if (!DA.SetDataTree(0, Regions)) { return; }
            if (!DA.SetDataTree(1, openRegions)) { return; }

            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            // import silkwormSettings file
            List <string> silkwormSettings = new List <string>();
            if (!DA.GetDataList(0, silkwormSettings))
            {
                return;
            }

            List <GH_ObjectWrapper> things = new List <GH_ObjectWrapper>();
            if (!DA.GetDataList(1, things))
            {
                return;
            }


            // import Silkworm Movement
            #endregion


            SilkwormUtility             sUtil    = new SilkwormUtility();
            Dictionary <string, string> Settings = sUtil.convertSettings(silkwormSettings);

            #region Optional Variables
            int shell = -999;
            if (!DA.GetData(4, ref shell))
            {
            }
            double layerheight = -999;
            if (!DA.GetData(3, ref layerheight))
            {
            }
            //bool detect = false;
            //if (!DA.GetData(5, ref detect)) { }
            List <Plane> sliceplanes = new List <Plane>();
            if (!DA.GetDataList(2, sliceplanes))
            {
            }

            if (shell == -999)
            {
                shell = int.Parse(Settings["perimeters"]);
            }
            if (layerheight == -999)
            {
                layerheight = double.Parse(Settings["layer_height"]);
            }
            if (sliceplanes.Count < 1)
            {
                sliceplanes.Add(Plane.WorldXY);
            }

            #endregion

            List <Brep> Breps = new List <Brep>();


            List <Mesh> Meshes = new List <Mesh>();

            SilkwormSkein skein = new SilkwormSkein();

            #region Sort Types
            foreach (GH_ObjectWrapper obj in things)
            {
                if (obj.Value is GH_Brep)
                {
                    Brep brep = null;
                    GH_Convert.ToBrep(obj.Value, ref brep, GH_Conversion.Both);

                    Breps.Add(brep);
                    continue;
                }

                if (obj.Value is GH_Mesh)
                {
                    Mesh mesh = null;
                    GH_Convert.ToMesh(obj.Value, ref mesh, GH_Conversion.Both);
                    Meshes.Add(mesh);

                    continue;
                }
            }
            #endregion


            if (Breps.Count > 0)
            {
                skein = new SilkwormSkein(Settings, Breps, sliceplanes, shell, layerheight);
                skein.BrepSlice(false);
            }


            if (Meshes.Count > 0)
            {
                //TODO
            }

            //Reflect Errors and Warnings

            foreach (string message in skein.ErrorMessages)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, message);
            }
            foreach (string message in skein.WarningMessages)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, message);
            }

            List <Curve>[] openregions = skein.openRegions;

            List <Brep>[] rRegions    = skein.Regions;
            List <Brep>[] rPerimeterR = skein.regionPerimeter;
            List <Brep>[] rInfillR    = skein.regionInfill;

            GH_Structure <GH_Brep> Regions = new GH_Structure <GH_Brep>();

            GH_Structure <GH_Curve> openRegions = new GH_Structure <GH_Curve>();


            #region Add Regions to GH_Structure

            if (rRegions.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < rRegions.Length; i++)
                {
                    if (rRegions[i] != null)
                    {
                        for (int j = 0; j < rRegions[i].Count; j++)
                        {
                            GH_Brep gShapes = new GH_Brep(rRegions[i][j]);
                            Regions.Insert(gShapes, new GH_Path(i, 0), j);
                        }
                    }
                }
            }
            if (rPerimeterR.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < rPerimeterR.Length; i++)
                {
                    if (rPerimeterR[i] != null)
                    {
                        for (int j = 0; j < rPerimeterR[i].Count; j++)
                        {
                            GH_Brep gShapes = new GH_Brep(rPerimeterR[i][j]);
                            Regions.Insert(gShapes, new GH_Path(i, 1), j);
                        }
                    }
                }
            }
            if (rInfillR.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < rInfillR.Length; i++)
                {
                    if (rInfillR[i] != null)
                    {
                        for (int j = 0; j < rInfillR[i].Count; j++)
                        {
                            GH_Brep gShapes = new GH_Brep(rInfillR[i][j]);
                            Regions.Insert(gShapes, new GH_Path(i, 2), j);
                        }
                    }
                }
            }

            if (openregions.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < openregions.Length; i++)
                {
                    if (openregions[i] != null)
                    {
                        for (int j = 0; j < openregions[i].Count; j++)
                        {
                            GH_Curve gShapes = new GH_Curve(openregions[i][j]);
                            openRegions.Insert(gShapes, new GH_Path(i), j);
                        }
                    }
                }
            }
            //TODO
            //Add Overhang and Bridges

            #endregion


            #region Add Open Regions to GH_Structure
            if (openregions.GetUpperBound(0) > 1)
            {
                for (int i = 0; i < openregions.Length; i++)
                {
                    for (int j = 0; j < openregions[i].Count; j++)
                    {
                        if (openregions[i][j] != null)
                        {
                            SilkwormSegment segment = new SilkwormSegment(openregions[i][j]);
                            Curve           curve   = segment.Pline.ToNurbsCurve();
                            GH_Curve        gShapes = new GH_Curve(curve);
                            openRegions.Insert(gShapes, new GH_Path(i), j);
                        }
                    }
                }
            }
            #endregion

            #region OUTPUT

            if (!DA.SetDataTree(0, Regions))
            {
                return;
            }
            if (!DA.SetDataTree(1, openRegions))
            {
                return;
            }

            #endregion
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            // import silkwormSettings file
            List<string> silkwormSettings = new List<string>();
            if (!DA.GetDataList(0, silkwormSettings)) return;

            List<Brep> things = new List<Brep>();
            if (!DA.GetDataList(1, things)) return;
            // import Silkworm Movement

            SilkwormUtility sUtil = new SilkwormUtility();
            Dictionary<string, string> Settings = sUtil.convertSettings(silkwormSettings);
            SilkwormCalculator calc = new SilkwormCalculator(Settings);

            #region Optional Inputs

            int infType = 0;
            if (!DA.GetData(2, ref infType)) { }

            List<double> spacing = new List<double>();
            if (!DA.GetDataList(3, spacing)) { }

            List<double> infDens = new List<double>();
            if (!DA.GetDataList(4, infDens)) { }
            List<double> infRot = new List<double>();
            if (!DA.GetDataList(5, infRot)) { }

            #endregion

            if (spacing.Count<1)
            {
                spacing.Add(0.66);
                //TODO Calculator

            }
            if (infDens.Count < 1)
            {
                infDens.Add(double.Parse(Settings["fill_density"]));

            }
            if (infRot.Count < 1)
            {
                infRot.Add(double.Parse(Settings["fill_angle"]));

            }
            #endregion

            SilkwormSkein skein = new SilkwormSkein(Settings, things);

            //Switch depending on which infill type is selected by input
            if (infType == 0)
            {
                //Match length of data
                if (spacing.Count != things.Count)
                {
                    List<double> newspacing = new List<double>();
                    for (int e = 0; e < things.Count; e++)
                    {
                        newspacing.Add(spacing[0]);
                    }
                    spacing = newspacing;
                }

                skein.Skinner(spacing);
            }
            if (infType == 1)
            {
                //Match length of data
                if (infDens.Count != things.Count)
                {
                    List<double> newinfDens = new List<double>();
                    for (int e = 0; e < things.Count; e++)
                    {
                        newinfDens.Add(infDens[0]);
                    }
                    spacing = newinfDens;
                }
                if (infRot.Count != things.Count)
                {
                    List<double> newinfRot = new List<double>();
                    for (int e = 0; e < things.Count; e++)
                    {
                        newinfRot.Add(infRot[0]);
                    }
                    spacing = newinfRot;
                }

                skein.Filler(infDens, infRot);
            }

            //Reflect Errors and Warnings

            foreach (string message in skein.ErrorMessages)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, message);

            }
            foreach (string message in skein.WarningMessages)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, message);

            }

            //Output Holders
            List<Curve>[] plPerimeter = skein.curvePerimeter;
            List<Curve>[] plInfill = skein.curveInfill;

            GH_Structure<GH_Curve> InfillRegion = new GH_Structure<GH_Curve>();

            //Create GH_Structure
            #region Create Structure from Curves

            if (plPerimeter.Length > 0)
            {
                for (int i = 0; i < plPerimeter.Length; i++)
                {
                  if (plPerimeter[i] != null)
                        {
                    for (int j = 0; j < plPerimeter[i].Count; j++)
                    {

                            Curve aShape = plPerimeter[i][j].ToNurbsCurve();

                            GH_Curve gShapes = new GH_Curve(aShape);
                            InfillRegion.Insert(gShapes, new GH_Path(i, 0), j);
                            //}
                        }
                    }
                }
            }
            if (plInfill.Length > 0)
            {
                for (int i = 0; i < plInfill.Length; i++)
                {
            if (plInfill[i] != null)
                        {
                    for (int j = 0; j < plInfill[i].Count; j++)
                    {

                            Curve aShape = plInfill[i][j].ToNurbsCurve();

                            GH_Curve gShapes = new GH_Curve(aShape);
                            InfillRegion.Insert(gShapes, new GH_Path(i, 1), j);
                        }
                    }
                }
            }

            #endregion

            //Output
            if (!DA.SetDataTree(0, InfillRegion)) { return; }
        }
Ejemplo n.º 4
0
        public List<SilkwormMovement> addsolidBrep(Dictionary<string, string> Settings, List<Brep> solids)
        {
            List<SilkwormMovement> unMovements = new List<SilkwormMovement>();

            //List<Brep> solidS = new List<Brep>();
            //solidS.Add((Brep)solid);
            int shell = int.Parse(Settings["perimeters"]);
            int verticalshell = int.Parse(Settings["solid_layers"]);
            double filldensity = double.Parse(Settings["fill_density"]);
            double fillangle = (double.Parse(Settings["fill_density"])/0.0174532925);
            double layerheight = double.Parse(Settings["layer_height"]);
            List<Plane> sliceplanes = new List<Plane>();
            sliceplanes.Add(Plane.WorldXY);

            List<Polyline> pInfill = new List<Polyline>();

            //Slice, Skin and Fill Breps
            SilkwormSkein solidskein = new SilkwormSkein(Settings, solids, sliceplanes, shell, layerheight);
            solidskein.BrepSlice(false);

            if (solidskein.validPos)
            {
                List<Curve> cInfill = new List<Curve>();

                //Use imported settings for shelling and infilling

                List<double>[] spacing = new List<double>[solidskein.slicePlanes.Count];
                for (int c = 0; c < solidskein.slicePlanes.Count; c++)
                {
                    spacing[c] = new List<double>();
                    spacing[c].Add(0.66);
                }
                List<double>[] infDens = new List<double>[solidskein.slicePlanes.Count];
                for (int a = 0; a < solidskein.slicePlanes.Count; a++)
                {
                    if (a < verticalshell)
                    {
                        infDens[a] = new List<double>();
                        infDens[a].Add(1.0);
                    }
                    else if (a >= solidskein.slicePlanes.Count - verticalshell)
                    {
                        infDens[a] = new List<double>();
                        infDens[a].Add(1.0);
                    }
                    else
                    {
                        infDens[a] = new List<double>();
                        infDens[a].Add(filldensity);
                    }
                }

                List<double>[] infRot = new List<double>[solidskein.slicePlanes.Count];
                for (int b = 0; b < solidskein.slicePlanes.Count; b++)
                {
                    if (IsOdd(b))
                    {
                        infRot[b] = new List<double>();
                        infRot[b].Add(fillangle + 90);
                    }
                    else
                    {
                        infRot[b] = new List<double>();
                        infRot[b].Add(fillangle);
                    }
                }

                if (solidskein.openRegions.Length > 0)
                {

                    for (int h = 0; h < solidskein.openRegions.Length; h++)
                    {

                        if (solidskein.openRegions[h] != null)
                        {
                            cInfill.AddRange(solidskein.openRegions[h]);
                        }
                    }
                }

                if (solidskein.Regions.Length > 0)
                {

                    for (int h = 0; h < solidskein.Regions.Length; h++)
                    {

                        if (solidskein.Regions[h] != null)
                        {
                            SilkwormSkein planarskein = new SilkwormSkein(Settings, solidskein.Regions[h]);
                            planarskein.Filler(infDens[h], infRot[h]);

                            for (int i = 0; i < planarskein.curvePerimeter.Length; i++)
                            {
                                cInfill.AddRange(planarskein.curvePerimeter[i]);
                            }
                        }

                    }
                }

                if (solidskein.regionPerimeter.Length > 0)
                {

                    for (int h = 0; h < solidskein.regionPerimeter.Length; h++)
                    {

                        if (solidskein.regionPerimeter[h] != null)
                        {
                            SilkwormSkein planarskein = new SilkwormSkein(Settings, solidskein.regionPerimeter[h]);
                            planarskein.Skinner(spacing[h]);

                            for (int i = 0; i < planarskein.curvePerimeter.Length; i++)
                            {
                                cInfill.AddRange(planarskein.curvePerimeter[i]);
                            }
                        }

                    }
                }

                if (solidskein.regionInfill.Length > 0)
                {

                    for (int h = 0; h < solidskein.regionInfill.Length; h++)
                    {

                        if (solidskein.regionInfill[h] != null)
                        {
                            SilkwormSkein planarskein = new SilkwormSkein(Settings, solidskein.regionInfill[h]);
                            planarskein.Filler(infDens[h], infRot[h]);

                            for (int i = 0; i < planarskein.curveInfill.Length; i++)
                            {
                                cInfill.AddRange(planarskein.curveInfill[i]);
                            }
                        }

                    }
                }

                if (solidskein.regionOverhangs.Length > 0)
                {

                    //TODO
                }

                if (solidskein.regionBridges.Length > 0)
                {

                    //TODO
                }

                //Segment Curves
                foreach (Curve curve in cInfill)
                {
                    SilkwormSegment segment = new SilkwormSegment(curve);
                    pInfill.Add(segment.Pline);
                }

            }

            List<SilkwormMovement> solidMovements = new List<SilkwormMovement>();

            //Add to List of Movements

            foreach (Polyline pline in pInfill)
            {
                //List<SilkwormMovement> sList = new List<SilkwormMovement>();
                //sList.Add(new SilkwormMovement(Settings, pline, true));
                solidMovements.Add(new SilkwormMovement(Settings, pline));
            }

            unMovements.AddRange(solidMovements);

            return unMovements;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            // import silkwormSettings file
            List <string> silkwormSettings = new List <string>();
            if (!DA.GetDataList(0, silkwormSettings))
            {
                return;
            }

            List <Brep> things = new List <Brep>();
            if (!DA.GetDataList(1, things))
            {
                return;
            }
            // import Silkworm Movement


            SilkwormUtility             sUtil    = new SilkwormUtility();
            Dictionary <string, string> Settings = sUtil.convertSettings(silkwormSettings);
            SilkwormCalculator          calc     = new SilkwormCalculator(Settings);

            #region Optional Inputs

            int infType = 0;
            if (!DA.GetData(2, ref infType))
            {
            }

            List <double> spacing = new List <double>();
            if (!DA.GetDataList(3, spacing))
            {
            }

            List <double> infDens = new List <double>();
            if (!DA.GetDataList(4, infDens))
            {
            }
            List <double> infRot = new List <double>();
            if (!DA.GetDataList(5, infRot))
            {
            }

            #endregion

            if (spacing.Count < 1)
            {
                spacing.Add(0.66);
                //TODO Calculator
            }
            if (infDens.Count < 1)
            {
                infDens.Add(double.Parse(Settings["fill_density"]));
            }
            if (infRot.Count < 1)
            {
                infRot.Add(double.Parse(Settings["fill_angle"]));
            }
            #endregion

            SilkwormSkein skein = new SilkwormSkein(Settings, things);

            //Switch depending on which infill type is selected by input
            if (infType == 0)
            {
                //Match length of data
                if (spacing.Count != things.Count)
                {
                    List <double> newspacing = new List <double>();
                    for (int e = 0; e < things.Count; e++)
                    {
                        newspacing.Add(spacing[0]);
                    }
                    spacing = newspacing;
                }

                skein.Skinner(spacing);
            }
            if (infType == 1)
            {
                //Match length of data
                if (infDens.Count != things.Count)
                {
                    List <double> newinfDens = new List <double>();
                    for (int e = 0; e < things.Count; e++)
                    {
                        newinfDens.Add(infDens[0]);
                    }
                    spacing = newinfDens;
                }
                if (infRot.Count != things.Count)
                {
                    List <double> newinfRot = new List <double>();
                    for (int e = 0; e < things.Count; e++)
                    {
                        newinfRot.Add(infRot[0]);
                    }
                    spacing = newinfRot;
                }


                skein.Filler(infDens, infRot);
            }

            //Reflect Errors and Warnings

            foreach (string message in skein.ErrorMessages)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, message);
            }
            foreach (string message in skein.WarningMessages)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, message);
            }

            //Output Holders
            List <Curve>[] plPerimeter = skein.curvePerimeter;
            List <Curve>[] plInfill    = skein.curveInfill;



            GH_Structure <GH_Curve> InfillRegion = new GH_Structure <GH_Curve>();

            //Create GH_Structure
            #region Create Structure from Curves

            if (plPerimeter.Length > 0)
            {
                for (int i = 0; i < plPerimeter.Length; i++)
                {
                    if (plPerimeter[i] != null)
                    {
                        for (int j = 0; j < plPerimeter[i].Count; j++)
                        {
                            Curve aShape = plPerimeter[i][j].ToNurbsCurve();


                            GH_Curve gShapes = new GH_Curve(aShape);
                            InfillRegion.Insert(gShapes, new GH_Path(i, 0), j);
                            //}
                        }
                    }
                }
            }
            if (plInfill.Length > 0)
            {
                for (int i = 0; i < plInfill.Length; i++)
                {
                    if (plInfill[i] != null)
                    {
                        for (int j = 0; j < plInfill[i].Count; j++)
                        {
                            Curve aShape = plInfill[i][j].ToNurbsCurve();

                            GH_Curve gShapes = new GH_Curve(aShape);
                            InfillRegion.Insert(gShapes, new GH_Path(i, 1), j);
                        }
                    }
                }
            }

            #endregion

            //Output
            if (!DA.SetDataTree(0, InfillRegion))
            {
                return;
            }
        }
Ejemplo n.º 6
0
        public List <SilkwormMovement> addsolidBrep(Dictionary <string, string> Settings, List <Brep> solids)
        {
            List <SilkwormMovement> unMovements = new List <SilkwormMovement>();

            //List<Brep> solidS = new List<Brep>();
            //solidS.Add((Brep)solid);
            int          shell         = int.Parse(Settings["perimeters"]);
            int          verticalshell = int.Parse(Settings["solid_layers"]);
            double       filldensity   = double.Parse(Settings["fill_density"]);
            double       fillangle     = (double.Parse(Settings["fill_density"]) / 0.0174532925);
            double       layerheight   = double.Parse(Settings["layer_height"]);
            List <Plane> sliceplanes   = new List <Plane>();

            sliceplanes.Add(Plane.WorldXY);

            List <Polyline> pInfill = new List <Polyline>();

            //Slice, Skin and Fill Breps
            SilkwormSkein solidskein = new SilkwormSkein(Settings, solids, sliceplanes, shell, layerheight);

            solidskein.BrepSlice(false);

            if (solidskein.validPos)
            {
                List <Curve> cInfill = new List <Curve>();

                //Use imported settings for shelling and infilling


                List <double>[] spacing = new List <double> [solidskein.slicePlanes.Count];
                for (int c = 0; c < solidskein.slicePlanes.Count; c++)
                {
                    spacing[c] = new List <double>();
                    spacing[c].Add(0.66);
                }
                List <double>[] infDens = new List <double> [solidskein.slicePlanes.Count];
                for (int a = 0; a < solidskein.slicePlanes.Count; a++)
                {
                    if (a < verticalshell)
                    {
                        infDens[a] = new List <double>();
                        infDens[a].Add(1.0);
                    }
                    else if (a >= solidskein.slicePlanes.Count - verticalshell)
                    {
                        infDens[a] = new List <double>();
                        infDens[a].Add(1.0);
                    }
                    else
                    {
                        infDens[a] = new List <double>();
                        infDens[a].Add(filldensity);
                    }
                }

                List <double>[] infRot = new List <double> [solidskein.slicePlanes.Count];
                for (int b = 0; b < solidskein.slicePlanes.Count; b++)
                {
                    if (IsOdd(b))
                    {
                        infRot[b] = new List <double>();
                        infRot[b].Add(fillangle + 90);
                    }
                    else
                    {
                        infRot[b] = new List <double>();
                        infRot[b].Add(fillangle);
                    }
                }

                if (solidskein.openRegions.Length > 0)
                {
                    for (int h = 0; h < solidskein.openRegions.Length; h++)
                    {
                        if (solidskein.openRegions[h] != null)
                        {
                            cInfill.AddRange(solidskein.openRegions[h]);
                        }
                    }
                }

                if (solidskein.Regions.Length > 0)
                {
                    for (int h = 0; h < solidskein.Regions.Length; h++)
                    {
                        if (solidskein.Regions[h] != null)
                        {
                            SilkwormSkein planarskein = new SilkwormSkein(Settings, solidskein.Regions[h]);
                            planarskein.Filler(infDens[h], infRot[h]);

                            for (int i = 0; i < planarskein.curvePerimeter.Length; i++)
                            {
                                cInfill.AddRange(planarskein.curvePerimeter[i]);
                            }
                        }
                    }
                }

                if (solidskein.regionPerimeter.Length > 0)
                {
                    for (int h = 0; h < solidskein.regionPerimeter.Length; h++)
                    {
                        if (solidskein.regionPerimeter[h] != null)
                        {
                            SilkwormSkein planarskein = new SilkwormSkein(Settings, solidskein.regionPerimeter[h]);
                            planarskein.Skinner(spacing[h]);

                            for (int i = 0; i < planarskein.curvePerimeter.Length; i++)
                            {
                                cInfill.AddRange(planarskein.curvePerimeter[i]);
                            }
                        }
                    }
                }


                if (solidskein.regionInfill.Length > 0)
                {
                    for (int h = 0; h < solidskein.regionInfill.Length; h++)
                    {
                        if (solidskein.regionInfill[h] != null)
                        {
                            SilkwormSkein planarskein = new SilkwormSkein(Settings, solidskein.regionInfill[h]);
                            planarskein.Filler(infDens[h], infRot[h]);

                            for (int i = 0; i < planarskein.curveInfill.Length; i++)
                            {
                                cInfill.AddRange(planarskein.curveInfill[i]);
                            }
                        }
                    }
                }

                if (solidskein.regionOverhangs.Length > 0)
                {
                    //TODO
                }

                if (solidskein.regionBridges.Length > 0)
                {
                    //TODO
                }

                //Segment Curves
                foreach (Curve curve in cInfill)
                {
                    SilkwormSegment segment = new SilkwormSegment(curve);
                    pInfill.Add(segment.Pline);
                }
            }

            List <SilkwormMovement> solidMovements = new List <SilkwormMovement>();

            //Add to List of Movements

            foreach (Polyline pline in pInfill)
            {
                //List<SilkwormMovement> sList = new List<SilkwormMovement>();
                //sList.Add(new SilkwormMovement(Settings, pline, true));
                solidMovements.Add(new SilkwormMovement(Settings, pline));
            }


            unMovements.AddRange(solidMovements);

            return(unMovements);
        }