コード例 #1
0
 public static dynamic GetTSObject(GridSurface dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
コード例 #2
0
 public GsaGridPlaneSurface()
 {
     m_plane     = Plane.Unset;
     m_gridplane = new GridPlane();
     m_gp_guid   = Guid.NewGuid();
     m_gridsrf   = new GridSurface();
     m_gs_guid   = Guid.NewGuid();
     m_axis      = new Axis();
 }
コード例 #3
0
        public GsaGridPlaneSurface(Plane plane, bool tryUseExisting = false)
        {
            m_plane     = plane;
            m_gridplane = new GridPlane();
            if (tryUseExisting)
            {
                m_gp_guid = new Guid(); // will create 0000-00000-00000-00000
            }
            else
            {
                m_gp_guid = Guid.NewGuid(); // will create random guid
            }
            m_gridsrf = new GridSurface
            {
                Direction     = 0,
                Elements      = "all",
                ElementType   = GridSurface.Element_Type.ONE_DIMENSIONAL,
                ExpansionType = GridSurfaceExpansionType.UNDEF,
                SpanType      = GridSurface.Span_Type.ONE_WAY
            };
            if (tryUseExisting)
            {
                m_gs_guid = new Guid(); // will create 0000-00000-00000-00000
            }
            else
            {
                m_gs_guid = Guid.NewGuid(); // will create random guid
            }
            m_axis          = new Axis();
            m_axis.Origin.X = plane.OriginX;
            m_axis.Origin.Y = plane.OriginY;
            m_axis.Origin.Z = plane.OriginZ;

            m_axis.XVector.X = plane.XAxis.X;
            m_axis.XVector.Y = plane.XAxis.Y;
            m_axis.XVector.Z = plane.XAxis.Z;
            m_axis.XYPlane.X = plane.YAxis.X;
            m_axis.XYPlane.Y = plane.YAxis.Y;
            m_axis.XYPlane.Z = plane.YAxis.Z;
        }
コード例 #4
0
 public GsaGridSurface()
 {
     m_gridsurface = new GridSurface();
     m_gridplane   = new GridPlane();
     m_plane       = new Plane();
 }
コード例 #5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 0 Plane
            Plane pln = Plane.Unset;
            GsaGridPlaneSurface gps;
            bool idSet = false;

            GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

            if (DA.GetData(0, ref gh_typ))
            {
                if (gh_typ.Value is GsaGridPlaneSurfaceGoo)
                {
                    GsaGridPlaneSurface temppln = new GsaGridPlaneSurface();
                    gh_typ.CastTo(ref temppln);
                    gps = temppln.Duplicate();
                }
                else
                {
                    if (gh_typ.CastTo(ref pln))
                    {
                        gps = new GsaGridPlaneSurface(pln);
                    }
                    else
                    {
                        int id = 0;
                        if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both))
                        {
                            gps = new GsaGridPlaneSurface();
                            gps.GridSurface.GridPlane = id;
                            gps.GridPlane             = null;
                            idSet = true;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Cannot convert your input to GridPlaneSurface or Plane");
                            return;
                        }
                    }
                }
            }
            else
            {
                pln = Plane.WorldXY;
                gps = new GsaGridPlaneSurface(pln);
            }

            // record if changes has been made from default type
            bool        changeGS = false;
            GridSurface gs       = new GridSurface(); // new GridSurface to make changes to, set it back to GPS in the end

            if (idSet)
            {
                gs.GridPlane = gps.GridSurface.GridPlane;
            }

            // 1 ID
            GH_Integer ghint = new GH_Integer();

            if (DA.GetData(1, ref ghint))
            {
                int id = 0;
                GH_Convert.ToInt32(ghint, out id, GH_Conversion.Both);
                gps.GridSurfaceID = id;
            }

            // 2 Elements
            GH_String ghelem = new GH_String();

            if (DA.GetData(2, ref ghelem))
            {
                string elem = "";
                if (GH_Convert.ToString(ghelem, out elem, GH_Conversion.Both))
                {
                    gs.Elements = elem;
                    changeGS    = true;
                }
            }

            // 3 Name
            GH_String ghtxt = new GH_String();

            if (DA.GetData(3, ref ghtxt))
            {
                string name = "";
                if (GH_Convert.ToString(ghtxt, out name, GH_Conversion.Both))
                {
                    gs.Name  = name;
                    changeGS = true;
                }
            }

            // 4 Tolerance
            GH_Number ghtol = new GH_Number();

            if (DA.GetData(4, ref ghtol))
            {
                double tol = 10;
                if (GH_Convert.ToDouble(ghtol, out tol, GH_Conversion.Both))
                {
                    gs.Tolerance = tol;
                    changeGS     = true;
                }
            }

            switch (_mode)
            {
            case FoldMode.One_Dimensional_One_Way:
                gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL;
                gs.SpanType    = GridSurface.Span_Type.ONE_WAY;

                // 5 span direction
                GH_Number ghdir = new GH_Number();
                if (DA.GetData(5, ref ghdir))
                {
                    double dir = 0;
                    if (GH_Convert.ToDouble(ghdir, out dir, GH_Conversion.Both))
                    {
                        if (dir > 180 || dir < -180)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Angle value must be between -180 and 180 degrees");     // to be updated when GsaAPI support units
                        }
                        gs.Direction = dir;
                        if (dir != 0)
                        {
                            changeGS = true;
                        }
                    }
                }
                break;

            case FoldMode.One_Dimensional_Two_Way:
                changeGS       = true;
                gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL;

                // 5 expansion method
                int        exp   = 0;
                GH_Integer ghexp = new GH_Integer();
                if (DA.GetData(5, ref ghexp))
                {
                    GH_Convert.ToInt32_Primary(ghexp, ref exp);
                }
                gs.ExpansionType = GridSurfaceExpansionType.PLANE_CORNER;
                if (exp == 1)
                {
                    gs.ExpansionType = GridSurfaceExpansionType.PLANE_SMOOTH;
                }
                if (exp == 2)
                {
                    gs.ExpansionType = GridSurfaceExpansionType.PLANE_ASPECT;
                }
                if (exp == 3)
                {
                    gs.ExpansionType = GridSurfaceExpansionType.LEGACY;
                }

                // 6 simplify tributary area
                bool       simple = true;
                GH_Boolean ghsim  = new GH_Boolean();
                if (DA.GetData(6, ref ghsim))
                {
                    GH_Convert.ToBoolean(ghsim, out simple, GH_Conversion.Both);
                }
                if (simple)
                {
                    gs.SpanType = GridSurface.Span_Type.TWO_WAY_SIMPLIFIED_TRIBUTARY_AREAS;
                }
                else
                {
                    gs.SpanType = GridSurface.Span_Type.TWO_WAY;
                }
                break;

            case FoldMode.Two_Dimensional:
                changeGS       = true;
                gs.ElementType = GridSurface.Element_Type.TWO_DIMENSIONAL;
                break;
            }
            if (changeGS)
            {
                gps.GridSurface = gs;
            }

            DA.SetData(0, new GsaGridPlaneSurfaceGoo(gps));
        }