예제 #1
0
        public static Dictionary <string, object> ReadStr(string strPath, List <Results.ResultType> resultTypes, Results.UnitResults units)
        {
            Results.FDfea fdFeaModel = null;

            // It needs to check if model has been runned
            // Always Return the FeaNode Result
            resultTypes.Insert(0, Results.ResultType.FeaNode);
            resultTypes.Insert(1, Results.ResultType.FeaBar);
            resultTypes.Insert(2, Results.ResultType.FeaShell);


            // Create Bsc files from resultTypes
            var bscPathsFromResultTypes = Calculate.Bsc.BscPathFromResultTypes(resultTypes, strPath, units);

            // Create FdScript
            var fdScript = FemDesign.Calculate.FdScript.ReadStr(strPath, bscPathsFromResultTypes);

            // Run FdScript
            var  app       = new FemDesign.Calculate.Application();
            bool hasExited = app.RunFdScript(fdScript, false, true, false);

            // Read model and results
            var model = Model.DeserializeFromFilePath(fdScript.StruxmlPath);

            IEnumerable <Results.IResult> results = Enumerable.Empty <Results.IResult>();

            List <Results.FeaNode>  feaNodeRes  = new List <Results.FeaNode>();
            List <Results.FeaBar>   feaBarRes   = new List <Results.FeaBar>();
            List <Results.FeaShell> feaShellRes = new List <Results.FeaShell>();

            if (resultTypes != null && resultTypes.Any())
            {
                foreach (var cmd in fdScript.CmdListGen)
                {
                    string path = cmd.OutFile;
                    try
                    {
                        if (path.Contains("FeaNode"))
                        {
                            feaNodeRes = Results.ResultsReader.Parse(path).Cast <Results.FeaNode>().ToList();
                        }
                        else if (path.Contains("FeaBar"))
                        {
                            feaBarRes = Results.ResultsReader.Parse(path).Cast <Results.FeaBar>().ToList();
                        }
                        else if (path.Contains("FeaShell"))
                        {
                            feaShellRes = Results.ResultsReader.Parse(path).Cast <Results.FeaShell>().ToList();
                        }
                        else
                        {
                            var _results = Results.ResultsReader.Parse(path);
                            results = results.Concat(_results);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.InnerException.Message);
                    }
                }
            }

            fdFeaModel = new FemDesign.Results.FDfea(feaNodeRes, feaBarRes, feaShellRes);

            var resultGroups = results.GroupBy(t => t.GetType()).ToList();

            // Convert Data in DataTree structure
            var resultsTree = new List <List <Results.IResult> >();

            var i = 0;

            foreach (var resGroup in resultGroups)
            {
                resultsTree.Add(resGroup.ToList());
                i++;
            }

            // Output
            return(new Dictionary <string, object>
            {
                { "Model", model },
                { "FdFeaModel", fdFeaModel },
                { "Results", results }
            });
        }
예제 #2
0
        public static Model ReadStruxml(string filePathStruxml)
        {
            Model _model = Model.DeserializeFromFilePath(filePathStruxml);

            return(_model);
        }