当前位置: 首页>>代码示例>>C#>>正文


C# IGH_DataAccess.GetDataTree方法代码示例

本文整理汇总了C#中IGH_DataAccess.GetDataTree方法的典型用法代码示例。如果您正苦于以下问题:C# IGH_DataAccess.GetDataTree方法的具体用法?C# IGH_DataAccess.GetDataTree怎么用?C# IGH_DataAccess.GetDataTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGH_DataAccess的用法示例。


在下文中一共展示了IGH_DataAccess.GetDataTree方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SolveInstance

        /// <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 -----------------------------------------------------------------------------
        }
开发者ID:GeneKao,项目名称:Pavilion2015_ITECH,代码行数:50,代码来源:GHC_Sofistik_Point_Indexer.cs

示例2: SafeSolveInstance

        protected override void SafeSolveInstance(IGH_DataAccess DA)
        {
            this.InitalizePrivateData();
            GH_Structure<Grasshopper.Kernel.Types.IGH_Goo> geom_tree = new GH_Structure<Grasshopper.Kernel.Types.IGH_Goo>();
            GH_Structure<Decodes_Attributes> attr_tree = new GH_Structure<Decodes_Attributes>();
            if ((DA.GetDataTree<Grasshopper.Kernel.Types.IGH_Goo>(0, out geom_tree)) && (DA.GetDataTree<Decodes_Attributes>(1, out attr_tree)))
            {
                if (geom_tree.PathCount != attr_tree.Branches.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "geometry and property inputs do not have the same number of branches.  check your inputs."); return; }

                for (int b = 0; b < geom_tree.Branches.Count; b++)
                {
                    List<Grasshopper.Kernel.Types.IGH_Goo> geom_given = geom_tree.Branches[b];
                    List<Decodes_Attributes> attr_given = attr_tree.Branches[b];

                    if (geom_given.Count != attr_given.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "geometry and property inputs are not lists of the same length.  check your inputs."); return; }

                    for (int i = 0; i < geom_given.Count; i++)
                    {
                        if (!(geom_given[i] is Grasshopper.Kernel.Types.IGH_GeometricGoo)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Did you give me something that isn't geometry?"); continue; }
                        try
                        {
                            m_obj.Add((Grasshopper.Kernel.Types.IGH_GeometricGoo)geom_given[i]);
                            if (!(attr_given[i] is Decodes_Attributes)) m_att.Add(new Decodes_Attributes());
                            else
                            {
                                m_att.Add(attr_given[i]);
                                if (!required_layers.Contains(attr_given[i].layer)) required_layers.Add(attr_given[i].layer);
                            }
                            m_branch_index.Add(b);
                        }
                        catch (Exception e)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Did you give me something that looks like geometry, but isn't?\n" + e.Message);
                        }

                    }
                }
            }
        }
开发者ID:jhaazpr,项目名称:decodes,代码行数:39,代码来源:DecodesBakeProps.cs

示例3: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeIn = new Grasshopper.Kernel.Data.GH_Structure<DHr>();

            if (DA.GetDataTree(0, out hourTreeIn)) {
                Plane plane = new Plane(new Point3d(0, 0, 0), new Vector3d(0, 0, 1));
                DA.GetData(1, ref plane);

                Grasshopper.Kernel.Types.UVInterval ival2d = new Grasshopper.Kernel.Types.UVInterval();
                if (!DA.GetData(2, ref ival2d)) {
                    ival2d.U0 = 0.0;
                    ival2d.U1 = 1.0;
                    ival2d.V0 = 0.0;
                    ival2d.V1 = 2.0;
                }
                if (ival2d.U.IsDecreasing) ival2d.U.Swap();
                if (ival2d.V.IsDecreasing) ival2d.V.Swap();

                double barWidthScale = 1.0;
                DA.GetData(3, ref barWidthScale);

                Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeOut = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point> points = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Rectangle> srects = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Rectangle>();
                List<Rectangle3d> rects = new List<Rectangle3d>();
                List<Mesh> meshes = new List<Mesh>();

                int i = 0;//keeps track of which branch we're on... note, this assumes we've been passed a list of lists and nothing 'deeper'
                int maxHourCount = hourTreeIn.Branches[0].Count;
                foreach (List<DHr> hourList in hourTreeIn.Branches) if (hourList.Count > maxHourCount) maxHourCount = hourList.Count;
                Rectangle3d brect = new Rectangle3d(plane, new Interval(0, ival2d.U1), new Interval(0, ival2d.V.ParameterAt((double)hourTreeIn.DataCount / maxHourCount)));
                DA.SetData(5, brect);

                double dx = ival2d.U.Length / hourTreeIn.Branches.Count * barWidthScale;
                double dy = ival2d.V.Length / maxHourCount;
                foreach (List<DHr> hourList in hourTreeIn.Branches) {
                    Grasshopper.Kernel.Data.GH_Path path = new Grasshopper.Kernel.Data.GH_Path(i);
                    hourTreeOut.EnsurePath(path);
                    points.EnsurePath(path);
                    srects.EnsurePath(path);

                    double x = ival2d.U.ParameterAt((i + 0.5) / hourTreeIn.Branches.Count);
                    for (int j = 0; j < hourList.Count; j++) {
                        DHr dhour = hourList[j];

                        double y = ival2d.V.ParameterAt((j + 0.5) / maxHourCount);
                        Point3d pt = plane.PointAt(x, y);
                        dhour.pos = new Point3d(x, y, 0);
                        points.Append(new Grasshopper.Kernel.Types.GH_Point(pt), path);
                        hourTreeOut.Append(dhour, path);

                        Plane pln = new Plane(plane);
                        pln.Origin = plane.PointAt(x - dx / 2, y - dy / 2);
                        Rectangle3d rct = new Rectangle3d(pln, dx, dy);
                        srects.Append(new Grasshopper.Kernel.Types.GH_Rectangle(rct), path);
                    }

                    // make meshes & big rectangles
                    if (hourList.Count > 0) {
                        Mesh mesh = new Mesh();
                        // add bottom pts
                        mesh.Vertices.Add(plane.PointAt(x - dx / 2, 0));
                        mesh.VertexColors.Add(hourList[0].color);
                        mesh.Vertices.Add(plane.PointAt(x + dx / 2, 0));
                        mesh.VertexColors.Add(hourList[0].color);

                        for (int j = 0; j < hourList.Count; j++) {
                            double y = ival2d.V.ParameterAt((j + 0.5) / maxHourCount);
                            mesh.Vertices.Add(plane.PointAt(x - dx / 2, y));
                            mesh.VertexColors.Add(hourList[j].color);
                            mesh.Vertices.Add(plane.PointAt(x + dx / 2, y));
                            mesh.VertexColors.Add(hourList[j].color);
                        }

                        // add top pts
                        double yy = ival2d.V.ParameterAt((float)hourList.Count / maxHourCount);
                        mesh.Vertices.Add(plane.PointAt(x - dx / 2, yy));
                        mesh.VertexColors.Add(hourList[hourList.Count - 1].color);
                        mesh.Vertices.Add(plane.PointAt(x + dx / 2, yy));
                        mesh.VertexColors.Add(hourList[hourList.Count - 1].color);

                        for (int n = 2; n < mesh.Vertices.Count; n = n + 2) mesh.Faces.AddFace(n - 2, n - 1, n + 1, n);
                        meshes.Add(mesh);

                        Plane pln = new Plane(plane);
                        pln.Origin = plane.PointAt(x - dx / 2, 0);
                        Rectangle3d rct = new Rectangle3d(pln, dx, yy);
                        rects.Add(rct);
                    }

                    i++;
                }

                DA.SetDataTree(0, hourTreeOut);
                DA.SetDataTree(1, points);
                DA.SetDataList(2, srects);
                DA.SetDataList(3, rects);
                DA.SetDataList(4, meshes);

            }
//.........这里部分代码省略.........
开发者ID:ksteinfe,项目名称:dyear,代码行数:101,代码来源:Components+Spatializing.cs

示例4: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            this.JSONIsPopulated = false;
            this.JSONString = "";
            Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.IGH_Goo> tree = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.IGH_Goo>();
            if (!DA.GetDataTree(0, out tree)) { return; }

            String JSONOpen = "";
            String JSONClose = "";
            JSONOpen = @"""" + this.ComponentName + @""":{";
            JSONClose = "}";

            DataStructure dim;
            if (tree.PathCount == 1) {
                if (tree.DataCount == 1) dim = DataStructure.Singleton; // a singleton
                else dim = DataStructure.List; // a list
            } else dim = DataStructure.Tree; // a tree
            JSONOpen += @"""DataStructure"":""" + dim.ToString() + @""",";

            String UniformType = "";
            bool IsUniform = JSONConverter.UniformDataType(tree, ref UniformType);
            if (IsUniform) JSONOpen += @"""Type"":""" + UniformType + @""",";

            if (dim == DataStructure.Singleton) {
                // SINGLETONS
                //
                String ObjString = "";
                IGH_Goo obj = tree.get_FirstItem(false);
                if ((obj != null)&&(JSONConverter.ObjectToJSON(obj, ref ObjString,false))){
                    this.JSONString = JSONOpen + @"""Value"":"+ObjString + JSONClose;
                    DA.SetData(0, "{" + this.JSONString + "}");
                    this.JSONIsPopulated = true;
                    return;
                } else {
                    // TODO: return failed item
                    this.JSONIsPopulated = false;
                    return;
                }
            } else if (dim == DataStructure.List) {
                // LISTS
                //

                JSONOpen += @"""Items"":{";
                JSONClose += "}";

                List<IGH_Goo> failures = new List<IGH_Goo>();
                List<String> ObjStrings = JSONConverter.ObjectsToJSON(tree.get_Branch(tree.Paths[0]), ref failures, !IsUniform);
                if (failures.Count > 0) AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Some items failed to be converted to JSON.");
                if (ObjStrings.Count == 0) {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Nothing was successfully converted to JSON.");
                    this.JSONIsPopulated = false;
                    return;
                }

                this.JSONString = JSONOpen + String.Join(",", ObjStrings.ToArray()) + JSONClose;
                DA.SetData(0, "{"+this.JSONString+"}");
                this.JSONIsPopulated = true;
                // TODO: return failed items
                return;
            } else {
                // TREES
                //
                JSONOpen += @"""BranchCount"":" + tree.Branches.Count + @",""DataCount"":" + tree.DataCount + @", ""Paths"":{";
                JSONClose += "}";

                List<IGH_Goo> failures = new List<IGH_Goo>();
                List<String> BranchStrings = new List<string>();

                foreach (Grasshopper.Kernel.Data.GH_Path path in tree.Paths) {
                    String BRANCHOpen = @"""" + path.ToString() + @""":{";
                    String BRANCHClose = "}";

                    List<String> ObjStrings = JSONConverter.ObjectsToJSON(tree.get_Branch(path), ref failures, !IsUniform);
                    if (ObjStrings.Count >= 0) {
                        BranchStrings.Add(BRANCHOpen + String.Join(",", ObjStrings.ToArray()) + BRANCHClose);
                    } else {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "An entire branch failed to be converted to JSON.");
                    }
                }

                if (failures.Count > 0) AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Some items failed to be converted to JSON.");

                this.JSONString = JSONOpen + String.Join(",", BranchStrings.ToArray()) + JSONClose;
                DA.SetData(0, "{" + this.JSONString + "}");
                this.JSONIsPopulated = true;
                // TODO: return failed items
                return;
            }
            //if (JSONConverter.ObjectToJSON(obj, ref JSONString)) DA.SetData(0, JSONString);
            //DA.SetData(0, tree.PathCount.ToString());
        }
开发者ID:ksteinfe,项目名称:lemmings,代码行数:91,代码来源:DataListener.cs

示例5: SolveInstance

        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;
//.........这里部分代码省略.........
开发者ID:ramonvanderheijden,项目名称:Lyrebird,代码行数:101,代码来源:GHClient.cs

示例6: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeIn = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
            string key = "";
            int subdivs = 0;
            if ((DA.GetDataTree(0, out hourTreeIn)) && (DA.GetData(1, ref key)) && (DA.GetData(3, ref subdivs)))
            {
                Interval ival_overall = new Interval();
                if (!DA.GetData(2, ref ival_overall)) {
                    // go thru the given hours and find the max and min value for the given key
                    ival_overall.T0 = MDHr.INVALID_VAL;
                    ival_overall.T1 = MDHr.INVALID_VAL;
                    foreach (DHr dhr in hourTreeIn.AllData(true)) {
                        float val = dhr.val(key);
                        if ((ival_overall.T0 == MDHr.INVALID_VAL) || (val < ival_overall.T0)) ival_overall.T0 = val;
                        if ((ival_overall.T1 == MDHr.INVALID_VAL) || (val > ival_overall.T1)) ival_overall.T1 = val;
                    }
                }

                Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeOut = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Integer> freqTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Integer>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Interval> ivalTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Interval>();

                List<Interval> ivalList = new List<Interval>();
                if (ival_overall.IsDecreasing) ival_overall.Swap();
                double delta = ival_overall.Length / subdivs;
                for (int n = 0; n < subdivs; n++) {  ivalList.Add(new Interval(ival_overall.T0 + n * delta, ival_overall.T0 + ((n + 1) * delta)));  }

                for (int b = 0; b < hourTreeIn.Branches.Count; b++)
                {
                    Grasshopper.Kernel.Data.GH_Structure<DHr> hourBranch = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                    for (int n = 0; n < subdivs; n++) { hourBranch.EnsurePath(n); }
                    List<int> freqOut = new List<int>();

                    List<DHr> hrsIn = hourTreeIn.Branches[b];
                    foreach (DHr dhr in hrsIn)
                    {
                        if (dhr.val(key) < ivalList[0].T0)
                        {
                            hourBranch.Append(dhr, new Grasshopper.Kernel.Data.GH_Path(0));
                            continue;
                        }
                        if (dhr.val(key) > ivalList[ivalList.Count - 1].T1)
                        {
                            hourBranch.Append(dhr, new Grasshopper.Kernel.Data.GH_Path(ivalList.Count - 1));
                            continue;
                        }
                        for (int n = 0; n < subdivs; n++)
                        {
                            if (ivalList[n].IncludesParameter(dhr.val(key)))
                            {
                                hourBranch.Append(dhr,new Grasshopper.Kernel.Data.GH_Path(n));
                                break;
                            }
                        }
                    }

                    for (int bb = 0; bb < hourBranch.Branches.Count; bb++)
                    {
                        Grasshopper.Kernel.Data.GH_Path branch_path = hourTreeIn.Paths[b].AppendElement(bb);
                        hourTreeOut.AppendRange(hourBranch.Branches[bb], branch_path);
                        Grasshopper.Kernel.Types.GH_Integer freq = new Grasshopper.Kernel.Types.GH_Integer(hourBranch.Branches[bb].Count);
                        freqTreeOut.Append(freq, branch_path);
                        Grasshopper.Kernel.Types.GH_Interval ival = new Grasshopper.Kernel.Types.GH_Interval(ivalList[bb]);
                        ivalTreeOut.Append(ival, branch_path);
                    }

                }

                hourTreeOut.Simplify(Grasshopper.Kernel.Data.GH_SimplificationMode.CollapseAllOverlaps);
                freqTreeOut.Simplify(Grasshopper.Kernel.Data.GH_SimplificationMode.CollapseAllOverlaps);
                ivalTreeOut.Simplify(Grasshopper.Kernel.Data.GH_SimplificationMode.CollapseAllOverlaps);

                DA.SetDataTree(0, freqTreeOut);
                DA.SetDataTree(1, ivalTreeOut);
                DA.SetDataTree(2, hourTreeOut);
            }
        }
开发者ID:ksteinfe,项目名称:dyear,代码行数:78,代码来源:Components+Filter.cs

示例7: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<int> hrs = new List<int>();
            List<string> keys = new List<string>();
            Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Number> valtree = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Number>();
            if ((DA.GetDataList(1, keys)) && (DA.GetDataTree(2, out valtree)) && (DA.GetDataList(0, hrs)))
            {

                bool has_color = false;
                List<Color> colors = new List<Color>();
                has_color = DA.GetDataList(4, colors);

                bool has_pt = false;
                List<Point3d> points = new List<Point3d>();
                has_pt = DA.GetDataList(4, points);

                if (hrs.Count != valtree.Branches.Count) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "List matching error.  Hours and Vals must match.  If you pass in more than one hour number, then you must pass in a tree of values with one branch per hour number, and vice-versa.");
                else foreach (List<GH_Number> branch in valtree.Branches) if (keys.Count != branch.Count) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "List matching error.  Keys and Vals must offer lists of the same length.  If you pass in a tree of values, each branch must contain a list of the same length as the list of keys.");
                        else
                        {
                            if (((has_color) && (colors.Count != hrs.Count)) || ((has_pt) && (points.Count != hrs.Count)))
                            {
                                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "List matching error.");
                                return;
                            }
                            List<DHr> hours = new List<DHr>();
                            for (int n = 0; n < valtree.Branches.Count; n++)
                            {
                                DHr hr = new DHr(hrs[n]);
                                for (int m = 0; m < keys.Count; m++) hr.put(keys[m], (float)valtree.Branches[n][m].Value);
                                if (has_color) hr.color = colors[n];
                                if (has_pt) hr.pos = points[n];
                                hours.Add(hr);
                            }
                            DA.SetDataList(0, hours);
                        }
            }
        }
开发者ID:ksteinfe,项目名称:dyear,代码行数:38,代码来源:Components+Primitive.cs

示例8: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // getting input
            DA.GetData<SpringMesh>("Spring Mesh", ref iSpringMesh);
            DA.GetDataList<Curve>("PolyLine", iPolyLine);
            DA.GetDataList<int>("PolyLine ID", iPolyLineID);
            DA.GetDataList<double>("Thickness", iThickness);
            DA.GetDataList<bool>("Vertex status", iVertexStatus);
            DA.GetData<bool>("Allow PolySrf", ref iPolySrf);
            DA.GetData<double>("TangentScale Min", ref iTangentScaleMin);
            DA.GetData<double>("TangentScale Max", ref iTangentScaleMax);
            DA.GetDataList<Point3d>("Attractors", iAttractors);
            DA.GetDataList<bool>("Vertex Panel2", iVertexPanel2);
            DA.GetData<double>("PlanarOffset Min", ref iPlanarOffsetScaleMin);
            DA.GetData<double>("PlanarOffset Max", ref iPlanarOffsetScaleMax);
            DA.GetData<double>("Curve Pointiness Min", ref CurvePointinessMin);
            DA.GetData<double>("Curve Pointiness Max", ref CurvePointinessMax);

            DA.GetData<double>("Opening Width Min", ref iOpeningWidthMin);
            DA.GetData<double>("Opening Width Max", ref iOpeningWidthMax);
            DA.GetDataTree<GH_Number>("Manual Adjustments", out ManualValueTree);
            DA.GetData<int>("Curve Degree", ref curveDegree);
            DA.GetData<double>("Ground Level", ref iGroundPos);

            DA.GetData<bool>("Super Normalization", ref iSuperNormalization);
            //------------------------------------------------------------

            // get all Vertex indexies that are manual adjusted
            for (int i = 0; i < ManualValueTree.Branches.Count; i++)
            { ManualAdjustedVertexIndexies.Add(ManualValueTree.Paths[i].Indices[0]); }

            storePlatesTPI();

            calculateVerticesValues();
            calculateVertexNormals();
            calculateVertexCps();
            //calculateVerticesValues();

            triLoop();

            half_dualLoop();

            oDebugList = vertexNormals;

            //------------------------------------------------------------

            // setting output
            DA.SetData("Info", oInfo);
            DA.SetDataList("General List", oDebugList);
            DA.SetDataTree(2, oTriLoop);
            DA.SetDataTree(3, oTriLoopID);
            DA.SetDataTree(4, oTriLoopCurves);
            DA.SetDataTree(5, oDualLoop1);
            DA.SetDataTree(6, oDualLoop2);
            DA.SetDataTree(7, oDualLoop1ID);
            DA.SetDataTree(8, oDualLoop2ID);
            DA.SetDataTree(9, oDualLoop1Curves);
            DA.SetDataTree(10, oDualLoop2Curves);
            DA.SetDataTree(11, oClosedPanel);
            DA.SetDataTree(12, oTriLoopPlanCrv);
            DA.SetDataTree(13, oTriLoopEffectorHoles);

            // -----------------------------------------------------------
        }
开发者ID:GeneKao,项目名称:Pavilion2015_ITECH,代码行数:64,代码来源:GHC_DoubleLayer_Topo_II(DataTree).cs

示例9: SolveInstance

        /// <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> PtL01;
            DA.GetDataTree("Layer 01 Points", out PtL01);

            GH_Structure<GH_Point> PtL02;
            DA.GetDataTree("Layer 02 Points", out PtL02);

            GH_Structure<GH_Integer> TopoPtIdx;
            DA.GetDataTree("Topology Points", out TopoPtIdx);

            GH_Structure<GH_Integer> NFIdx;
            DA.GetDataTree("Neighbour Face Index", out NFIdx);

            GH_Structure<GH_Integer> All_TopoEdges;
            DA.GetDataTree("Face Topology Edge Indexies", out All_TopoEdges);

            GH_Structure<GH_Point> EdgeCentreL01;
            DA.GetDataTree("Edge Centre L01", out EdgeCentreL01);

            GH_Structure<GH_Point> EdgeCentreL02;
            DA.GetDataTree("Edge Centre L02", out EdgeCentreL02);

            List<double> CtrlPSc = new List<double>();
            DA.GetDataList<double>("Curve Control Point Tangent Scalar", CtrlPSc);

            List<double> PentPSc = new List<double>();
            DA.GetDataList<double>("Planar Pentagon Point Tangent Scalar", PentPSc);

            List<bool> openclosed = new List<bool>();
            DA.GetDataList<bool>("Plate?", openclosed);

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

            DA.GetData<bool>("Allow PolySrf", ref iAllowPolySrf);
            // ==================================================================================================

            List<Tri_Loop_Component> All_Components = new List<Tri_Loop_Component>();

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

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

            for (int i = 0; i < PtL01.Branches.Count; i++)
            {
                // List 01
                List<Point3d> _ptL01 = new List<Point3d>();
                foreach (GH_Point pt in PtL01[i])
                    _ptL01.Add(pt.Value);

                // List 02
                List<Point3d> _ptL02 = new List<Point3d>();
                foreach (GH_Point pt in PtL02[i])
                    _ptL02.Add(pt.Value);

                // List TopoPtIdx
                List<int> _topoVidx = new List<int>();
                foreach (GH_Integer integer in TopoPtIdx[i])
                    _topoVidx.Add(integer.Value);

                // List TopoPtIdx
                List<int> _nFIdx = new List<int>();
                foreach (GH_Integer integer in NFIdx[i])
                    _nFIdx.Add(integer.Value);

                // List TopoEdges
                List<int> _topoEdges = new List<int>();
                foreach (GH_Integer integer in All_TopoEdges[i])
                    _topoEdges.Add(integer.Value);

                // EdgeCentreL01
                List<Point3d> _edgeCentreL01 = new List<Point3d>();
                foreach (GH_Point cntr in EdgeCentreL01[i])
                    _edgeCentreL01.Add(cntr.Value);

                // EdgeCentreL02
                List<Point3d> _edgeCentreL02 = new List<Point3d>();
                foreach (GH_Point cntr in EdgeCentreL02[i])
                    _edgeCentreL02.Add(cntr.Value);

                // Create Components
                //Tri_Loop_Component component = new Tri_Loop_Component(_ptL01, _ptL02, _topoVidx, _nFIdx, _topoEdges, _edgeCentreL01, _edgeCentreL02, i);

                // ======================================================================================================================
                // Gene Added with documentTolerance
                Tri_Loop_Component component = new Tri_Loop_Component(_ptL01, _ptL02, _topoVidx, _nFIdx, _topoEdges, _edgeCentreL01, _edgeCentreL02, i, documentTolerance);
                // ======================================================================================================================

                component.Run(PentPSc, CtrlPSc, openclosed);

                // ======================================================================================================================
                // Gene Added with documentTolerance
                if (!iAllowPolySrf)
                    component.RunSingle();
//.........这里部分代码省略.........
开发者ID:GeneKao,项目名称:Pavilion2015_ITECH,代码行数:101,代码来源:GHC_02_DoubleLayer.cs

示例10: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //declare input variables to load into

            AuthToken authToken = new AuthToken();
            string sheetName = "";
            string worksheet = "";
            bool rowsColumns = false;

            GH_Structure<GH_String> addresses = new GH_Structure<GH_String>();
            GH_Structure<GH_String> data = new GH_Structure<GH_String>();
            bool write = false;

            //declare output variables
            GH_Structure<GH_String> addressesOut = new GH_Structure<GH_String>();

            //get data from inputs
            if (!DA.GetData<AuthToken>("Token", ref authToken))
            {
                return; //exit if no token given
            }
            if (!authToken.IsValid)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The provided authentication token appears to be invalid. Try re-running the Google Authenticator component.");
                return; //exit if token invalid
            }

            if (!DA.GetData<string>("Name", ref sheetName))
            {
                return; //exit if no name given
            }
            DA.GetData<string>("Worksheet", ref worksheet);

            DA.GetData<bool>("Organize by Rows or Columns", ref rowsColumns);
            DA.GetDataTree<GH_String>("Address", out addresses);
            DA.GetDataTree<GH_String>("Data", out data);
            DA.GetData<bool>("Write", ref write);

            if (!write) return; //exit if write is not true

            //check each specified address for validity
            foreach (GH_String address in addresses.AllData(true))
            {
                if (!GDriveUtil.isValidAddress(address.ToString()))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error,"Not all addresses are specified in a valid format.");
                    return;
                }
            }

            //setup auth and factory
            //set up oAuth parameters
            OAuth2Parameters parameters = GDriveUtil.GetParameters(authToken);
            SpreadsheetsService service = GDriveUtil.GetSpreadsheetsService(parameters);

            //find spreadsheet by name
            SpreadsheetEntry spreadsheet = GDriveUtil.findSpreadsheetByName(sheetName, service);
            if (spreadsheet == null) //if the spreadsheet is not found
            {
                if (createNewSpreadsheets) //if the user has elected to create new spreadsheets
                {
                   List<string> worksheets = new List<string>();
                   if (!String.IsNullOrEmpty(worksheet))
                   {
                       worksheets.Add(worksheet); //create a 1-item list with the worksheet name
                   }
                    spreadsheet = CreateSpreadsheet.createNewSpreadsheet(this, authToken, sheetName, worksheets, false); //create the spreadsheet
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Specified spreadsheet not found.");
                    return;
                }
            }
            //find worksheet by name
            WorksheetEntry worksheetEntry = GDriveUtil.findWorksheetByName(worksheet, spreadsheet);
            if (worksheetEntry == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Specified worksheet not found.");
                return;
            }

            uint maxRow = 0;
            uint maxCol = 0;
            // set up dictionary<Cell address, cell input>
            // associate each input value with a corresponding address
            Dictionary<string, string> writeMap = constructWriteMap(addresses, data, rowsColumns, ref maxRow, ref maxCol, ref addressesOut);

                //expand worksheet if necessary
                if (worksheetEntry.Rows < maxRow)
                {

                        worksheetEntry.Rows = maxRow;
                        worksheetEntry.Etag = "*"; //required for compatibility with "new" google sheets (see:  http://stackoverflow.com/questions/22719170/updating-cell-in-google-spreadsheets-returns-error-missing-resource-version-id)
                        worksheetEntry.Update();

                }

                if (worksheetEntry.Cols < maxCol)
                {
//.........这里部分代码省略.........
开发者ID:ptierney,项目名称:leafcutter,代码行数:101,代码来源:WriteToSpreadsheet.cs

示例11: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Structure<IGH_Goo> Input = new GH_Structure<IGH_Goo>();
            DA.GetDataTree("Input", out Input);

            GH_Structure<HashType> Output = new GH_Structure<HashType>();
            bool bEnumerate = false;
            DA.GetData("Enumerate", ref bEnumerate);
            // iterate through all the sources by the Params.input value (and thus bypass the DA object, is this ugly?)

            foreach (IGH_Param Param in this.Params.Input[0].Sources)
            {

                foreach (GH_Path path in Input.Paths)
                {
                    String nickname = Param.NickName;
                    if (nickname.Length == 0)
                    {
                        this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Nickname of the connected component is empty");
                        nickname = "Anonymous";
                    }
                    List<object> DataList = new List<object>();
                    IEnumerable Data = Param.VolatileData.get_Branch(path);
                    if (Data != null)
                    {
                        foreach (object item in Data)
                        {
                            if (item != null)
                            {
                                DataList.Add(item);
                            }
                            else
                            {
                                DataList.Add("");
                            }
                        }
                    }
                    //
                    // Add the data to the list. If result is a tree or something similar: this means the results will be flattened.

                    if (Data == null || DataList.Count == 0)
                    {

                    }
                    else if (DataList.Count == 1)
                    {
                        // If the component has a single output: name it singular
                        Output.Append(new HashType(nickname, DataList[0]), path);
                    }
                    else if (DataList.Count > 1)
                    {
                        // .. otherwise: add a
                        int j = 0;
                        if (bEnumerate)
                        {
                            foreach (object item in DataList)
                            {
                                Output.Append(new HashType(String.Format("{0}_{1}", nickname, j), item), path);
                                j++;
                            }
                        }
                        else
                        {
                            Output.Append(new HashType(nickname, DataList), path);
                        }
                    }
                }
            }
            DA.SetDataTree(0, Output);
        }
开发者ID:arendvw,项目名称:ExportTools,代码行数:70,代码来源:AutoHashComponent.cs

示例12: SolveInstance

        /// <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));
//.........这里部分代码省略.........
开发者ID:GeneKao,项目名称:Pavilion2015_ITECH,代码行数:101,代码来源:GHC_Unroller.cs


注:本文中的IGH_DataAccess.GetDataTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。