Ejemplo n.º 1
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)
        {
            IntPtr topoData = IntPtr.Zero;
            string name     = "";

            if (!DA.GetData(0, ref topoData))
            {
                return;
            }
            if (!DA.GetData(1, ref name))
            {
                return;
            }

            if (name == "tiltAngle")
            {
                double tilt_angle = 0;
                if (!DA.GetData(2, ref tilt_angle))
                {
                    return;
                }
                if (tilt_angle < 0 || tilt_angle > 90)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Tilt Angle");
                    return;
                }
                TopoCreator.setParaDouble(name, tilt_angle, topoData);
            }
            else if (name == "cutUpper" || name == "cutLower")
            {
                double cut_height = 0;
                if (!DA.GetData(2, ref cut_height))
                {
                    return;
                }
                if (cut_height < 0 || cut_height > 0.2)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name);
                    return;
                }
                TopoCreator.setParaDouble(name, cut_height, topoData);
            }
            else if (name == "patternID")
            {
                double type = 0;
                if (!DA.GetData(2, ref type))
                {
                    return;
                }
                if (type < 0 || type > 15)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name);
                    return;
                }
                TopoCreator.setParaInt(name, (int)type, topoData);
            }
            else if (name == "patternAngle")
            {
                double angle = 0;
                if (!DA.GetData(2, ref angle))
                {
                    return;
                }
                if (angle < -180 || angle > 180)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name);
                    return;
                }
                TopoCreator.setPatternAngle(angle, topoData);
            }
            else if (name == "patternXY")
            {
                Rhino.Geometry.Vector3d pos = new Rhino.Geometry.Vector3d();
                if (!DA.GetData(2, ref pos))
                {
                    return;
                }
                TopoCreator.setPatternXY(pos.X, pos.Y, topoData);
            }
            else if (name == "patternScale")
            {
                double scale = 0;
                if (!DA.GetData(2, ref scale))
                {
                    return;
                }
                if (scale < 0 || scale > 5)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name);
                    return;
                }
                TopoCreator.setPatternScale(scale, topoData);
            }

            DA.SetData(0, topoData);
        }