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


C# Interval.ParameterAt方法代码示例

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


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

示例1: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<DHr> hours = new List<DHr>();
            String key = "";
            if (DA.GetDataList(0, hours) && DA.GetData(1, ref key)) {
                if (hours.Count == 0) {
                    //TODO: we may want to return null values here instead.
                    return;
                }
                Interval ival_r = new Interval();
                float[] vals = new float[0];

                if (!(DA.GetData(2, ref ival_r))) DHr.get_domain(key, hours.ToArray(), ref vals, ref ival_r);
                else
                {
                    vals = new float[hours.Count];
                    for (int h = 0; h < hours.Count; h++) vals[h] = hours[h].val(key);
                    /* FROM HEAD:
                    ival_r = new Interval(hours[0].val(key), hours[0].val(key));
                    vals = new float[hours.Count];
                    for (int h = 0; h < hours.Count; h++) {
                        vals[h] = hours[h].val(key);
                        if (vals[h] < ival_r.T0) ival_r.T0 = vals[h];
                        if (vals[h] > ival_r.T1) ival_r.T1 = vals[h];
                    }
                     */
                }

                String period_string = "none";
                cycle_type = CType.Invalid;
                DA.GetData(3, ref period_string);

                if (period_string.Contains("year")) { this.cycle_type = CType.Year; }
                else if (period_string.Contains("day") || period_string.Contains("daily")) { this.cycle_type = CType.Day; }
                else if (period_string.Contains("none")) { this.cycle_type = CType.None; }
                if (cycle_type == CType.Invalid)
                {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "I don't understand the time period you're looking for.\nPlease choose 'year', 'day', or 'none'.");
                    return;
                }

                Plane plane = new Plane(new Point3d(0, 0, 0), new Vector3d(0, 0, 1));
                DA.GetData(4, ref plane);

                Interval ival_gr = new Interval();
                Interval ival_ga = new Interval(Math.PI * 2, 0); // reversed interval to ensure clockwise direction
                DA.GetData(5, ref ival_gr);

                switch (this.cycle_type) {

                    case CType.None: {
                            List<Point3d> points = new List<Point3d>();
                            Rhino.Geometry.Mesh mesh = new Mesh();
                            for (int h = 0; h < hours.Count; h++) {
                                double radius = ival_gr.ParameterAt(ival_r.NormalizedParameterAt(vals[h]));
                                double theta = ival_ga.ParameterAt(h / (double)hours.Count);
                                Point3d gpt = PointByCylCoords(radius, theta); // a point in graph coordinates
                                hours[h].pos = gpt; // the hour records the point in graph coordinates

                                Point3d wpt = plane.PointAt(gpt.X, gpt.Y);
                                points.Add(wpt);  // adds this point in world coordinates

                                mesh.Vertices.Add(wpt);
                                mesh.VertexColors.Add(hours[h].color);
                                Point3d wbpt = PointByCylCoords(ival_gr.ParameterAt(-0.01), theta);
                                mesh.Vertices.Add(plane.PointAt(wbpt.X, wbpt.Y));
                                mesh.VertexColors.Add(hours[h].color);
                                if (h > 0) mesh.Faces.AddFace(h * 2, h * 2 + 1, h * 2 - 1);
                                if (h > 0) mesh.Faces.AddFace(h * 2 - 1, h * 2 - 2, h * 2);
                            }
                            mesh.Normals.ComputeNormals();
                            mesh.Compact();

                            DA.SetDataList(0, hours);
                            DA.SetDataList(1, points);
                            //DA.SetDataTree(2, regions);
                            DA.SetData(2, mesh);
                        }
                        break;

                    case CType.Day: {
                            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<DHr> hourTreeOut = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                            List<Mesh> meshes = new List<Mesh>();
                            Rhino.Geometry.Mesh mesh = new Mesh();
                            int hour_of_day = 0;
                            int cycle_count = 0;
                            for (int i = 0; i < hours.Count; i++) {
                                if (hours[i].hr % 24 != hour_of_day) {
                                    cycle_count++;
                                    hour_of_day = hours[i].hr % 24;
                                    mesh.Normals.ComputeNormals();
                                    mesh.Compact();
                                    meshes.Add(mesh);
                                    mesh = new Mesh();
                                }
                                double radius = ival_gr.ParameterAt(ival_r.NormalizedParameterAt(vals[i]));
                                double theta = ival_ga.ParameterAt(hour_of_day / 24.0);
                                Point3d gpt = PointByCylCoords(radius, theta); // a point in graph coordinates
                                hours[i].pos = gpt; // the hour records the point in graph coordinates
//.........这里部分代码省略.........
开发者ID:ksteinfe,项目名称:dyear,代码行数:101,代码来源:Components+Spatializing.cs

示例2: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (!this.is_zombie) {
                // Ensure that no lists or trees are connected
                for (int i = 0; i < Params.Input.Count; i++) {
                    int cnt = Params.Input[i].VolatileData.DataCount;
                    if (cnt > 1) {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please don't connect lists or trees here! Variable at index " + i + " contains " + cnt.ToString() + " items");
                        return;
                    }
                }

                // Update local vars and ivals from input parameters
                this.veng.Init(this.VariableCount);

                for (int i = 0; i < this.VariableCount; i++) {
                    double t = 0.0;
                    Interval ival = new Interval();
                    if (!DA.GetData(i * 2, ref t)) { return; }
                    if (!DA.GetData(i * 2 + 1, ref ival)) { return; }
                    this.veng.SetVariableAt(i, ival.ParameterAt(t), ival, this.Params.Input[i*2].NickName);
                }
            }

            for (int i = 0; i < Params.Output.Count; i++) DA.SetData(i, this.veng.values[i]);

            //if (this.is_zombie) DA.SetData(1, test_var);
            //else DA.SetData(1, var_aa);
        }
开发者ID:ksteinfe,项目名称:lemmings,代码行数:29,代码来源:LemmingsComponent.cs


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