コード例 #1
0
ファイル: NodeResultRequest.cs プロジェクト: BHoM/BHoM_Engine
 public static NodeResultRequest NodeResultRequest(NodeResultType resultType = NodeResultType.NodeReaction, LoadAxis axis = LoadAxis.Global, List <object> cases = null, List <string> modes = null, List <object> objectIds = null)
 {
     return(new NodeResultRequest
     {
         ResultType = resultType,
         Axis = axis,
         Cases = cases ?? new List <object>(),
         Modes = modes ?? new List <string>(),
         ObjectIds = objectIds ?? new List <object>()
     });
 }
コード例 #2
0
ファイル: IResultRequest.cs プロジェクト: BHoM/BHoM_Engine
        public static IResultRequest IResultRequest(Type type, IEnumerable <object> ids = null, IEnumerable <object> cases = null, int divisions = 5)
        {
            IResultRequest request = null;

            if (typeof(BarResult).IsAssignableFrom(type))
            {
                BarResultType resType = BarResultType.BarForce;

                if (type == typeof(BarForce))
                {
                    resType = BarResultType.BarForce;
                }
                else if (type == typeof(BarDeformation))
                {
                    resType = BarResultType.BarDeformation;
                }
                else if (type == typeof(BarStress))
                {
                    resType = BarResultType.BarStress;
                }
                else if (type == typeof(BarStrain))
                {
                    resType = BarResultType.BarStrain;
                }
                else if (type == typeof(BarDisplacement))
                {
                    resType = BarResultType.BarDisplacement;
                }
                else if (type == typeof(BarModeShape))
                {
                    resType = BarResultType.BarModeShape;
                }
                else
                {
                    Reflection.Compute.RecordWarning("Did not find exact type. Assuming " + resType);
                }

                request = new BarResultRequest {
                    Divisions = divisions, DivisionType = DivisionType.EvenlyDistributed, ResultType = resType
                };
            }
            else if (typeof(MeshResult).IsAssignableFrom(type) || typeof(MeshElementResult).IsAssignableFrom(type))
            {
                MeshResultType resType = MeshResultType.Forces;

                if (type == typeof(MeshForce))
                {
                    resType = MeshResultType.Forces;
                }
                else if (type == typeof(MeshStress))
                {
                    resType = MeshResultType.Stresses;
                }
                else if (type == typeof(MeshVonMises))
                {
                    resType = MeshResultType.VonMises;
                }
                else if (type == typeof(MeshDisplacement))
                {
                    resType = MeshResultType.Displacements;
                }
                else if (type == typeof(MeshModeShape))
                {
                    resType = MeshResultType.MeshModeShape;
                }
                else
                {
                    Reflection.Compute.RecordWarning("Did not find exact type. Assuming " + resType);
                }

                request = new MeshResultRequest {
                    ResultType = resType
                };
            }
            else if (typeof(StructuralGlobalResult).IsAssignableFrom(type))
            {
                GlobalResultType resType = GlobalResultType.Reactions;

                if (type == typeof(GlobalReactions))
                {
                    resType = GlobalResultType.Reactions;
                }
                else if (type == typeof(ModalDynamics))
                {
                    resType = GlobalResultType.ModalDynamics;
                }
                else
                {
                    Reflection.Compute.RecordWarning("Did not find exact type. Assuming " + resType);
                }

                request = new GlobalResultRequest {
                    ResultType = resType
                };
            }
            else if (typeof(NodeResult).IsAssignableFrom(type))
            {
                NodeResultType resType = NodeResultType.NodeReaction;

                if (type == typeof(NodeReaction))
                {
                    resType = NodeResultType.NodeReaction;
                }
                else if (type == typeof(NodeDisplacement))
                {
                    resType = NodeResultType.NodeDisplacement;
                }
                else if (type == typeof(NodeAcceleration))
                {
                    resType = NodeResultType.NodeAcceleration;
                }
                else if (type == typeof(NodeVelocity))
                {
                    resType = NodeResultType.NodeVelocity;
                }
                else if (type == typeof(NodeModalMass))
                {
                    resType = NodeResultType.NodeModalMass;
                }
                else if (type == typeof(NodeModeShape))
                {
                    resType = NodeResultType.NodeModeShape;
                }
                else
                {
                    Reflection.Compute.RecordWarning("Did not find exact type. Assuming " + resType);
                }

                request = new NodeResultRequest {
                    ResultType = resType
                };
            }
            else
            {
                return(null);
            }


            if (ids != null)
            {
                request.ObjectIds = ids.ToList();
            }

            if (cases != null)
            {
                request.Cases = cases.ToList();
            }

            return(request);
        }