Add() public method

public Add ( string value ) : void
value string
return void
        protected override void SolveInstance(IGH_DataAccess da)
        {
            if (!GetInputs(da)) return;
            prop = new DataTree<double>();
            int index = 0;
            foreach (Amoeba amo in p.population)
            {
                prop.Add(amo.tempValue,new GH_Path(index));
                prop.Add(PhysaSetting.gmin, new GH_Path(index));
                prop.Add(PhysaSetting.gmax, new GH_Path(index));
                index++;
            }

            SetOutputs(da);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets structured content
        /// </summary>
        public DataTree <string> Get()
        {
            DataTree <string> result = new DataTree <string>($"Documentation for {Name}: {Description}");

            if (Examples.Count == 1)
            {
                result.Add($"Example: {Examples[0]}");
            }
            if (Examples.Count > 1)
            {
                DataTree <string> example = new DataTree <string>("Examples:");
                Examples.ForEach(x => example.Add(x));
                result.Add(example);
            }
            if (!Default.IsNullOrWhiteSpace())
            {
                result.Add($"Default: {Default}");
            }
            if (!PossibleValues.IsNullOrWhiteSpace())
            {
                result.Add($"PossibleValues: {PossibleValues}");
            }
            if (!Remark.IsNullOrWhiteSpace())
            {
                result.Add($"Remarks: {Remark}");
            }

            return(result);
        }
Ejemplo n.º 3
0
        void createNetFromPoints(DataTree <Point3d> PointGrid)
        {
            // Receives a tree of points and gives back it's corresponding net of lines properly divided into WARP AND WEFT directions
            DataTree <Line> warpLines = new DataTree <Line>();
            DataTree <Line> weftLines = new DataTree <Line>();

            //WARP
            for (int bNum = 0; bNum < PointGrid.BranchCount; bNum++)
            { // Iterate all branches
                List <Point3d> branch = PointGrid.Branches[bNum];
                GH_Path        pth    = PointGrid.Paths[bNum];
                for (int ptNum = 0; ptNum < branch.Count - 1; ptNum++)
                { // Iterate all points in each branch
                    Line warpLn = new Line(branch[ptNum], branch[ptNum + 1]);
                    warpLines.Add(warpLn, new GH_Path(pth));
                    if (bNum < PointGrid.BranchCount - 1)
                    {
                        List <Point3d> nextBranch = PointGrid.Branches[bNum + 1];
                        if (ptNum < nextBranch.Count)
                        {
                            Line weftLn = new Line(branch[ptNum], nextBranch[ptNum]);
                            weftLines.Add(weftLn, pth);
                        }
                    }
                }
            }

            _warpNet.MergeTree(warpLines);
            _weftNet.MergeTree(weftLines);
        }
Ejemplo n.º 4
0
        public DataTree <string> ToDataTree(List <string>[] Data)
        {
            DataTree <string> dTree = new DataTree <string>();
            // define numbers of branches of data tree
            int rows = Data[0].Count;
            // define numbers of items in each branch
            int cols = Data.GetLength(0);

            for (int irow = 0; irow < rows; irow++)
            {
                for (int icol = 0; icol < cols; icol++)
                {
                    if (Data[icol] == null)
                    {
                        continue;
                    }
                    //dTree.Add(Data[icol][irow], new GH_Path(irow));
                    try
                    {
                        dTree.Add(Data[icol][irow].ToString(), new GH_Path(irow));
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
            return(dTree);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // get input
            StruSoft.Interop.StruXml.Data.Complex_composite_type ComplexComposite = null;
            if (!DA.GetData(0, ref ComplexComposite))
            {
                return;
            }
            if (ComplexComposite == null)
            {
                return;
            }

            // return


            DataTree <FemDesign.Materials.Material> material = new DataTree <FemDesign.Materials.Material>();
            DataTree <FemDesign.Sections.Section>   section  = new DataTree <FemDesign.Sections.Section>();

            for (int i = 0; i < ComplexComposite.Composite_section.Count; i++)
            {
                var item = ComplexComposite.Composite_section[i];
                foreach (var obj in item.CompositeSectionDataObj.Part)
                {
                    material.Add(obj.MaterialObj, new GH_Path(i));
                    section.Add(obj.SectionObj, new GH_Path(i));
                }
            }

            DA.SetDataTree(0, material);
            DA.SetDataTree(1, section);
        }
        //private DataTree<Point3d> CreateControlPoints(ref List<string> msg)
        //{
        //    var oControlPoints = new DataTree<Point3d>();
        //    foreach (var member in _saveddata.GetMembers())
        //    {
        //        var gh_path = new GH_Path(member.No);
        //        var fe1delements = _rfemMesh.GetMemberNodes(member.No, ItemAt.AtNo); // We can't sort this list
        //        foreach (var node in fe1delements)
        //        {
        //            oControlPoints.Add(new Point3d(node.X, node.Y, node.Z), gh_path);
        //        }
        //    }
        //    return oControlPoints;
        //}

        private DataTree <Vector3d> GetMemberDisplacements(ref List <string> msg)
        {
            // Get control points
            _controlPoints.Clear();
            var rfmembers = Component_GetData.GetRFMembers(_saveddata.GetMembers().ToList(), _saveddata);
            // Save defoirmation vectors into a tree;
            var oDisplacements = new DataTree <Vector3d>();

            foreach (var member in rfmembers)
            {
                // Add also control points. We are just going to get one set of control points for each curve regardless thne result type
                var pts_path = new GH_Path(member.No);
                _controlPoints.RemovePath(pts_path);
                var baseline = member.BaseLine.ToCurve();
                // Get deformations
                var memberResults = _lcresults.GetMemberDeformations(member.No, ItemAt.AtNo, MemberAxesType.GlobalAxes); // We can't sort this list
                var valueType     = memberResults[0].Type;                                                               // Get deformation types to avoid duplicate control points
                foreach (var result in memberResults)
                {
                    var gh_path      = new GH_Path(member.No, (int)result.Type);
                    var displacement = new Vector3d(result.Displacements.ToPoint3d());
                    oDisplacements.Add(displacement, gh_path);
                    // Get control points
                    if (result.Type == valueType)
                    {
                        _controlPoints.Add(baseline.PointAtNormalizedLength(Math.Min(result.Location / baseline.GetLength(), 1.0)), pts_path);
                    }
                }
            }
            return(oDisplacements);
        }
        private DataTree <Vector3d> GetMeshDisplacements(ref List <int> sfcNo, ref List <string> msg)
        {
            var oDisplacements = new DataTree <Vector3d>();

            sfcNo = new List <int>();
            // Save defoirmation vectors into a tree
            var surfaceResults = _lcresults.GetSurfacesDeformations(false).OrderBy(o => o.LocationNo); // Sort according to nodes so there are no errors when applying displacements

            foreach (var resulttype in surfaceResults.Select(x => x.Type).Distinct())
            {
                _resultTypes.Add(resulttype);
            }
            foreach (var result in surfaceResults) // GET RESULT TYPES!!!
            {
                var gh_path      = new GH_Path(result.SurfaceNo, (int)result.Type);
                var displacement = new Vector3d(result.Displacements.ToPoint3d());
                oDisplacements.Add(displacement, gh_path);
                // Add surface numbers to output list
                if (sfcNo.Count == 0 || result.SurfaceNo != sfcNo[sfcNo.Count - 1])
                {
                    sfcNo.Add(result.SurfaceNo);
                }
            }
            return(oDisplacements);
        }
Ejemplo n.º 8
0
    /// <summary>
    /// This procedure contains the user code. Input parameters are provided as regular arguments,
    /// Output parameters as ref arguments. You don't have to assign output parameters,
    /// they will have a default value.
    /// </summary>
    private void RunScript(DataTree <Point3d> P, ref object A, ref object B, ref object C, ref object D, ref object E)
    {
        // simplify
        P.SimplifyPaths();
        // making a copy since DataTree is reference type
        A = new DataTree <Point3d>(P);

        // graft
        P.Graft(false);
        B = new DataTree <Point3d>(P);

        // flatten (extract alla data to a list)
        List <Point3d> pts = P.AllData(); // data tree to List

        C = pts;

        // extract paths list (like Param Viewer)
        IList <GH_Path> paths = P.Paths;

        D = paths;

        // rebuild a tree from the list
        DataTree <Point3d> pTree = new DataTree <Point3d>();
        GH_Path            p;

        for (int i = 0; i < paths.Count; i++)
        {
            p = new GH_Path(paths[i][0]);
            pTree.Add(pts[i], p);
        }
        E = pTree;
    }
Ejemplo n.º 9
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)
        {
            GH_Structure <IGH_Goo> objects = new GH_Structure <IGH_Goo>();

            if (!DA.GetDataTree(0, out objects))
            {
                return;
            }
            /////////////////////////////////////////////////////////////////////////////
            DataTree <object> newobj = new DataTree <object>();
            int        num           = objects.PathCount;
            List <int> index         = new List <int>();//////每个分支的长度

            for (int i = 0; i < num; i++)
            {
                index.Add(objects.Branches[i].Count);
            }
            index.Sort();                        /////排序长度,找出最大值
            int maxnum = index[index.Count - 1]; /////找出数据最长分支的长度

            for (int i = 0; i < maxnum; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    List <object> obb  = new List <object>(objects.Branches[j]);
                    int           num2 = obb.Count;
                    if (num2 >= i + 1)/////////////////////如果分支的数据长度大于序号,则进入
                    {
                        newobj.Add(obb[i], new GH_Path(0, i));
                    }
                }
            }
            DA.SetDataTree(0, newobj);
        }
Ejemplo n.º 10
0
// ===============================================================================================
// Get Vertices from breps
// ===============================================================================================
        public static DataTree <Point3d> BrepVertices(List <Brep> breps)
        {
            DataTree <Point3d> faceVertices = new DataTree <Point3d>();

            int i = 0;

            foreach (Brep brep in breps)
            {
                int j = 0;
                foreach (var face in brep.Faces)
                {
                    Brep faceBrep = face.DuplicateFace(true);
                    var  pts      = faceBrep.DuplicateVertices();

                    for (int k = 0; k < pts.Length; k++)
                    {
                        GH_Path path = new GH_Path(i, j);
                        faceVertices.Add(pts[k], path);
                    }
                    j++;
                }
                i++;
            }
            return(faceVertices);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // First, we need to retrieve all data from the input parameters.
            // We'll start by declaring variables and assigning them starting values.
            object  obj  = new object();
            GH_Path path = new GH_Path();

            // Then we need to access the input parameters individually.
            // When data cannot be extracted from a parameter, we should abort this method.
            if (!DA.GetData(0, ref obj))
            {
                return;
            }
            if (!DA.GetData(1, ref path))
            {
                return;
            }

            DataTree <object> dt = new DataTree <object>();

            dt.Add(obj, path);

            // Finally assign to the output parameter.
            DA.SetData(0, dt);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <sPointLoad> sups = new List <sPointLoad>();

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

            DataTree <sPointLoad> supTree = new DataTree <sPointLoad>();
            var ngrouped = sups.GroupBy(n => n.loadPatternName);
            int ngroupID = 0;

            foreach (var nngroup in ngrouped)
            {
                GH_Path npth = new GH_Path(ngroupID);
                foreach (sPointLoad sn in nngroup)
                {
                    supTree.Add(sn, npth);
                }
                ngroupID++;
            }

            DA.SetDataTree(0, supTree);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <IFrameSet> beams = new List <IFrameSet>();

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

            DataTree <IFrameSet> beamTree = new DataTree <IFrameSet>();
            var grouped = beams.GroupBy(b => b.crossSection.shapeName);
            int groupID = 0;

            foreach (var bgroup in grouped)
            {
                GH_Path bpth = new GH_Path(groupID);
                foreach (IFrameSet sb in bgroup)
                {
                    beamTree.Add(sb, bpth);
                }
                groupID++;
            }

            DA.SetDataTree(0, beamTree);
        }
Ejemplo n.º 14
0
        private static DataTree <object> UpdateInfo(List <string> patchKeys, List <Thresholds.WindThreshold> thresholds,
                                                    int criteria)
        {
            var info   = "Patch Names:\n";
            var output = new DataTree <object>();

            if (criteria == 1)
            {
                var i = 0;
                foreach (var key in patchKeys)
                {
                    info += $"{{{i}}} is {key}\n";
                    i++;
                }

                info += "\nComfort Categories\n";
                var j = 0;
                foreach (var threshold in thresholds)
                {
                    info += $"{threshold.Field} is {j}\n";
                    output.Add(threshold.Field, new GH_Path(1));
                    j++;
                }
            }
            else
            {
                var i = 0;
                foreach (var key in patchKeys)
                {
                    info += $"{{{i};*}} is {key}\n";
                    i++;
                }

                info += "\nThreshold Categories\n";
                var j = 0;
                foreach (var threshold in thresholds)
                {
                    info += $"{{*;{j}}} is {threshold.Field}\n";
                    output.Add(threshold.Field, new GH_Path(1));
                    j++;
                }
            }


            output.Add(info, new GH_Path(0));
            return(output);
        }
Ejemplo n.º 15
0
        public DataTree <Line> GetDowels(double radius = 0.075, int count = 8)
        {
            DataTree <Line> dt = new DataTree <Line>();

            for (int i = 0; i < this._nexors.Count; i++)
            {
                if (this._nexors[i].isNexor != 0)
                {
                    var     path = new GH_Path(i);
                    Point3d c    = (this._nexors[i].endPl0.Origin + this._nexors[i].endPl1.Origin) * 0.5;

                    int dir = (c.DistanceToSquared(this._nexors[i].endPl0.Origin + this._nexors[i].endPl0.ZAxis) < c.DistanceToSquared(this._nexors[i].endPl0.Origin - this._nexors[i].endPl0.ZAxis)) ? -1 : 1;

                    Plane  plane  = this._nexors[i].endPl0.ChangeOrigin(PlaneUtil.LinePlane(this._nexors[i].pipe.line, this._nexors[i].endPl0));
                    Circle circle = new Circle(plane, radius);
                    Curve  curve  = circle.ToNurbsCurve();
                    curve.DivideByCount(count, true, out Point3d[] pts);

                    foreach (Point3d p in pts)
                    {
                        Line line = new Line(p, this._nexors[i].endPl0.ZAxis * dir * 0.15);
                        dt.Add(line, path);
                        //line.Bake();
                    }

                    plane  = this._nexors[i].endPl1.ChangeOrigin(PlaneUtil.LinePlane(this._nexors[i].pipe.line, this._nexors[i].endPl1));
                    circle = new Circle(plane, radius);
                    curve  = circle.ToNurbsCurve();
                    curve.DivideByCount(count, true, out Point3d[] pts1);



                    dir = (c.DistanceToSquared(this._nexors[i].endPl1.Origin + this._nexors[i].endPl1.ZAxis) < c.DistanceToSquared(this._nexors[i].endPl1.Origin - this._nexors[i].endPl1.ZAxis)) ? -1 : 1;


                    foreach (Point3d p in pts1)
                    {
                        Line line = new Line(p, this._nexors[i].endPl1.ZAxis * dir * 0.15);
                        dt.Add(line, path);
                        //line.Bake();
                    }

                    //Rhino.RhinoDoc.ActiveDoc.Objects.AddCircle(circle);
                }
            }
            return(dt);
        }
Ejemplo n.º 16
0
        public void Add(Point3d position, bool wrapped)
        {
            if (Count >= size)
            {
                tree.Branch(0).RemoveAt(0);

                if (tree.Branch(0).Count == 0)
                {
                    tree.RemovePath(tree.Path(0));
                }
            }
            if (wrapped)
            {
                nextPathIndex++;
            }
            tree.Add(position, new GH_Path(nextPathIndex));
        }
        public void test_core(ref List <Rectangle3d> core_list, ref List <Point3d> g_pts, ref DataTree <bool> g_val)
        {
            List <Rectangle3d> c = new List <Rectangle3d>();

            double core_area_min = core_area * (1.0 - deviation);
            double core_area_max = core_area * (1.0 + deviation);

            for (int i = 1; i <= skin_width; i++)
            {
                for (int j = 1; j <= skin_height; j++)
                {
                    g_pts.Add(new Point3d(i - 0.5, j - 0.5, 0));

                    if ((i * j == core_area || (i * j >= core_area_min && i * j <= core_area_max)) && i >= core_min_width && j >= core_min_height)
                    {
                        double possible_x_pos = skin.Width - i;
                        double possible_y_pos = skin.Height - j;

                        for (int k = 0; k <= possible_x_pos; k++)
                        {
                            for (int l = 0; l <= possible_y_pos; l++)
                            {
                                c.Add(new Rectangle3d(Plane.WorldXY, new Point3d(k, l, 0), new Point3d(k + i, l + j, 0)));
                                g_val.EnsurePath(c.Count() - 1);

                                for (int m = 0; m < skin_width; m++)
                                {
                                    for (int n = 0; n < skin_height; n++)
                                    {
                                        if ((m + 0.5 > k && m + 0.5 < k + i) && (n + 0.5 > l && n + 0.5 < l + j))
                                        {
                                            g_val.Add(false);
                                        }
                                        else
                                        {
                                            g_val.Add(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            core_list = c;
        }
Ejemplo n.º 18
0
        public static Dictionary <string, DataTree <object> > CreateAnalysisMesh(
            List <Surface> baseSurfaces,
            double gridSize,
            List <Brep> excludeGeometry,
            double offset,
            string offsetDirection)
        {
            var analysisMesh = new DataTree <object>();
            var faceCenters  = new DataTree <object>();
            var faceNormals  = new DataTree <object>();
            var index        = 0;
            var doneEvents   = new ManualResetEvent[baseSurfaces.Count];
            var callBacks    = new List <ThreadedCreateAnalysisMesh>();

            foreach (var surface in baseSurfaces)
            {
                doneEvents[index] = new ManualResetEvent(false);
                var callBack = new ThreadedCreateAnalysisMesh
                {
                    gridSize        = gridSize,
                    excludeGeometry = excludeGeometry,
                    offset          = offset,
                    offsetDirection = offsetDirection,
                    doneEvent       = doneEvents[index]
                };
                ThreadPool.QueueUserWorkItem(callBack.ThreadPoolCallback);
                callBacks.Add(callBack);
                index++;
            }

            WaitHandle.WaitAll(doneEvents);

            index = 0;
            foreach (var callBack in callBacks)
            {
                var mesh = callBack.analysisMesh;
                var path = new GH_Path(index);
                analysisMesh.Add(mesh, path);

                foreach (var normal in mesh.FaceNormals)
                {
                    faceNormals.Add(normal, path);
                }

                for (var i = 0; i < mesh.Faces.Count(); i++)
                {
                    faceCenters.Add(mesh.Faces.GetFaceCenter(i), path);
                }

                index++;
            }
            return(new Dictionary <string, DataTree <object> >
            {
                { "analysisMesh", analysisMesh },
                { "faceCenters", faceCenters },
                { "faceNormals", faceNormals },
            });
        }
Ejemplo n.º 19
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)
        {
            List <Brep> breps     = new List <Brep>();
            double      tolerance = 0;

            if (!DA.GetDataList(0, breps))
            {
                return;
            }
            if (!DA.GetData(1, ref tolerance))
            {
                return;
            }
            DataTree <int> index = new DataTree <int>();
            List <Brep>    bps   = new List <Brep>();
            List <int>     test  = new List <int>();
            int            num   = 0;

            for (int i = 0; i < breps.Count; i++)
            {
                if (test.Contains(i))
                {
                    continue;
                }
                Brep bb = breps[i];
                bps.Add(bb);
                test.Add(i);
                index.Add(i, new GH_Path(0, DA.Iteration, num));
                for (int j = 0; j < breps.Count; j++)
                {
                    if (test.Contains(j))
                    {
                        continue;
                    }
                    if (bb.IsDuplicate(breps[j], tolerance))
                    {
                        test.Add(j);
                        index.Add(j, new GH_Path(0, DA.Iteration, num));
                    }
                }
                num++;
            }
            DA.SetDataList(0, bps);
            DA.SetDataTree(1, index);
        }
Ejemplo n.º 20
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)
        {
            List <string> _buildingFiles       = new List <string>();
            List <string> _buildingBinaryFiles = new List <string>();
            int           _val_  = 0;
            bool          runIt_ = false;

            DA.GetDataList(0, _buildingFiles);
            DA.GetDataList(1, _buildingBinaryFiles);
            DA.GetData(2, ref _val_);
            DA.GetData(3, ref runIt_);

            // Unwrap variables
            List <FacadeVariable> variables = BuildingFacadeOutputMapping();

            if (runIt_)
            {
                DataTree <string>         fileNameTree = new DataTree <string>();
                DataTree <FacadeVariable> variableTree = new DataTree <FacadeVariable>();
                DataTree <double>         dataTree     = new DataTree <double>();

                // Warning!
                if (_val_ >= variables.Count)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Variable is out of range, check description of the input.");
                    return;
                }

                for (int i = 0; i < _buildingFiles.Count; i++)
                {
                    GHD.GH_Path pth = new GHD.GH_Path(i);
                    try
                    {
                        string edxName = Path.GetFileNameWithoutExtension(_buildingFiles[i]);
                        string edtName = Path.GetFileNameWithoutExtension(_buildingBinaryFiles[i]);

                        if (edxName == edtName)
                        {
                            List <double> results = BuildingOutput.ParseBinBuilding(_buildingFiles[i], _buildingBinaryFiles[i], (int)variables[_val_], Direction);

                            fileNameTree.Add(Path.GetFileName(_buildingFiles[i]), pth);
                            variableTree.Add(variables[_val_], pth);
                            dataTree.AddRange(results, pth);
                        }
                    }
                    catch
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Something is wrong in output dynamic folder.\nPlease, make sure EDT length is equals to EDX length.");
                        continue;
                    }
                }

                DA.SetDataTree(0, fileNameTree);
                DA.SetDataTree(1, variableTree);
                DA.SetDataTree(2, dataTree);
            }
        }
Ejemplo n.º 21
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)
        {
            List <Point3d> x = new List <Point3d>();
            double         t = 0;

            if (!DA.GetDataList(0, x))
            {
                return;
            }
            if (!DA.GetData(1, ref t))
            {
                return;
            }
            //////////////////////////////////////////////////////////
            DataTree <int> index  = new DataTree <int>();
            int            mem    = 0;
            int            branch = DA.Iteration;
            List <Point3d> last   = new List <Point3d>();

            for (int i = 0; i < x.Count; i++)
            {
                if (x[i] == Point3d.Unset)
                {
                    continue;
                }
                last.Add(x[i]);
                index.Add(i, new GH_Path(0, branch, mem));
                for (int q = 0; q < x.Count; q++)
                {
                    if (x[q] == Point3d.Unset || i == q)
                    {
                        continue;
                    }
                    if (x[i].DistanceTo(x[q]) <= t + 0.000000001)
                    {
                        x[q] = Point3d.Unset;
                        index.Add(q, new GH_Path(0, branch, mem));
                    }
                }
                mem++;
            }
            DA.SetDataList(0, last);
            DA.SetDataTree(1, index);
        }
Ejemplo n.º 22
0
        public void MatchToProgram()
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                for (int j = 0; j < smIntervals.Length; j++)
                {
                    if (nodes[i].intervalIndex == j)
                    {
                        smIntervals[j].cumulArea += nodes[i].area;
                    }
                }
            }

            var sortedIntervals = smIntervals.OrderBy(i => i.cumulArea).ToList();
            var sortedProgram   = programPairs.OrderBy(p => p.area).ToList();

            for (int i = 0; i < nodes.Count; i++)
            {
                for (int j = 0; j < sortedIntervals.Count; j++)
                {
                    if (nodes[i].intervalIndex == j)
                    {
                        nodes[i].name = sortedProgram[j].name;
                    }
                }
            }

            var sortedNodes = nodes.OrderBy(n => n.multiplierStrength).ToList();

            for (int i = 0; i < sortedIntervals.Count; i++)
            {
                int count = 0;

                for (int j = 0; j < sortedNodes.Count; j++)
                {
                    if (i == sortedNodes[j].intervalIndex)
                    { //if(i == 0)
                      // sortedNodes[j].bmu = true;

                        sortedNodes[j].name += "_" + count;
                        count++;
                    }
                }
            }

            for (int i = 0; i < nodes.Count; i++)
            {
                for (int j = 0; j < sortedIntervals.Count; j++)
                {
                    if (nodes[i].intervalIndex == j)
                    {
                        programTree.Add(nodes[i], new GH_Path(j));
                    }
                }
            }
        }
        protected override void SolveInstance(IGH_DataAccess da)
        {
            if (!GetInputs(da))
            {
                return;
            }
            prop = new DataTree <double>();
            int index = 0;

            foreach (Amoeba amo in p.population)
            {
                prop.Add(amo.tempValue, new GH_Path(index));
                prop.Add(PhysaSetting.gmin, new GH_Path(index));
                prop.Add(PhysaSetting.gmax, new GH_Path(index));
                index++;
            }

            SetOutputs(da);
        }
Ejemplo n.º 24
0
        public DataTree <int> GetID()
        {
            DataTree <int> dt = new DataTree <int>();

            for (int i = 0; i < _pipes.Count; i++)
            {
                dt.Add(_pipes[i].ID, new Grasshopper.Kernel.Data.GH_Path(i));
            }
            return(dt);
        }
Ejemplo n.º 25
0
        //Properties
        public DataTree <Line> GetLines()
        {
            DataTree <Line> dt = new DataTree <Line>();

            for (int i = 0; i < _pipes.Count; i++)
            {
                dt.Add(_pipes[i].line, new Grasshopper.Kernel.Data.GH_Path(i));
            }
            return(dt);
        }
Ejemplo n.º 26
0
        public DataTree <Mesh> GetMeshes()
        {
            DataTree <Mesh> dt = new DataTree <Mesh>();

            for (int i = 0; i < _pipes.Count; i++)
            {
                dt.Add(_pipes[i].meshloft, new Grasshopper.Kernel.Data.GH_Path(i));
            }
            return(dt);
        }
Ejemplo n.º 27
0
        public DataTree <Brep> GetBreps()
        {
            DataTree <Brep> dt = new DataTree <Brep>();

            for (int i = 0; i < _pipes.Count; i++)
            {
                dt.Add(_pipes[i].breploft, new Grasshopper.Kernel.Data.GH_Path(i));
            }
            return(dt);
        }
        static DataTree <T> ListToTree <T>(List <T> List)
        {
            DataTree <T> tree = new DataTree <T>();

            for (int i = 0; i < List.Count; i++)
            {
                tree.Add(List[i], new GH_Path(i));
            }
            return(tree);
        }
Ejemplo n.º 29
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //Input variables
            List <Line>    lines  = new List <Line>();
            List <Point3d> points = new List <Point3d>();

            //Link input
            DA.GetDataList(0, lines);
            DA.GetDataList(1, points);

            //output variables
            DataTree <int>  IDS  = new DataTree <int>();
            DataTree <Line> tree = new DataTree <Line>();

            //tolerance needed to cover rounding errors
            double tol = 1e-6;

            //loop over data
            for (int i = 0; i < points.Count; i++)
            {
                Point3d ptree = points[i];
                GH_Path path  = new GH_Path(i);
                foreach (Line linetree in lines)
                {
                    //if startpoint is equal to current point
                    if (Math.Abs(ptree.X - linetree.From.X) < tol && Math.Abs(ptree.Y - linetree.From.Y) < tol && Math.Abs(ptree.Z - linetree.From.Z) < tol)
                    {
                        tree.Add(linetree, path);
                        IDS.Add(lines.IndexOf(linetree), path);
                    }
                    //if endpoint is equal to current point
                    if (Math.Abs(ptree.X - linetree.To.X) < tol && Math.Abs(ptree.Y - linetree.To.Y) < tol && Math.Abs(ptree.Z - linetree.To.Z) < tol)
                    {
                        tree.Add(linetree, path);
                        IDS.Add(lines.IndexOf(linetree), path);
                    }
                }
            }

            //link output
            DA.SetDataTree(0, tree);
            DA.SetDataTree(1, IDS);
        }
Ejemplo n.º 30
0
        private static DataTree <object> UpdateInfo(
            Dictionary <string, Dictionary <string, Dictionary <string, object> > > data)
        {
            var fieldKey = data.Keys.ToList().First();
            var info     = "Patch Names:\n";
            var i        = 0;
            var patches  = data[fieldKey].Keys.ToList();

            foreach (var key in patches)
            {
                info += $"{{{i};*}} is {key}\n";
                i++;
            }

            var j        = 0;
            var angles   = new List <string>();
            var patchKey = patches.First();

            info += "\nAngles:\n";
            foreach (var key in data[fieldKey][patchKey].Keys)
            {
                info += $"{{*;{j}}} is {key} degrees\n";
                angles.Add(key);
                j++;
            }

            var output = new DataTree <object>();

            output.Add(info, new GH_Path(0));

            foreach (var patch in patches)
            {
                output.Add(patch, new GH_Path(1));
            }

            foreach (var angle in angles)
            {
                output.Add(angle, new GH_Path(2));
            }

            return(output);
        }
Ejemplo n.º 31
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)
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////////声明变量
            List <Curve> c  = new List <Curve>();
            double       t1 = 0;
            double       t2 = 0;

            ///////////////////////////////////////////////////////////////////////////////////////////////////检测输入端是否合理
            if (!DA.GetDataList(0, c))
            {
                return;
            }
            if (!DA.GetData(1, ref t1))
            {
                return;
            }
            if (!DA.GetData(2, ref t2))
            {
                return;
            }
            DataTree <Curve>   last     = new DataTree <Curve>();
            DataTree <Point3d> collects = ViperClass.EmptyTree(c.Count);
            int index  = 0;
            int branch = DA.Iteration;

            for (int i = 0; i < c.Count; i++)
            {
                for (int q = i + 1; q < c.Count; q++)
                {
                    Rhino.Geometry.Intersect.CurveIntersections result = Rhino.Geometry.Intersect.Intersection.CurveCurve(c[i], c[q], t1, t2);
                    if (result.Count > 0)                      ////有交集
                    {
                        for (int k = 0; k < result.Count; k++) ////记录每次相交的t值并分别赋值给两曲线
                        {
                            collects.Branch(i).Add((result[k].PointA));
                            collects.Branch(q).Add((result[k].PointB));
                        }
                    }
                }
            }
            /////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 0; i < c.Count; i++)
            {
                if (collects.Branch(i).Count == 0)
                {
                    last.Add(c[i], new GH_Path(0, branch, index));
                    index++;
                    continue;
                }
                last.AddRange(ViperClass.SplitByPts(c[i], collects.Branch(i).ToList()), new GH_Path(0, branch, index));
                index++;
            }
            DA.SetDataTree(0, last);
        }
    private static DataTree<Brep> BrepArray2DToDatatree(Brep[][] array)
    {
      DataTree<Brep> tree = new DataTree<Brep>();
      GH_Path trunk = new GH_Path();

      for (int i = 0; i < array.Length; i++)
      {
        GH_Path branch = trunk.AppendElement(i);

        for (int j = 0; j < array[i].Length; j++)
        {
          tree.Add(array[i][j], branch);
        }
      }
      return tree;
    }
Ejemplo n.º 33
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)
        {
            //-----------------------------------------------------------------INPUT----------------------------------------------------------------------------//

            List<IGoal> permanentGoals = new List<IGoal>();
            DA.GetDataList(0, permanentGoals);

            List<IGoal> loadGoals = new List<IGoal>();
            DA.GetDataList(1, loadGoals);

            double fStart = 1.0;
            DA.GetData(2, ref fStart);

            double fStep = 0.1;
            DA.GetData(3, ref fStep);

            double angle = 15.0;
            DA.GetData(4, ref angle);
            angle *= Math.PI / 180.0;

            double displ = 2.0;
            DA.GetData(5, ref displ);

            double threshold = 1e-15;
            DA.GetData(6, ref threshold);

            int equilibriumIter = 100;
            DA.GetData(7, ref equilibriumIter);

            bool opt = false;
            DA.GetData(8, ref opt);

            int maxIterations = 1000;


            //--------------------------------------------------------------CALCULATE----------------------------------------------------------------------------//

            //-------------------VALUES TO STORE----------------------------//
            //Position lists
            List<Point3d> initialPositions = new List<Point3d>();
            List<Point3d> previousPositions = new List<Point3d>();
            List<Point3d> currentPositions = new List<Point3d>();
            DataTree<Point3d> vertexPositions = new DataTree<Point3d>();

            //Goal output lists
            List<object> previousGOutput = new List<object>();
            List<object> currentGOutput = new List<object>();
            DataTree<object> outputGoals = new DataTree<object>();

            //Load factors and displacements
            List<double> loadfactors = new List<double>();
            List<double> displacementsRMS = new List<double>();


            //-------------------K2 PHYSICAL SYSTEM----------------------------//
            //Initialise Kangaroo solver
            var PS = new KangarooSolver.PhysicalSystem();
            var GoalList = new List<IGoal>();

            //Assign indexes to the particles in each Goal
            foreach (IGoal pG in permanentGoals)
            {
                PS.AssignPIndex(pG, 0.01);
                GoalList.Add(pG);
            }

            foreach (IGoal lG in loadGoals)
            {
                PS.AssignPIndex(lG, 0.01);
                GoalList.Add(lG);
            }

            //Store initial loads
            List<Vector3d> initialLoads = new List<Vector3d>();
            for (int i = 0; i < loadGoals.Count; i++)
            {
                initialLoads.Add(loadGoals[i].Move[0]);
            }


            //-------------------INITIALISE VALUE LISTS----------------------------//
            //Initial vertex positions
            Point3d[] initPos = PS.GetPositionArray();
            foreach (Point3d pt in initPos)
            {
                initialPositions.Add(pt);
                previousPositions.Add(pt);
                currentPositions.Add(pt);
            }

            //Initial goal output
            List<object> initGOutput = PS.GetOutput(GoalList);
            for (int i = 0; i < permanentGoals.Count; i++)
            {
                previousGOutput.Add(initGOutput[i]);
                currentGOutput.Add(initGOutput[i]);
            }


            //-------------------LOAD INCREMENT LOOP----------------------------//
            bool run = true;
            int iter = 0;

            double LF;
            double BLF = 0.0;
            double preRMS = 0.0;

            while (run && iter < maxIterations)
            {
                LF = fStart + (fStep * iter);
                loadfactors.Add(LF);

                //Scale load goals in each iteration
                for (int i = 0; i < loadGoals.Count; i++)
                {
                    int index = GoalList.Count - loadGoals.Count + i;
                    Vector3d scaledLoad = initialLoads[i] * LF;
                    GoalList[index] = new KangarooSolver.Goals.Unary(GoalList[index].PIndex[0], scaledLoad);
                }


                //Solve equilibrium for given load increment
                int counter = 0;
                do
                {
                    PS.Step(GoalList, true, threshold);
                    counter++;
                } while (PS.GetvSum() > threshold && counter < equilibriumIter);



                //Update value lists
                GH_Path path = new GH_Path(iter);

                //Get new equilibrium positions and update position lists
                Point3d[] newPositions = PS.GetPositionArray();

                for (int k = 0; k < initialPositions.Count; k++)
                {
                    previousPositions[k] = currentPositions[k];
                    currentPositions[k] = newPositions[k];

                    if (opt)
                    {
                        vertexPositions.Add(newPositions[k], path);
                    }
                }

                //Get new goal output and update goal output lists
                List<object> newGOutput = PS.GetOutput(GoalList);
                for (int m = 0; m < permanentGoals.Count; m++)
                {
                    previousGOutput[m] = currentGOutput[m];
                    currentGOutput[m] = newGOutput[m];

                    if (opt)
                    {
                        outputGoals.Add(newGOutput[m], path);
                    }
                }



                //Does buckling occur?
                List<Vector3d> nodalDisplacements = calcDisplacement(currentPositions, initialPositions);
                double curRMS = calcDisplacementsRMS(nodalDisplacements);
                displacementsRMS.Add(curRMS);

                bool buckled = isBuckled(curRMS, preRMS, iter, fStart, fStep, angle);
                bool deflected = isDeflectionTooBig(nodalDisplacements, displ);

                if (buckled || deflected)
                {
                    run = false;
                    BLF = LF - fStep;
                }

                //Update
                preRMS = curRMS;
                iter++;
            }


            //-----------------------FLAG BUCKLED STATE----------------------------//
            if (BLF >= 1.0)
            {
                this.Message = "Works!";
            }
            else
            {
                this.Message = "Buckles!";
            }


            //-----------------------WARNING----------------------------//
            //If the maximum number of iterations has been reached
            if (iter == maxIterations)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Buckling did not occur within " + maxIterations + " load increments. Adjust load-step");
            }


            //-----------------------UPDATE VALUE LISTS----------------------------//
            //If opt is false then add results from last two iterations
            if (!opt)
            {
                for (int i = 0; i < currentPositions.Count; i++)
                {
                    vertexPositions.Add(previousPositions[i], new GH_Path(0));
                    vertexPositions.Add(currentPositions[i], new GH_Path(1));
                }

                for (int j = 0; j < currentGOutput.Count; j++)
                {
                    outputGoals.Add(previousGOutput[j], new GH_Path(0));
                    outputGoals.Add(currentGOutput[j], new GH_Path(1));
                }

            }


            //---------------------------------------------------------------OUTPUT-------------------------------------------------------------------------------//

            DA.SetData(0, BLF);
            DA.SetDataList(1, loadfactors);
            DA.SetDataList(2, displacementsRMS);
            DA.SetDataTree(3, vertexPositions);
            DA.SetDataTree(4, outputGoals);
        }
        /// <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)
        {
            //----Declareing--------------------------------------------------------------------------

            // contains the 3 points of each face
            DataTree<Point3f> facePoints = new DataTree<Point3f>();
            // contains the coresponding topology points of each face
            DataTree<int> faceTopologyPoints = new DataTree<int>();
            // contains the face normals of each face
            List<Vector3f> faceNormals = new List<Vector3f>();

            // contains the 3 topology edges of each face
            DataTree<int> faceTopoEdgesIdx = new DataTree<int>();
            // contains the points of each topology edge
            DataTree<int> topologyEdgesTopPtsIdx = new DataTree<int>();

            // Contains the coordinates of each topology point
            List<Point3d> topologyPoints = new List<Point3d>();
            // Contains the index of neighbouring faces for each face
            DataTree<int> faceNeighbours = new DataTree<int>();
            // Contains Normals of topology vertices
            List<Vector3d> topologyNormals = new List<Vector3d>();

            // Contains the index of topology Edges for each Topology Point
            DataTree<int> TopPt_Connected_TopEdges = new DataTree<int>();

            //get Mesh from input
            Mesh M = new Mesh();
            DA.GetData<Mesh>("Mesh", ref M);

            //----End Declareing-----------------------------------------------------------------------

            //----Functions------------------------------------------------------------------------------

            // get List with sublist of 3 points per face
            for (int face_id = 0; face_id < M.Faces.Count; face_id++)
            {
                // set up the branch index
                GH_Path pth = new GH_Path(face_id);

                # region FacePoints

                //---- Face Points (Point3f)
                Point3f A, B, C, D;
                M.Faces.GetFaceVertices(face_id, out A, out B, out C, out D);

                facePoints.Add(A, pth);
                facePoints.Add(B, pth);
                facePoints.Add(C, pth);

                #endregion FacePoints

                #region FaceNormals
                //---- Face Normals (Vector3f)
                M.FaceNormals.ComputeFaceNormals();
                faceNormals.Add(M.FaceNormals[face_id]);
                #endregion FaceNormals

                #region faceTopologyPoints

                //---- Topology Points of the face (int)
                int TA = M.Faces.GetTopologicalVertices(face_id)[0];
                int TB = M.Faces.GetTopologicalVertices(face_id)[1];
                int TC = M.Faces.GetTopologicalVertices(face_id)[2];

                faceTopologyPoints.Add(TA, pth);
                faceTopologyPoints.Add(TB, pth);
                faceTopologyPoints.Add(TC, pth);

                #endregion faceTopologyPoints

                #region faceNeighbours

                //---- Neighbours of face (int)

                foreach (int i in M.TopologyEdges.GetEdgesForFace(face_id))
                {
                    if (M.TopologyEdges.GetConnectedFaces(i).Length > 1)
                    {
                        foreach (int j in M.TopologyEdges.GetConnectedFaces(i))
                        {
                            if (j != face_id)
                            { faceNeighbours.Add(j, pth); }
                        }
                    }
                    else
                    { faceNeighbours.Add(-1, pth); }
                }

                #endregion faceNeighbours

                #region Face Topology Edges

                //---- Topology Edges (int)

                foreach (int i in M.TopologyEdges.GetEdgesForFace(face_id))
                { faceTopoEdgesIdx.Add(i, pth); }

                #endregion Face Topology Edges

            }

            for (int i = 0; i < M.TopologyVertices.Count; i++)
            {
                #region topologyPoints
                //---- Topology Points (point3f)
                int[] vertIdx = M.TopologyVertices.MeshVertexIndices(i);
                topologyPoints.Add(M.Vertices[vertIdx[0]]);
                #endregion topologyPoints

                #region topologyNormals
                //---- Topology Normals
                M.FaceNormals.ComputeFaceNormals();
                Vector3d normal = new Vector3d(0, 0, 0);
                int count = 0;

                foreach (int face in M.TopologyVertices.ConnectedFaces(i))
                {
                    Vector3f temp = new Vector3f();
                    temp = M.FaceNormals[face];
                    Vector3d temp2 = new Vector3d(temp.X, temp.Y, temp.Z);
                    normal += temp2;
                    count++;
                }

                normal /= count;
                topologyNormals.Add(normal);
                #endregion topologyNormals

            }

            #region Topology Edges

            for (int i = 0; i < M.TopologyEdges.Count; i++)
            {
                topologyEdgesTopPtsIdx.Add(M.TopologyEdges.GetTopologyVertices(i).I, new GH_Path(i));
                topologyEdgesTopPtsIdx.Add(M.TopologyEdges.GetTopologyVertices(i).J, new GH_Path(i));
            }

            #endregion Topology Edges

            #region Topology Vertex connected Topology Edge

            for (int i = 0; i < topologyPoints.Count; i++)
            {
                // i = index of Topology Point
                GH_Path pth = new GH_Path(i);

                for (int j = 0; j < topologyEdgesTopPtsIdx.BranchCount; j++)
                {
                    // j = index of Topology Edge
                    foreach (int k in topologyEdgesTopPtsIdx.Branch(j))
                    {
                        if (k == i)
                        // add multiple Topology Edges to the branch index, which is representing the topology point index
                        { TopPt_Connected_TopEdges.Add(j, pth); }
                    }
                }
            }

            #endregion Topology Vertex connected Topology Edge

            //----End Functions--------------------------------------------------------------------------

            //----Set Output-----------------------------------------------------------------------------

            DA.SetDataTree(0, facePoints);
            DA.SetDataTree(1, faceTopologyPoints);
            DA.SetDataList(2, faceNormals);
            DA.SetDataTree(3, faceNeighbours);
            DA.SetDataList(4, topologyPoints);
            DA.SetDataList(5, topologyNormals);
            DA.SetDataTree(6, faceTopoEdgesIdx);
            DA.SetDataTree(7, topologyEdgesTopPtsIdx);
            DA.SetDataTree(8, TopPt_Connected_TopEdges);

            //----End Set Output-------------------------------------------------------------------------
        }
Ejemplo n.º 35
0
    private DataTree<AgentType> run(Boolean reset, bool liveUpdate, List<T.AgentSystem> systems)
    {
      int index = 0;
      pts.Clear();
      if (reset)
      {
        agentSystems.Clear();
        foreach (T.AgentSystem system in systems)
        {
          agentSystems.Add(new T.AgentSystem(system));
          foreach (EmitterType emitter in system.Emitters)
          {
            if (!emitter.ContinuousFlow)
            {
              for (int i = 0; i < emitter.NumAgents; i++)
              {
                agentSystems[index].addAgent(emitter);
              }
            }
          }
          index++;
        }


      }
      else
      {
        if (liveUpdate)
        {
          if (systems.Count > agentSystems.Count)
          {
            //Find the system that is not in agentSystems and add it.
            foreach (T.AgentSystem system in systems)
            {
              if (!agentSystems.Contains(system))
              {
                agentSystems.Add(new T.AgentSystem(system));
              }
            }
          }
          else if (systems.Count < agentSystems.Count)
          {
            foreach (T.AgentSystem agentSystem in agentSystems)
            {
              if (!systems.Contains(agentSystem))
              {
                agentSystems.Remove(agentSystem);
              }
            }
          }
          foreach (T.AgentSystem system in systems)
          {
            agentSystems[index].Emitters = systems[index].Emitters;
            agentSystems[index].AgentsSettings = systems[index].AgentsSettings;
            agentSystems[index].Forces = systems[index].Forces;
            agentSystems[index].Environment = systems[index].Environment;
            agentSystems[index].Behaviors = systems[index].Behaviors;
            index++;
          }
        }
        foreach (T.AgentSystem system in agentSystems)
        {
          system.run();
        }
      }

      DataTree<AgentType> tree = new DataTree<AgentType>();
      int counter = 0;
      foreach (T.AgentSystem system in agentSystems)
      {
        foreach (AgentType agent in system.Agents)
        {
          tree.Add(agent, new GH_Path(counter));
        }
        counter++;
      }

        return tree;
    }
Ejemplo n.º 36
0
        DataTree<Curve> GetContourTree(Mesh mesh, List<double> contourZList)
        {
            DataTree<Curve> contourTree = new DataTree<Curve>();
            int i = 0;
            foreach (double z in contourZList)
            {
                Polyline[] contour = Rhino.Geometry.Intersect.Intersection.MeshPlane(mesh, new Plane(new Point3d(0, 0, z), new Vector3d(0, 0, 1)));
                foreach (Polyline contourItem in contour)
                {
                    PolylineCurve pCurve = new PolylineCurve(contourItem);
                    contourTree.Add(pCurve, new GH_Path(0, i));

                }
                i++;
            }
            return contourTree;
        }
Ejemplo n.º 37
0
        DataTree<Object> GetStepTree(Mesh terrainMesh, List<double> contourZList, DataTree<Curve> contourTree, List<Brep> brepList)
        {
            DataTree<Object> stepTree = new DataTree<Object>();
            Plane basePlane = Plane.WorldXY;
            basePlane.OriginZ = terrainMesh.GetBoundingBox(true).Min.Z;

            // For each contour-plane
            for (int i = 0; i < contourTree.BranchCount; i++)
            {

                // create higher-Z pt list
                Point3dList winPtList = new Point3dList();

                foreach (Curve contourCrv in contourTree.Branches[i])
                {

                    Plane frm;
                    double t;
                    contourCrv.NormalizedLengthParameter(0.5, out t);
                    contourCrv.FrameAt(t, out frm);
                    frm.Transform(Rhino.Geometry.Transform.PlanarProjection(basePlane));

                    Point3d samplePt0, samplePt1;
                    samplePt0 = frm.Origin;
                    samplePt1 = frm.Origin;
                    samplePt0 += doc.ModelAbsoluteTolerance * frm.YAxis;
                    samplePt1 -= doc.ModelAbsoluteTolerance * frm.YAxis;
                    Ray3d ray0 = new Ray3d(samplePt0, Vector3d.ZAxis);
                    Ray3d ray1 = new Ray3d(samplePt1, Vector3d.ZAxis);
                    double rayParam0 = Rhino.Geometry.Intersect.Intersection.MeshRay(terrainMesh, ray0);
                    double rayParam1 = Rhino.Geometry.Intersect.Intersection.MeshRay(terrainMesh, ray1);

                    winPtList.Add(((rayParam0 > rayParam1) ? samplePt0 : samplePt1));
                }

                // For each splitted region in contour-plane
                foreach (BrepFace brepFace in brepList[i].Faces)
                {
                    Brep testBrep = brepFace.DuplicateFace(false);

                    foreach (Point3d pt in winPtList)
                    {

                        LineCurve testRay = new LineCurve(new Line(pt, Vector3d.ZAxis, 1000));
                        Point3d[] outPts;
                        Curve[] outCrvs;

                        bool ix = Rhino.Geometry.Intersect.Intersection.CurveBrep(testRay, testBrep, doc.ModelAbsoluteTolerance, out outCrvs, out outPts);
                        if (outPts.Length != 0)
                        {
                            stepTree.Add(testBrep, new GH_Path(i));
                            break;
                        }
                    }
                }
            }

            return stepTree;
        }
Ejemplo n.º 38
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool runCommand = false;
            GH_Structure<GH_Point> origPoints = new GH_Structure<GH_Point>();
            GH_Structure<GH_Point> adaptPoints = new GH_Structure<GH_Point>();
            GH_Structure<GH_Curve> curves = new GH_Structure<GH_Curve>();
            GH_Structure<GH_Vector> orientations = new GH_Structure<GH_Vector>();
            GH_Structure<GH_Vector> faceOrientations = new GH_Structure<GH_Vector>();
            DA.GetData(0, ref runCommand);
            DA.GetDataTree(1, out origPoints);
            DA.GetDataTree(2, out adaptPoints);
            DA.GetDataTree(3, out curves);
            DA.GetDataTree(4, out orientations);
            DA.GetDataTree(5, out faceOrientations);

            // Make sure the family and type is set before running the command.
            if (runCommand && (familyName == null || familyName == "Not Selected"))
            {
                message = "Please select a family/type by double-clicking on the component before running the command.";
            }
            else if (runCommand)
            {
                // Get the scale
                GHInfo ghi = new GHInfo();
                GHScale scale = ghi.GetScale(Rhino.RhinoDoc.ActiveDoc);

                // Send to Revit
                LyrebirdChannel channel = new LyrebirdChannel(appVersion);
                channel.Create();

                if (channel != null)
                {
                    string documentName = channel.DocumentName();
                    if (documentName != null)
                    {
                        // Create RevitObjects
                        List<RevitObject> obj = new List<RevitObject>();

                        #region OriginPoint Based
                        if (origPoints != null && origPoints.Branches.Count > 0)
                        {
                            List<RevitObject> tempObjs = new List<RevitObject>();
                            // make sure the branches match the datacount
                            if (origPoints.Branches.Count == origPoints.DataCount)
                            {
                                for (int i = 0; i < origPoints.Branches.Count; i++)
                                {
                                    GH_Point ghpt = origPoints[i][0];
                                    LyrebirdPoint point = new LyrebirdPoint
                                    {
                                        X = ghpt.Value.X,
                                        Y = ghpt.Value.Y,
                                        Z = ghpt.Value.Z
                                    };

                                    RevitObject ro = new RevitObject
                                    {
                                        Origin = point,
                                        FamilyName = familyName,
                                        TypeName = typeName,
                                        Category = category,
                                        CategoryId = categoryId,
                                        GHPath = origPoints.Paths[i].ToString(),
                                        GHScaleFactor = scale.ScaleFactor,
                                        GHScaleName = scale.ScaleName
                                    };

                                    tempObjs.Add(ro);
                                }
                                obj = tempObjs;
                            }
                            else
                            {
                                // Inform the user they need to graft their inputs.  Only one point per branch
                                System.Windows.Forms.MessageBox.Show("Warning:\n\nEach Branch represents an object, " +
                                    "so origin point based elements should be grafted so that each point is on it's own branch.");
                            }
                        }
                        #endregion

                        #region AdaptiveComponents
                        else if (adaptPoints != null && adaptPoints.Branches.Count > 0)
                        {
                            // generate adaptive components
                            List<RevitObject> tempObjs = new List<RevitObject>();
                            for (int i = 0; i < adaptPoints.Branches.Count; i++)
                            {
                                RevitObject ro = new RevitObject();
                                List<LyrebirdPoint> points = new List<LyrebirdPoint>();
                                for (int j = 0; j < adaptPoints.Branches[i].Count; j++)
                                {
                                    LyrebirdPoint point = new LyrebirdPoint(adaptPoints.Branches[i][j].Value.X, adaptPoints.Branches[i][j].Value.Y, adaptPoints.Branches[i][j].Value.Z);
                                    points.Add(point);
                                }
                                ro.AdaptivePoints = points;
                                ro.FamilyName = familyName;
                                ro.TypeName = typeName;
                                ro.Origin = null;
                                ro.Category = category;
                                ro.CategoryId = categoryId;
                                ro.GHPath = adaptPoints.Paths[i].ToString();
                                ro.GHScaleFactor = scale.ScaleFactor;
                                ro.GHScaleName = scale.ScaleName;
                                tempObjs.Add(ro);
                            }
                            obj = tempObjs;

                        }
                        #endregion

                        #region Curve Based
                        else if (curves != null && curves.Branches.Count > 0)
                        {
                            // Get curves for curve based components

                            // Determine if we're profile or line based
                            if (curves.Branches.Count == curves.DataCount)
                            {
                                // Determine if the curve is a closed planar curve
                                Curve tempCrv = curves.Branches[0][0].Value;
                                if (tempCrv.IsPlanar(0.00000001) && tempCrv.IsClosed)
                                {
                                    // Closed planar curve
                                    List<RevitObject> tempObjs = new List<RevitObject>();
                                    for (int i = 0; i < curves.Branches.Count; i++)
                                    {
                                        Curve crv = curves[i][0].Value;
                                        List<Curve> rCurves = new List<Curve>();
                                        bool getCrvs = CurveSegments(rCurves, crv, true);
                                        if (rCurves.Count > 0)
                                        {
                                            RevitObject ro = new RevitObject();
                                            List<LyrebirdCurve> lbCurves = new List<LyrebirdCurve>();
                                            for (int j = 0; j < rCurves.Count; j++)
                                            {
                                                LyrebirdCurve lbc;
                                                lbc = GetLBCurve(rCurves[j]);
                                                lbCurves.Add(lbc);
                                            }
                                            ro.Curves = lbCurves;
                                            ro.FamilyName = familyName;
                                            ro.Category = category;
                                            ro.CategoryId = categoryId;
                                            ro.TypeName = typeName;
                                            ro.Origin = null;
                                            ro.GHPath = curves.Paths[i].ToString();
                                            ro.GHScaleFactor = scale.ScaleFactor;
                                            ro.GHScaleName = scale.ScaleName;
                                            tempObjs.Add(ro);
                                        }
                                    }
                                    obj = tempObjs;

                                }
                                else if (!tempCrv.IsClosed)
                                {
                                    // Line based.  Can only be arc or linear curves
                                    List<RevitObject> tempObjs = new List<RevitObject>();
                                    for (int i = 0; i < curves.Branches.Count; i++)
                                    {

                                        Curve ghc = curves.Branches[i][0].Value;
                                        // Test that there is only one curve segment
                                        PolyCurve polycurve = ghc as PolyCurve;
                                        if (polycurve != null)
                                        {
                                            Curve[] segments = polycurve.Explode();
                                            if (segments.Count() != 1)
                                            {
                                                break;
                                            }
                                        }
                                        if (ghc != null)
                                        {
                                            //List<LyrebirdPoint> points = new List<LyrebirdPoint>();
                                            LyrebirdCurve lbc = GetLBCurve(ghc);
                                            List<LyrebirdCurve> lbcurves = new List<LyrebirdCurve> { lbc };

                                            RevitObject ro = new RevitObject
                                            {
                                                Curves = lbcurves,
                                                FamilyName = familyName,
                                                Category = category,
                                                CategoryId = categoryId,
                                                TypeName = typeName,
                                                Origin = null,
                                                GHPath = curves.Paths[i].ToString(),
                                                GHScaleFactor = scale.ScaleFactor,
                                                GHScaleName = scale.ScaleName
                                            };

                                            tempObjs.Add(ro);
                                        }
                                    }
                                    obj = tempObjs;
                                }
                            }
                            else
                            {
                                // Make sure all of the curves in each branch are closed
                                bool allClosed = true;
                                DataTree<CurveCheck> crvTree = new DataTree<CurveCheck>();
                                for (int i = 0; i < curves.Branches.Count; i++)
                                {
                                    List<GH_Curve> ghCrvs = curves.Branches[i];
                                    List<CurveCheck> checkedcurves = new List<CurveCheck>();
                                    GH_Path path = new GH_Path(i);
                                    for (int j = 0; j < ghCrvs.Count; j++)
                                    {
                                        Curve c = ghCrvs[j].Value;
                                        if (c.IsClosed)
                                        {
                                            AreaMassProperties amp = AreaMassProperties.Compute(c);
                                            if (amp != null)
                                            {
                                                double area = amp.Area;
                                                CurveCheck cc = new CurveCheck(c, area);
                                                checkedcurves.Add(cc);
                                            }
                                        }
                                        else
                                        {
                                            allClosed = false;
                                        }
                                    }
                                    if (allClosed)
                                    {
                                        // Sort the curves by area
                                        checkedcurves.Sort((x, y) => x.Area.CompareTo(y.Area));
                                        checkedcurves.Reverse();
                                        foreach (CurveCheck cc in checkedcurves)
                                        {
                                            crvTree.Add(cc, path);
                                        }
                                    }
                                }

                                if (allClosed)
                                {
                                    // Determine if the smaller profiles are within the larger
                                    bool allInterior = true;
                                    List<RevitObject> tempObjs = new List<RevitObject>();
                                    for (int i = 0; i < crvTree.Branches.Count; i++)
                                    {
                                        try
                                        {
                                            List<int> crvSegmentIds = new List<int>();
                                            List<LyrebirdCurve> lbCurves = new List<LyrebirdCurve>();
                                            List<CurveCheck> checkedCrvs = crvTree.Branches[i];
                                            Curve outerProfile = checkedCrvs[0].Curve;
                                            double outerArea = checkedCrvs[0].Area;
                                            List<Curve> planarCurves = new List<Curve>();
                                            planarCurves.Add(outerProfile);
                                            double innerArea = 0.0;
                                            for (int j = 1; j < checkedCrvs.Count; j++)
                                            {
                                                planarCurves.Add(checkedCrvs[j].Curve);
                                                innerArea += checkedCrvs[j].Area;
                                            }
                                            // Try to create a planar surface
                                            IEnumerable<Curve> surfCurves = planarCurves;
                                            Brep[] b = Brep.CreatePlanarBreps(surfCurves);
                                            if (b.Count() == 1)
                                            {
                                                // Test the areas
                                                double brepArea = b[0].GetArea();
                                                double calcArea = outerArea - innerArea;
                                                double diff = (brepArea - calcArea) / calcArea;

                                                if (diff < 0.1)
                                                {
                                                    // The profiles probably are all interior
                                                    foreach (CurveCheck cc in checkedCrvs)
                                                    {
                                                        Curve c = cc.Curve;
                                                        List<Curve> rCurves = new List<Curve>();
                                                        bool getCrvs = CurveSegments(rCurves, c, true);

                                                        if (rCurves.Count > 0)
                                                        {
                                                            int crvSeg = rCurves.Count;
                                                            crvSegmentIds.Add(crvSeg);
                                                            foreach (Curve rc in rCurves)
                                                            {
                                                                LyrebirdCurve lbc;
                                                                lbc = GetLBCurve(rc);
                                                                lbCurves.Add(lbc);
                                                            }
                                                        }
                                                    }
                                                    RevitObject ro = new RevitObject();
                                                    ro.Curves = lbCurves;
                                                    ro.FamilyName = familyName;
                                                    ro.Category = category;
                                                    ro.CategoryId = categoryId;
                                                    ro.TypeName = typeName;
                                                    ro.Origin = null;
                                                    ro.GHPath = crvTree.Paths[i].ToString();
                                                    ro.GHScaleFactor = scale.ScaleFactor;
                                                    ro.GHScaleName = scale.ScaleName;
                                                    ro.CurveIds = crvSegmentIds;
                                                    tempObjs.Add(ro);
                                                }
                                            }
                                            else
                                            {
                                                allInterior = false;
                                                message = "Warning:\n\nEach Branch represents an object, " +
                                                "so curve based elements should be grafted so that each curve is on it's own branch, or all curves on a branch should " +
                                                "be interior to the largest, outer boundary.";
                                            }
                                        }
                                        catch
                                        {
                                            allInterior = false;
                                            // Inform the user they need to graft their inputs.  Only one curve per branch
                                            message = "Warning:\n\nEach Branch represents an object, " +
                                                "so curve based elements should be grafted so that each curve is on it's own branch, or all curves on a branch should " +
                                                "be interior to the largest, outer boundary.";
                                        }
                                    }
                                    if (tempObjs.Count > 0)
                                    {
                                        obj = tempObjs;
                                    }
                                }
                            }
                        }
                        #endregion

                        // Orientation
                        if (orientations != null && orientations.Branches.Count > 0)
                        {
                            List<RevitObject> tempList = AssignOrientation(obj, orientations);
                            obj = tempList;
                        }

                        // face orientation
                        if (faceOrientations != null && faceOrientations.Branches.Count > 0)
                        {
                            List<RevitObject> tempList = AssignFaceOrientation(obj, faceOrientations);
                            obj = tempList;
                        }

                        // Parameters...
                        if (Params.Input.Count > 6)
                        {
                            List<RevitObject> currentObjs = obj;
                            List<RevitObject> tempObjs = new List<RevitObject>();
                            for (int r = 0; r < currentObjs.Count; r++)
                            {
                                RevitObject ro = currentObjs[r];
                                List<RevitParameter> revitParams = new List<RevitParameter>();
                                for (int i = 6; i < Params.Input.Count; i++)
                                {

                                    RevitParameter rp = new RevitParameter();
                                    IGH_Param param = Params.Input[i];
                                    string paramInfo = param.Description;
                                    string[] pi = paramInfo.Split(new[] { "\n", ":" }, StringSplitOptions.None);
                                    string paramName = null;
                                    try
                                    {
                                        paramName = pi[1].Substring(1);
                                        string paramStorageType = pi[5].Substring(1);
                                        rp.ParameterName = paramName;
                                        rp.StorageType = paramStorageType;
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine(ex.Message);
                                    }
                                    if (paramName != null)
                                    {
                                        GH_Structure<IGH_Goo> data = null;
                                        try
                                        {
                                            DA.GetDataTree(i, out data);
                                        }
                                        catch (Exception ex)
                                        {
                                            Debug.WriteLine(ex.Message);
                                        }
                                        if (data != null)
                                        {
                                            string value = data[r][0].ToString();
                                            rp.Value = value;
                                            revitParams.Add(rp);
                                        }
                                    }

                                }
                                ro.Parameters = revitParams;
                                tempObjs.Add(ro);
                            }
                            obj = tempObjs;
                        }

                        // Send the data to Revit to create and/or modify family instances.
                        if (obj != null && obj.Count > 0)
                        {
                            try
                            {
                                string docName = channel.DocumentName();
                                if (docName == null || docName == string.Empty)
                                {
                                    message = "Could not contact the lyrebird server.  Make sure it's running and try again.";
                                }
                                else
                                {
                                    string nn = NickName;
                                    if (nn == null || nn.Length == 0)
                                    {
                                        nn = "LBOut";
                                    }
                                    channel.CreateOrModify(obj, InstanceGuid, NickName);
                                    message = obj.Count.ToString() + " objects sent to the lyrebird server.";
                                }
                            }
                            catch
                            {
                                message = "Could not contact the lyrebird server.  Make sure it's running and try again.";
                            }
                        }
                        channel.Dispose();
                        try
                        {
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        message = "Error\n" + "The Lyrebird Service could not be found.  Ensure Revit is running, the Lyrebird server plugin is installed, and the server is active.";
                    }
                }
            }
            else
            {
                message = null;
            }

            // Check if the revit information is set
            if (familyName != null || (familyName != "Not Selected" && typeName != "Not Selected"))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Family: " + familyName);
                sb.AppendLine("Type: " + typeName);
                sb.AppendLine("Category: " + category);
                for (int i = 0; i < inputParameters.Count; i++)
                {
                    RevitParameter rp = inputParameters[i];
                    string type = "Instance";
                    if (rp.IsType)
                    {
                        type = "Type";
                    }
                    sb.AppendLine(string.Format("Parameter{0}: {1}  /  {2}  /  {3}", (i + 1).ToString(CultureInfo.InvariantCulture), rp.ParameterName, rp.StorageType, type));
                }
                objMessage = sb.ToString();
            }
            else
            {
                objMessage = "No data type set.  Double-click to set data type";
            }

            DA.SetData(0, objMessage);
            DA.SetData(1, message);
        }
Ejemplo n.º 39
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Retrieve and validate data
            var cell = new UnitCell();
            double radius = 0;
            double height = 0;
            int nU = 0;
            int nV = 0;
            int nW = 0;
            bool morphed = false;

            if (!DA.GetData(0, ref cell)) { return; }
            if (!DA.GetData(1, ref radius)) { return; }
            if (!DA.GetData(2, ref height)) { return; }
            if (!DA.GetData(3, ref nU)) { return; }
            if (!DA.GetData(4, ref nV)) { return; }
            if (!DA.GetData(5, ref nW)) { return; }
            if (!DA.GetData(6, ref morphed)) { return; }

            if (!cell.isValid) { return; }
            if (radius == 0) { return; }
            if (height == 0) { return; }
            if (nU == 0) { return; }
            if (nV == 0) { return; }
            if (nW == 0) { return; }

            // 2. Initialize the lattice
            var lattice = new Lattice();
            // Will contain the morphed uv spaces (as surface-surface, surface-axis or surface-point)
            var spaceTree = new DataTree<GeometryBase>(); 
            
            // 3. Define cylinder
            Plane basePlane = Plane.WorldXY;
            Surface cylinder = ( new Cylinder(new Circle(basePlane, radius), height) ).ToNurbsSurface();
            cylinder = cylinder.Transpose();
            LineCurve axis = new LineCurve(basePlane.Origin, basePlane.Origin + height*basePlane.ZAxis);

            // 4. Package the number of cells in each direction into an array
            float[] N = new float[3] { nU, nV, nW };

            // 5. Normalize the UV-domain
            Interval unitDomain = new Interval(0, 1);
            cylinder.SetDomain(0, unitDomain); // surface u-direction
            cylinder.SetDomain(1, unitDomain); // surface v-direction
            axis.Domain = unitDomain;

            // 6. Prepare cell (this is a UnitCell object)
            cell = cell.Duplicate();
            cell.FormatTopology();

            // 7. Map nodes to design space
            //    Loop through the uvw cell grid
            for (int u = 0; u <= N[0]; u++)
            {
                for (int v = 0; v <= N[1]; v++)
                {
                    for (int w = 0; w <= N[2]; w++)
                    {
                        // Construct cell path in tree
                        GH_Path treePath = new GH_Path(u, v, w);
                        // Fetch the list of nodes to append to, or initialise it
                        var nodeList = lattice.Nodes.EnsurePath(treePath);      

                        // This loop maps each node index in the cell onto the UV-surface maps
                        for (int i = 0; i < cell.Nodes.Count; i++)
                        {
                            double usub = cell.Nodes[i].X; // u-position within unit cell (local)
                            double vsub = cell.Nodes[i].Y; // v-position within unit cell (local)
                            double wsub = cell.Nodes[i].Z; // w-position within unit cell (local)
                            double[] uvw = { u + usub, v + vsub, w + wsub }; // uvw-position (global)

                            // Check if the node belongs to another cell (i.e. it's relative path points outside the current cell)
                            bool isOutsideCell = (cell.NodePaths[i][0] > 0 || cell.NodePaths[i][1] > 0 || cell.NodePaths[i][2] > 0);
                            // Check if current uvw-position is beyond the upper boundary
                            bool isOutsideSpace = (uvw[0] > N[0] || uvw[1] > N[1] || uvw[2] > N[2]);

                            if (isOutsideCell || isOutsideSpace)
                            {
                                nodeList.Add(null);
                            }
                            else
                            {
                                Point3d pt1, pt2;
                                Vector3d[] derivatives;

                                // Construct z-position vector
                                Vector3d vectorZ = height * basePlane.ZAxis * uvw[0] / N[0];
                                // Compute pt1 (on axis)
                                pt1 = basePlane.Origin + vectorZ;
                                // Compute pt2 (on surface)
                                cylinder.Evaluate(uvw[0] / N[0], uvw[1] / N[1], 2, out pt2, out derivatives);       

                                // Create vector joining these two points
                                Vector3d wVect = pt2 - pt1;
                                // Instantiate new node
                                var newNode = new LatticeNode(pt1 + wVect * uvw[2] / N[2]);
                                // Add new node to tree
                                nodeList.Add(newNode); 
                            }
                        }
                    }

                    // Define the uv space map tree (used for morphing)
                    if (morphed && u < N[0] && v < N[1])
                    {
                        GH_Path spacePath = new GH_Path(u, v);
                        // Set trimming interval
                        var uInterval = new Interval((u) / N[0], (u + 1) / N[0]);                   
                        var vInterval = new Interval((v) / N[1], (v + 1) / N[1]);
                        // Create sub-surface and sub axis
                        Surface ss1 = cylinder.Trim(uInterval, vInterval);                          
                        Curve ss2 = axis.Trim(uInterval);
                        // Unitize domains
                        ss1.SetDomain(0, unitDomain); ss1.SetDomain(1, unitDomain);                 
                        ss2.Domain = unitDomain;
                        // Save to the space tree
                        spaceTree.Add(ss1, spacePath);
                        spaceTree.Add(ss2, spacePath);
                    }
                }
            }

            // 8. Map struts to the node tree
            if (morphed)
            {
                lattice.MorphMapping(cell, spaceTree, N);
            }
            else
            {
                lattice.ConformMapping(cell, N);
            }

            // 9. Set output
            DA.SetDataList(0, lattice.Struts);            
        }
        /// <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)
        {
            //---- Declareing -------------------------------------------------------------------------------

            GH_Structure<GH_Point> SofistikPts;
            DA.GetDataTree("SofistikPoints", out SofistikPts);

            List<Point3d> flatclean = new List<Point3d>();
            DA.GetDataList<Point3d>("Flatten Points", flatclean);

            DataTree<int> SofistikInt = new DataTree<int>();

            //---- End Declareing ---------------------------------------------------------------------------

            //---- Functions --------------------------------------------------------------------------------

            for (int i = 0; i < flatclean.Count; i++)
            {
                Point3d fpoint = flatclean[i];

                for (int j = 0; j < SofistikPts.Paths.Count; j++)
                {
                    GH_Path pth = SofistikPts.Paths[j];
                    for (int k = 0; k < SofistikPts[pth].Count; k++)
                    {
                        GH_Point ghp = SofistikPts[pth][k];

                        if ((Math.Abs(fpoint.X - ghp.Value.X) <= 0.01) &&
                                (Math.Abs(fpoint.Y - ghp.Value.Y) <= 0.01) &&
                                (Math.Abs(fpoint.Z - ghp.Value.Z) <= 0.01))
                        {
                            SofistikInt.Add(i, pth.AppendElement(k));
                        }
                    }

                }
            }

            //---- End Functions ----------------------------------------------------------------------------

            //---- Set Output -----------------------------------------------------------------------------

            DA.SetDataTree(0, SofistikInt);

            //---- End Set Output -----------------------------------------------------------------------------
        }
Ejemplo n.º 41
0
    public static DataTree<Polyline> makeTiles(Mesh mesh)
    {
        DataTree < Polyline> Tree = new DataTree<Polyline>();
        for(int i = 0;i < mesh.Faces.Count;i++)
        {
          Vector3d ab = new Vector3d (mesh.Vertices[mesh.Faces[i].B] - mesh.Vertices[mesh.Faces[i].A]);
          Vector3d ac = new Vector3d (mesh.Vertices[mesh.Faces[i].C] - mesh.Vertices[mesh.Faces[i].A]);

          Point3dList pts = new Point3dList();
          pts.Add(mesh.Vertices[mesh.Faces[i].A]);
          pts.Add(mesh.Vertices[mesh.Faces[i].C]);
          pts.Add(mesh.Vertices[mesh.Faces[i].B]);
          Polyline edge = new Polyline(pts);
          Tree.Add(edge);
        }
        return Tree;
    }
Ejemplo n.º 42
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Declare placeholder
            string source = null;
            string query = null;
            string indexPath = null;

            DataTree<string> queryResultTree = new DataTree<string>();

            // 2. Abort on invalid inputs.
            if (!DA.GetData(0, ref source)) { return; }
            if (source == null) { return; }
            if (source.Length == 0) { return; }
            if (!DA.GetData(1, ref query)) { return; }
            if (query == null) { return; }
            if (query.Length == 0) { return; }
            if (!DA.GetData(2, ref indexPath)) { return; }
            if (query == null) { return; }
            if (query.Length == 0) { return; }

            gh_watcher = new GH_FileWatcher(indexPath, true, gh_watcher_Changed);

            // 3. Connect to source & fetch data

            MySqlConnection connection = new MySqlConnection(source);

            try
            {
                connection.Open();
            }
            catch (Exception ex)
            {
                output.Add("Connection Failed.\n" + ex.ToString());
            }

            try
            {
                MySqlCommand command = connection.CreateCommand();
                command.CommandText = query;

                MySqlDataReader reader = command.ExecuteReader();

                int i = 0;
                while (reader.Read())
                {
                    for (int j = 0; j < reader.FieldCount; j++)
                    {
                        queryResultTree.Add(reader.GetString(j), new GH_Path(i));
                    }
                    i++;
                }
            }
            catch (Exception ex)
            {
                output.Add("Fetching failed.\n" + ex.ToString());
            }

            connection.Close();

            // 4. Output
            DA.SetDataTree(0, queryResultTree);
            DA.SetDataList(1, output);
        }
Ejemplo n.º 43
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Retrieve and validate inputs
            var cell = new UnitCell();
            Surface s1 = null;
            Surface s2 = null;
            int nU = 0;
            int nV = 0;
            int nW = 0;
            bool morphed = false;

            if (!DA.GetData(0, ref cell)) { return; }
            if (!DA.GetData(1, ref s1)) { return; }
            if (!DA.GetData(2, ref s2)) { return; }
            if (!DA.GetData(3, ref nU)) { return; }
            if (!DA.GetData(4, ref nV)) { return; }
            if (!DA.GetData(5, ref nW)) { return; }
            if (!DA.GetData(6, ref morphed)) { return; }

            if (!cell.isValid) { return; }
            if (!s1.IsValid) { return; }
            if (!s2.IsValid) { return; }
            if (nU == 0) { return; }
            if (nV == 0) { return; }
            if (nW == 0) { return; }

            // 2. Initialize the lattice
            var lattice = new Lattice();
            // Will contain the morphed uv spaces (as surface-surface)
            var spaceTree = new DataTree<GeometryBase>(); 
            
            // 3. Package the number of cells in each direction into an array
            float[] N = new float[3] { nU, nV, nW };

            // 4. Normalize the UV-domain
            Interval unitDomain = new Interval(0,1);
            s1.SetDomain(0, unitDomain); // s1 u-direction
            s1.SetDomain(1, unitDomain); // s1 v-direction
            s2.SetDomain(0, unitDomain); // s2 u-direction
            s2.SetDomain(1, unitDomain); // s2 v-direction

            // 5. Prepare cell (this is a UnitCell object)
            cell = cell.Duplicate();
            cell.FormatTopology();

            // 6. Map nodes to design space
            //    Loop through the uvw cell grid
            for (int u = 0; u <= N[0]; u++)
            {
                for (int v = 0; v <= N[1]; v++)
                {
                    for (int w = 0; w <= N[2]; w++)
                    {
                        // Construct cell path in tree
                        GH_Path treePath = new GH_Path(u, v, w);
                        // Fetch the list of nodes to append to, or initialise it
                        var nodeList = lattice.Nodes.EnsurePath(treePath);      

                        // This loop maps each node in the cell onto the UV-surface maps
                        for (int i = 0; i < cell.Nodes.Count; i++)
                        {
                            double usub = cell.Nodes[i].X; // u-position within unit cell (local)
                            double vsub = cell.Nodes[i].Y; // v-position within unit cell (local)
                            double wsub = cell.Nodes[i].Z; // w-position within unit cell (local)
                            double[] uvw = { u + usub, v + vsub, w + wsub }; // uvw-position (global)

                            // Check if the node belongs to another cell (i.e. it's relative path points outside the current cell)
                            bool isOutsideCell = (cell.NodePaths[i][0] > 0 || cell.NodePaths[i][1] > 0 || cell.NodePaths[i][2] > 0);
                            // Check if current uvw-position is beyond the upper boundary
                            bool isOutsideSpace = (uvw[0] > N[0] || uvw[1] > N[1] || uvw[2] > N[2]);

                            if (isOutsideCell || isOutsideSpace)
                            {
                                nodeList.Add(null);
                            }
                            else
                            {
                                // Initialize for surface 1
                                Point3d pt1; Vector3d[] derivatives1;
                                // Initialize for surface 2
                                Point3d pt2; Vector3d[] derivatives2;

                                // Evaluate point on both surfaces
                                s1.Evaluate(uvw[0] / N[0], uvw[1] / N[1], 2, out pt1, out derivatives1);
                                s2.Evaluate(uvw[0] / N[0], uvw[1] / N[1], 2, out pt2, out derivatives2);

                                // Create vector joining the two points (this is our w-range)
                                Vector3d wVect = pt2 - pt1;

                                // Create the node, accounting for the position along the w-direction
                                var newNode = new LatticeNode(pt1 + wVect * uvw[2] / N[2]);
                                // Add node to tree
                                nodeList.Add(newNode);
                            }
                        }
                    }

                    // Define the uv space tree (used for morphing)
                    if (morphed && u < N[0] && v < N[1])
                    {
                        GH_Path spacePath = new GH_Path(u, v);
                        // Set trimming interval
                        var uInterval = new Interval((u) / N[0], (u + 1) / N[0]);
                        var vInterval = new Interval((v) / N[1], (v + 1) / N[1]);
                        // Create sub-surfaces
                        Surface ss1 = s1.Trim(uInterval, vInterval);
                        Surface ss2 = s2.Trim(uInterval, vInterval);
                        // Unitize domain
                        ss1.SetDomain(0, unitDomain); ss1.SetDomain(1, unitDomain);
                        ss2.SetDomain(0, unitDomain); ss2.SetDomain(1, unitDomain); 
                        // Save to the space tree
                        spaceTree.Add(ss1, spacePath);
                        spaceTree.Add(ss2, spacePath);
                    }
                    
                }
            }

            // 7. Map struts to the node tree
            if (morphed) lattice.MorphMapping(cell, spaceTree, N);
            else lattice.ConformMapping(cell, N);

            // 8. Set output
            DA.SetDataList(0, lattice.Struts);

        }
Ejemplo n.º 44
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)
        {
            //---- Declareing ---------------------------------------------------------------------------

            List<Tri_Loop_Component> All_Components = new List<Tri_Loop_Component>();
            DA.GetDataList<Tri_Loop_Component>("Components", All_Components);

            DataTree<Point3d> SofistikPoints = new DataTree<Point3d>();
            DataTree<int> SofistikIndexies = new DataTree<int>();

            DataTree<int> SofistikCrvPtIdx = new DataTree<int>();
            DataTree<Point3d> SofistikCrvPtCoo = new DataTree<Point3d>();

            DataTree<Brep> SofistikBreps = new DataTree<Brep>();
            DataTree<int> SofistikBrepsIdx = new DataTree<int>();

            DataTree<Curve> SofistikCurves = new DataTree<Curve>();

            //---- End Declareing -----------------------------------------------------------------------

            //---- Functions ----------------------------------------------------------------------------

            int componentIdx = 0;

            foreach (Tri_Loop_Component component in All_Components)
            {
                GH_Path pth1 = new GH_Path(componentIdx);

                // run / generate Informations for Sofistik
                component.SofistikInformation();
                component.SofistikCreateSurfaces();

                // Points
                for (int j = 0; j < component.SofistikPlatePoints.BranchCount; j++)
                {

                    foreach (Point3d p in component.SofistikPlatePoints.Branch(j))
                    { SofistikPoints.Add(p, pth1.AppendElement(j)); }

                    foreach (int idx in component.SofistikPlateIndexies.Branch(j))
                    { SofistikIndexies.Add(idx, pth1.AppendElement(j)); }
                }

                // CurvePoints
                for (int j = 0; j < component.SofistikCrvPtCoo.BranchCount; j++)
                {
                    GH_Path pth0 = component.SofistikCrvPtCoo.Path(j);

                    foreach (Point3d pt in component.SofistikCrvPtCoo.Branch(j))
                    {
                        //pth1.AppendElement(pth0[0]);
                        //pth1.AppendElement(pth0[1]);
                        //SofistikCrvPtCoo.Add(pt, pth1.AppendElement(pth0[0]));

                        // 2 level Tree
                        SofistikCrvPtCoo.Add(pt, pth1.AppendElement(pth0[0]));

                    }

                    foreach (int idx in component.SofistikCrvPtIdx.Branch(j))
                    {
                        //pth1.AppendElement(pth0[0]);
                        //pth1.AppendElement(pth0[1]);
                        //SofistikCrvPtIdx.Add(idx, pth1.AppendElement(pth0[0]));

                        // 2 level Tree
                        SofistikCrvPtIdx.Add(idx, pth1.AppendElement(pth0[0]));

                    }
                }

                // Curves
                for (int i = 0; i < component.SofistikCurves.BranchCount; i++)
                {
                    GH_Path pth0 = component.SofistikCurves.Path(i);

                    foreach (Curve c in component.SofistikCurves.Branch(i))
                    {
                        SofistikCurves.Add(c, pth1.AppendElement(pth0[0]));
                    }

                }

                // Surfaces
                for (int j = 0; j < component.SofistikSurfaces.BranchCount; j++)
                {

                    foreach (Brep[] p in component.SofistikSurfaces.Branch(j))
                    { SofistikBreps.Add(p[0], pth1.AppendElement(j)); }

                    foreach (int idx in component.SofistikSurfacesIdx.Branch(j))
                    { SofistikBrepsIdx.Add(idx, pth1.AppendElement(j)); }
                }

                componentIdx++;
            }

            //---- End Functions ------------------------------------------------------------------------
            //---- Set Output ---------------------------------------------------------------------------

            DA.SetDataTree(0, SofistikPoints);
            DA.SetDataTree(1, SofistikIndexies);

            DA.SetDataTree(2, SofistikCrvPtCoo);
            DA.SetDataTree(3, SofistikCrvPtIdx);

            DA.SetDataTree(4, SofistikBreps);
            DA.SetDataTree(5, SofistikBrepsIdx);

            DA.SetDataTree(6, SofistikCurves);

            //---- End Set Output -----------------------------------------------------------------------
        }
Ejemplo n.º 45
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)
        {
            //---- Declareing ---------------------------------------------------------------------------
            GH_Structure<GH_Brep> AllStripes;
            DA.GetDataTree("Triloop Stipes", out AllStripes);

            GH_Structure<GH_Point> AllPoints;
            DA.GetDataTree("Points", out AllPoints);

            bool Reorient = false;
            DA.GetData<bool>("Merge Stripes", ref Reorient);

            bool Switch = false;
            DA.GetData<bool>("Switch", ref Switch);

            int Seam = 0;
            DA.GetData<int>("Seam", ref Seam);

            DataTree<Brep> AllUnrolledBreps = new DataTree<Brep>();
            DataTree<Brep> ForReorientBreps = new DataTree<Brep>();
            DataTree<Plane> AllOrientPlanes = new DataTree<Plane>();
            DataTree<Curve> AllSharedCurves = new DataTree<Curve>();
            DataTree<Point3d> AllUnrolledPoints = new DataTree<Point3d>();

            //---- End Declareing -----------------------------------------------------------------------
            //---- Functions ----------------------------------------------------------------------------

            #region Unroll

            for (int i = 0; i < AllStripes.Branches.Count; i++)
            {
                GH_Path pth = new GH_Path(i);
                GH_Path originalPath = AllStripes.Paths[i];
                int stripecounter = 0;

                foreach (GH_Brep gbrep in AllStripes[i])
                {
                    Unroller unroll = new Unroller(gbrep.Value);
                    // Add points to unroll with
                    if (AllPoints.Branches.Count != 0)
                    {
                        foreach (GH_Point pt in AllPoints[i])
                        { unroll.AddFollowingGeometry(pt.Value); }
                    }

                    unroll.ExplodeOutput = false;

                    Curve[] curves;
                    Point3d[] unrolledPoints;
                    TextDot[] dots;
                    Brep[] unrolledBreps = unroll.PerformUnroll(out curves, out unrolledPoints, out dots);

                    if (Reorient == false)
                    {
                        foreach (Brep b in unrolledBreps)
                        { AllUnrolledBreps.Add(b, originalPath); }

                        foreach (Point3d p in unrolledPoints)
                        { AllUnrolledPoints.Add(p, originalPath); }
                    }

                    else
                    {
                        foreach (Brep b in unrolledBreps)
                        { AllUnrolledBreps.Add(b, pth.AppendElement(stripecounter)); }
                    }

                    // For reorientation
                    if (Reorient == true)
                    { ForReorientBreps.Add(unrolledBreps[Seam], pth); }

                    stripecounter++;
                }
            }
            #endregion unroll

            if (Reorient == true)
            {
                //ForReorientBreps.Branch(0)[0].Curves3D[0].PointAtEnd;

                for (int i = 0; i < ForReorientBreps.BranchCount; i++)
                {
                    GH_Path pth = new GH_Path(i);

                    foreach (Curve crv0 in ForReorientBreps.Branch(i)[0].Curves3D)
                    {
                        foreach (Curve crv1 in ForReorientBreps.Branch(i)[1].Curves3D)
                        {
                            double l0 = crv0.GetLength();
                            double l1 = crv1.GetLength();

                            if (Math.Abs(l0 - l1) < 0.00001)
                            {

                                // orient crv0
                                Plane origin0 = new Plane(new Point3d(0, 0, 0), new Vector3d(1, 0, 0), new Vector3d(0, 1, 0));
                                Plane target0 = new Plane(origin0);
                                AllOrientPlanes.Add(origin0, pth.AppendElement(0));
                                AllOrientPlanes.Add(target0, pth.AppendElement(0));

                                // orient crv1
                                Vector3d vect0 = crv1.TangentAtStart;
                                Vector3d vect1 = Vector3d.CrossProduct(vect0, new Vector3d(0.0, 0.0, 1.0));
                                Plane origin1 = new Plane(crv1.PointAtStart, vect0, vect1);

                                Vector3d vect2 = new Vector3d();
                                Vector3d vect3 = new Vector3d();
                                Plane target1 = new Plane();

                                if (Switch == true)
                                {
                                    vect2 = crv0.TangentAtStart;
                                    vect3 = Vector3d.CrossProduct(vect2, new Vector3d(0.0, 0.0, 1.0));
                                    target1 = new Plane(crv0.PointAtStart, vect2, vect3);
                                }

                                else
                                {
                                    vect2 = crv0.TangentAtStart;
                                    vect3 = Vector3d.CrossProduct(-vect2, new Vector3d(0.0, 0.0, 1.0));
                                    target1 = new Plane(crv0.PointAtEnd, -vect2, vect3);
                                }

                                AllOrientPlanes.Add(origin1, pth.AppendElement(1));
                                AllOrientPlanes.Add(target1, pth.AppendElement(1));
                                // shared curve of stripe0 and stripe 1
                                AllSharedCurves.Add(crv0, pth.AppendElement(0));
                                AllSharedCurves.Add(crv1, pth.AppendElement(0));

                            }
                        }

                        // orient crv2
                        foreach (Curve crv2 in ForReorientBreps.Branch(i)[2].Curves3D)
                        {
                            double l0 = crv0.GetLength();
                            double l1 = crv2.GetLength();

                            if (Math.Abs(l0 - l1) < 0.00001)
                            {
                                Vector3d vect0 = crv2.TangentAtStart;
                                Vector3d vect1 = Vector3d.CrossProduct(vect0, new Vector3d(0.0, 0.0, 1.0));
                                Plane origin2 = new Plane(crv2.PointAtStart, vect0, vect1);

                                Vector3d vect2 = new Vector3d();
                                Vector3d vect3 = new Vector3d();
                                Plane target2 = new Plane();

                                if (Switch == true)
                                {
                                    vect2 = crv0.TangentAtStart;
                                    vect3 = Vector3d.CrossProduct(vect2, new Vector3d(0.0, 0.0, 1.0));
                                    target2 = new Plane(crv0.PointAtStart, vect2, vect3);
                                }

                                else
                                {
                                    vect2 = crv0.TangentAtStart;
                                    vect3 = Vector3d.CrossProduct(-vect2, new Vector3d(0.0, 0.0, 1.0));
                                    target2 = new Plane(crv0.PointAtEnd, -vect2, vect3);
                                }

                                AllOrientPlanes.Add(origin2, pth.AppendElement(2));
                                AllOrientPlanes.Add(target2, pth.AppendElement(2));
                                // shared curve of stripe0 and stripe 2
                                AllSharedCurves.Add(crv2, pth.AppendElement(2));
                                AllSharedCurves.Add(crv0, pth.AppendElement(2));
                            }
                        }

                    }
                    // find the shared curve oft stripe 1 and stripe 2
                    foreach (Curve crv1 in ForReorientBreps.Branch(i)[1].Curves3D)
                    {
                        foreach (Curve crv2 in ForReorientBreps.Branch(i)[2].Curves3D)
                        {
                            double l1 = crv1.GetLength();
                            double l2 = crv2.GetLength();

                            // shared curve of stripe1 and stripe 2
                            if (Math.Abs(l1 - l2) < 0.00001)
                            {
                                AllSharedCurves.Add(crv1, pth.AppendElement(1));
                                AllSharedCurves.Add(crv2, pth.AppendElement(1));
                            }

                        }

                    }
                }

            }

            //---- End Functions --------------------------------------------------------------------------
            //----Set Output-------------------------------------------------------------------------------

            DA.SetDataTree(0, AllUnrolledBreps);
            DA.SetDataTree(1, AllOrientPlanes);
            DA.SetDataTree(2, AllSharedCurves);
            DA.SetDataTree(3, AllUnrolledPoints);

            //----End Set Output---------------------------------------------------------------------------
        }
Ejemplo n.º 46
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)
        {
            //---- Declareing ---------------------------------------------------------------------------

            List<Tri_Loop_Component> All_Components = new List<Tri_Loop_Component>();
            DA.GetDataList<Tri_Loop_Component>("Components", All_Components);

            DataTree<Curve> All_Curves = new DataTree<Curve>();

            //// =======================================================================================
            // Added by Gene
            DataTree<Curve> All_ExtendedCurves = new DataTree<Curve>();
            DataTree<Brep> All_SingleStripeBreps = new DataTree<Brep>();

            //// =======================================================================================

            DataTree<Point3d> All_CentrePointsL01 = new DataTree<Point3d>();
            DataTree<Point3d> All_CentrePointsL02 = new DataTree<Point3d>();
            DataTree<Curve> All_PlateCrv = new DataTree<Curve>();

            DataTree<Point3d> All_PentagonPts_L01 = new DataTree<Point3d>();
            DataTree<Point3d> All_PentagonPts_L02 = new DataTree<Point3d>();

            DataTree<int> All_StripeIds = new DataTree<int>();
            DataTree<Brep> All_StripeBreps = new DataTree<Brep>();
            DataTree<Curve> All_StripeIntersectCrvs = new DataTree<Curve>();
            DataTree<Plane> All_StripeIntersectPlane = new DataTree<Plane>();

            //---- End Declareing -----------------------------------------------------------------------
            //---- Functions ----------------------------------------------------------------------------

            int componentIdx = 0;

            foreach (Tri_Loop_Component component in All_Components)
            {
                GH_Path pth1 = new GH_Path(componentIdx);

                // run / generate Informations for Sofistik
                // create output information
                for (int p = 0; p < component.CentersL01.Count; p++)
                {
                    All_CentrePointsL01.Add(component.CentersL01[p], pth1);
                    All_CentrePointsL02.Add(component.CentersL02[p], pth1);
                }

                for (int c = 0; c < component.Curves.BranchCount; c++)
                {
                    All_Curves.Add(component.Curves.Branch(c)[0], pth1.AppendElement(c));
                    All_Curves.Add(component.Curves.Branch(c)[1], pth1.AppendElement(c));

                    //// =======================================================================================
                    // Added by Gene
                    All_ExtendedCurves.Add(component.ExtendedCurves.Branch(c)[0], pth1.AppendElement(c));
                    All_ExtendedCurves.Add(component.ExtendedCurves.Branch(c)[1], pth1.AppendElement(c));
                    //// =======================================================================================
                }

                for (int sid = 0; sid < component.StripeID.BranchCount; sid++)
                {
                    All_StripeIds.Add(component.StripeID.Branch(sid)[0], pth1.AppendElement(sid));
                    All_StripeIds.Add(component.StripeID.Branch(sid)[1], pth1.AppendElement(sid));
                    All_StripeIds.Add(component.StripeID.Branch(sid)[2], pth1.AppendElement(sid));
                }

                for (int p = 0; p < component.PlateCrv.BranchCount; p++)
                {
                    All_PlateCrv.Add(component.PlateCrv.Branch(p)[0], pth1.AppendElement(p));
                    All_PlateCrv.Add(component.PlateCrv.Branch(p)[1], pth1.AppendElement(p));
                }

                for (int pent = 0; pent < component.PlanarPentagonL01.BranchCount; pent++)
                {
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[0], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[1], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[2], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[3], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[4], pth1.AppendElement(pent));
                }

                for (int pent = 0; pent < component.PlanarPentagonL02.BranchCount; pent++)
                {
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[0], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[1], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[2], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[3], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[4], pth1.AppendElement(pent));
                }

                // Information from Stripe Class
                for (int s = 0; s < component.Stripes.Count; s++)
                {
                    for (int t = 0; t < component.Stripes[s].SurfaceAtLoop.Length; t++)
                    { All_StripeBreps.Add(component.Stripes[s].SurfaceAtLoop[t], pth1.AppendElement(s)); }

                    //for (int u = 0; u < component.Stripes[s].IntersectionCurve.Length; u++)
                    //{ All_StripeIntersectCrvs.Add(component.Stripes[s].IntersectionCurve[u], pth1.AppendElement(s));}

                    All_StripeIntersectPlane.Add(component.Stripes[s].IntersectionPlane, pth1.AppendElement(s));
                }

                // ======================================================================================================
                // Gene Added

                for (int s = 0; s < component.StripesSingle.Count; s++)
                {
                    All_SingleStripeBreps.Add(component.StripesSingle[s].loop, pth1.AppendElement(s));

                    //for (int u = 0; u < component.Stripes[s].IntersectionCurve.Length; u++)
                    //{ All_StripeIntersectCrvs.Add(component.Stripes[s].IntersectionCurve[u], pth1.AppendElement(s));}

                    //All_StripeIntersectPlane.Add(component.StripesSingle[s].IntersectionPlane, pth1.AppendElement(s));
                }

                // ======================================================================================================

                componentIdx++;
            }

            //---- End Functions ------------------------------------------------------------------------
            //---- Set Output ---------------------------------------------------------------------------

            DA.SetDataTree(0, All_CentrePointsL01);
            DA.SetDataTree(1, All_CentrePointsL02);
            DA.SetDataTree(2, All_Curves);
            DA.SetDataTree(3, All_PlateCrv);
            DA.SetDataTree(4, All_PentagonPts_L01);
            DA.SetDataTree(5, All_PentagonPts_L02);
            DA.SetDataTree(6, All_StripeIds);
            DA.SetDataTree(7, All_StripeBreps);
            DA.SetDataTree(8, All_StripeIntersectPlane);

            //// =======================================================================================
            // Added by Gene

            DA.SetDataTree(9, All_ExtendedCurves);
            DA.SetDataTree(10, All_SingleStripeBreps);
            //// =======================================================================================

            //---- End Set Output -----------------------------------------------------------------------
        }