Example #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Input Holders
            List <double>           Flow     = new List <double>();
            List <double>           Speed    = new List <double>();
            List <GH_ObjectWrapper> Movement = new List <GH_ObjectWrapper>();
            GH_ObjectWrapper        dObject  = new GH_ObjectWrapper();

            List <SilkwormLine> sMovement = new List <SilkwormLine>();


            //Input
            if (!DA.GetData(3, ref dObject))
            {
            }

            if (!DA.GetDataList(1, Speed))
            {
            }

            if (!DA.GetDataList(2, Flow))
            {
            }

            if (!DA.GetDataList(0, Movement))
            {
                return;
            }


            //Fill Input with placeholders if empty
            if (Speed.Count < 1)
            {
                for (int j = 0; j < Movement.Count; j++)
                {
                    Speed.Add(-1);
                }
            }
            if (Speed.Count == 1)
            {
                if (Movement.Count > 1)
                {
                    for (int j = 0; j < Movement.Count; j++)
                    {
                        Speed.Add(Speed[0]);
                    }
                }
            }
            if (Flow.Count < 1)
            {
                for (int k = 0; k < Movement.Count; k++)
                {
                    Flow.Add(-1);
                }
            }
            if (Flow.Count == 1)
            {
                if (Movement.Count > 1)
                {
                    for (int k = 0; k < Movement.Count; k++)
                    {
                        Flow.Add(Flow[0]);
                    }
                }
            }


            #region Sort Geometric Input
            List <Curve>   curves = new List <Curve>();
            List <Line>    lines  = new List <Line>();
            List <Point3d> points = new List <Point3d>();

            foreach (GH_ObjectWrapper Goo in Movement)
            {
                if (Goo.Value is GH_Curve)
                {
                    Curve curve = null;
                    GH_Convert.ToCurve(Goo.Value, ref curve, GH_Conversion.Both);
                    curves.Add(curve);
                    continue;
                }
                if (Goo.Value is GH_Line)
                {
                    Line line = new Line();
                    GH_Convert.ToLine(Goo.Value, ref line, GH_Conversion.Both);
                    lines.Add(line);
                    continue;
                }

                if (Goo.Value is GH_Point)
                {
                    Point3d point = new Point3d();
                    GH_Convert.ToPoint3d(Goo.Value, ref point, GH_Conversion.Both);
                    points.Add(point);
                    continue;
                }
            }
            #endregion

            #region Sort Numerical Input
            #endregion

            //Output Holder
            SilkwormMovement sModel = new SilkwormMovement();

            //Convert Different Geometry types to Movements based on input parameters
            #region Catch Exceptions
            if (points.Count > 1 || curves.Count > 1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Only one curve or point per movement");
            }
            if (points.Count == 1 || curves.Count == 1)
            {
                if (Flow.Count > 1 || Speed.Count > 1)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Flow or Speed Values do not match length of Input");
                }
            }
            #endregion

            #region if curve
            ////Make Silkworm Lines
            if (curves.Count > 0 && curves.Count < 2)
            {
                List <Line>     sLines    = new List <Line>();
                Curve           newcurve  = curves[0];
                SilkwormSegment segmented = new SilkwormSegment(newcurve);

                //Make lines from curves
                foreach (Curve curve in segmented.Segments)
                {
                    Line line = new Line(curve.PointAtStart, curve.PointAtEnd);
                    sLines.Add(line);
                }

                //Create Silkworm Line from each line and a single flow or speed value
                for (int i = 0; i < sLines.Count; i++)
                {
                    SilkwormLine sLine = new SilkwormLine(Flow[0], Speed[0], sLines[i]);
                    sMovement.Add(sLine);
                }

                //Add Custom Delimiter or Default Delimiter (depending if input is provided)
                if (dObject.Value is Delimiter)
                {
                    Delimiter delimiter = (Delimiter)dObject.Value;

                    sModel = new SilkwormMovement(sMovement, delimiter);
                }
                else
                {
                    sModel = new SilkwormMovement(sMovement, new Delimiter());
                }
            }
            #endregion

            #region if lines
            //Make Silkworm Lines
            if (lines.Count > 0)
            {
                #region More Error Catching
                if (Flow.Count > 1 && Flow.Count != lines.Count)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Flow Values do not match length of Line List");
                }
                if (Speed.Count > 1 && Speed.Count != lines.Count)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Speed Values do not match length of Line List");
                }
                #endregion

                //Create Silkworm Line from each line and a corresponding flow or speed value
                //(will create an incomplete movement if none are provided)
                if (Flow.Count == lines.Count && Speed.Count == lines.Count)
                {
                    for (int i = 0; i < lines.Count; i++)
                    {
                        SilkwormLine sLine = new SilkwormLine(Flow[i], Speed[i], lines[i]);
                        sMovement.Add(sLine);
                    }
                }


                //Add Custom Delimiter or Default Delimiter (depending if input is provided)
                if (dObject.Value is Delimiter)
                {
                    Delimiter delimiter = (Delimiter)dObject.Value;

                    sModel = new SilkwormMovement(sMovement, delimiter);
                }
                else
                {
                    sModel = new SilkwormMovement(sMovement, new Delimiter());
                }
            }
            #endregion

            #region if point
            if (points.Count < 2 && points.Count > 0)
            {
                if (dObject.Value is Delimiter)
                {
                    Delimiter delimiter = (Delimiter)dObject.Value;

                    sModel = new SilkwormMovement(points[0], delimiter);
                }
                else
                {
                    sModel = new SilkwormMovement(points[0], new Delimiter());
                }
            }
            #endregion

            //Output
            DA.SetData(0, sModel);
        }
Example #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
        }
Example #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 <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
        }
Example #4
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

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

            #region Optional Inputs
            int mainSegmentCount = 0;
            if (!DA.GetData(1, ref mainSegmentCount)) { }
            int subSegmentCount = 0;
            if (!DA.GetData(2, ref subSegmentCount)) { }
            double maxAngleRadians = 0.05;
            if (!DA.GetData(3, ref maxAngleRadians)) { }
            double maxChordLengthRatio = 0.1;
            if (!DA.GetData(4, ref maxChordLengthRatio)) { }

            double maxAspectRatio = 0;
            if (!DA.GetData(5, ref maxAspectRatio)) { }
            double tolerance = 0;
            if (!DA.GetData(6, ref tolerance)) { }
            double minEdgeLength = 0.1;
            if (!DA.GetData(7, ref minEdgeLength)) { }
            double maxEdgeLength = 0;
            if (!DA.GetData(8, ref maxEdgeLength)) { }
            bool keepStartPoint = true;
            if (!DA.GetData(9, ref keepStartPoint)) { }
            #endregion

            #endregion

            List<Curve>[] lines = new List<Curve>[things.Count];
            List<PolylineCurve> polylines = new List<PolylineCurve>();
            GH_Structure<GH_Curve> Lines = new GH_Structure<GH_Curve>();

            for (int i = 0; i < things.Count; i++)
            {
                SilkwormSegment segment = new SilkwormSegment(things[i], mainSegmentCount, subSegmentCount, maxAngleRadians, maxChordLengthRatio, maxAspectRatio, tolerance, minEdgeLength, maxEdgeLength, keepStartPoint);
                lines[i] = new List<Curve>();
                lines[i].AddRange(segment.Segments);
                PolylineCurve pline = new PolylineCurve(segment.Pline);
                polylines.Add(pline);
            }

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

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

            //                        GH_Curve glines = new GH_Curve(lines[i][j]);
            //                        Lines.Insert(glines, new GH_Path(i), j);
            //                    }

            //                }
            //            }
            //        }
            //if (!DA.SetDataTree(0, Lines)) { return; }
            if (!DA.SetDataList(0, polylines)) { return; }
        }
Example #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


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

            #region Optional Inputs
            int mainSegmentCount = 0;
            if (!DA.GetData(1, ref mainSegmentCount))
            {
            }
            int subSegmentCount = 0;
            if (!DA.GetData(2, ref subSegmentCount))
            {
            }
            double maxAngleRadians = 0.05;
            if (!DA.GetData(3, ref maxAngleRadians))
            {
            }
            double maxChordLengthRatio = 0.1;
            if (!DA.GetData(4, ref maxChordLengthRatio))
            {
            }


            double maxAspectRatio = 0;
            if (!DA.GetData(5, ref maxAspectRatio))
            {
            }
            double tolerance = 0;
            if (!DA.GetData(6, ref tolerance))
            {
            }
            double minEdgeLength = 0.1;
            if (!DA.GetData(7, ref minEdgeLength))
            {
            }
            double maxEdgeLength = 0;
            if (!DA.GetData(8, ref maxEdgeLength))
            {
            }
            bool keepStartPoint = true;
            if (!DA.GetData(9, ref keepStartPoint))
            {
            }
            #endregion

            #endregion

            List <Curve>[]          lines     = new List <Curve> [things.Count];
            List <PolylineCurve>    polylines = new List <PolylineCurve>();
            GH_Structure <GH_Curve> Lines     = new GH_Structure <GH_Curve>();


            for (int i = 0; i < things.Count; i++)
            {
                SilkwormSegment segment = new SilkwormSegment(things[i], mainSegmentCount, subSegmentCount, maxAngleRadians, maxChordLengthRatio, maxAspectRatio, tolerance, minEdgeLength, maxEdgeLength, keepStartPoint);
                lines[i] = new List <Curve>();
                lines[i].AddRange(segment.Segments);
                PolylineCurve pline = new PolylineCurve(segment.Pline);
                polylines.Add(pline);
            }

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

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


            //                        GH_Curve glines = new GH_Curve(lines[i][j]);
            //                        Lines.Insert(glines, new GH_Path(i), j);
            //                    }

            //                }
            //            }
            //        }
            //if (!DA.SetDataTree(0, Lines)) { return; }
            if (!DA.SetDataList(0, polylines))
            {
                return;
            }
        }
Example #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;
        }
Example #7
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);
        }