コード例 #1
0
ファイル: Load.cs プロジェクト: BHoM/RFEM_Toolkit
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <ILoad> loads)
        {
            if (loads.Count() > 0)
            {
                int          loadId   = 0;
                List <ILoad> loadList = loads.ToList();

                //*****move this to adapter *****
                modelData.FinishModification();
                rf.ILoads rfloads = model.GetLoads();
                //*******************************

                var loadGroupByCase = loadList.GroupBy(load => load.Loadcase.Number);

                foreach (var caseGroup in loadGroupByCase)
                {
                    int          loadcaseId = caseGroup.Key;
                    rf.ILoadCase rfLoadcase = rfloads.GetLoadCase(loadcaseId, rf.ItemAt.AtNo);
                    rfLoadcase.PrepareModification();

                    foreach (ILoad load in caseGroup)
                    {
                        loadId = GetAdapterId <int>(load);

                        if (load.GetType().IsAssignableFrom(typeof(BarUniformlyDistributedLoad)))
                        {
                            BarUniformlyDistributedLoad barLoad    = load as BarUniformlyDistributedLoad;
                            rf.MemberLoad[]             rfBarLoads = barLoad.ToRFEM(loadId, loadcaseId).ToArray();
                            foreach (rf.MemberLoad item in rfBarLoads)
                            {
                                rfLoadcase.SetMemberLoad(item);
                            }
                        }

                        //if (load.GetType().IsAssignableFrom(typeof(BarPointLoad)))
                        //{
                        //    BarPointLoad barLoad = load as BarPointLoad;
                        //    rf.MemberLoad[] rfBarLoads = barLoad.ToRFEM(loadId, loadcaseId).ToArray();
                        //    foreach (rf.MemberLoad item in rfBarLoads)
                        //        rfLoadcase.SetMemberLoad(item);
                        //}
                    }
                    rfLoadcase.FinishModification(); // <---- move to adapter
                    modelData.PrepareModification(); //<--- hack to avoid app lock issue
                }
            }

            return(true);
        }
コード例 #2
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <Loadcase> loadcases)
        {
            if (loadcases.Count() > 0)
            {
                string loadcaseId = "";

                List <Loadcase> loadcaseList = loadcases.ToList();
                rf.LoadCase[]   rfLoadcases  = new rf.LoadCase[loadcaseList.Count()];

                //*****move this to adapter *****
                //modelData.FinishModification();

                rf.ILoads loads = model.GetLoads();
                loads.PrepareModification();
                //*******************************

                if (loadcaseList.Count == 1)
                {
                    loadcaseId     = GetAdapterId <string>(loadcaseList[0]);
                    rfLoadcases[0] = loadcaseList[0].ToRFEM(loadcaseId);
                    loads.SetLoadCase(rfLoadcases[0]);
                }
                else
                {
                    for (int i = 0; i < loadcaseList.Count(); i++)
                    {
                        loadcaseId = GetAdapterId <string>(loadcaseList[i]);

                        rfLoadcases[i] = loadcaseList[i].ToRFEM(loadcaseId);
                        loads.SetLoadCase(rfLoadcases[i]);
                    }
                    loads.SetLoadCases(rfLoadcases);
                }

                loads.FinishModification();      // <---- move to adapter
                modelData.PrepareModification(); //<--- hack to avoid app lock issue
            }

            return(true);
        }
コード例 #3
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private List <ILoad> ReadLoads(List <string> ids = null)
        {
            List <ILoad> loadList = new List <ILoad>();


            if (ids == null)
            {
                List <rf.LoadCase> rfLoadcases = model.GetLoads().GetLoadCases().ToList();
                rf.ILoads          l           = model.GetLoads();
                int lcCount = l.GetLoadCaseCount();

                Dictionary <int, Loadcase> bhLoadcaseDict = new Dictionary <int, Loadcase>();
                bhLoadcaseDict = ReadLoadcases().Distinct().ToDictionary(x => x.Number, x => x);

                Dictionary <string, Bar> bhBarDict = new Dictionary <string, Bar>();
                bool barsRead = false;

                for (int i = 0; i < lcCount; i++)
                {
                    rf.LoadCase rfLoadcase = l.GetLoadCase(i, rf.ItemAt.AtIndex).GetData();
                    Loadcase    bhLoadcase;

                    bhLoadcase = bhLoadcaseDict[rfLoadcase.Loading.No];


                    rf.MemberLoad[] rfMemberLoads = l.GetLoadCase(i, rf.ItemAt.AtIndex).GetMemberLoads();
                    if (rfMemberLoads.Length > 0)
                    {
                        if (!barsRead)
                        {
                            bhBarDict = ReadBars().ToDictionary(x => GetAdapterId(x).ToString(), x => x);
                            barsRead  = true;
                        }


                        foreach (rf.MemberLoad rfLoad in rfMemberLoads)
                        {
                            List <string>           barIds   = BH.Engine.Adapters.RFEM.Compute.GetIdListFromString(rfLoad.ObjectList);
                            oM.Base.BHoMGroup <Bar> barGroup = new oM.Base.BHoMGroup <Bar>();
                            barGroup.Elements.AddRange(barIds.Where(k => bhBarDict.ContainsKey(k)).Select(k => bhBarDict[k]));


                            if (rfLoad.Distribution == rf.LoadDistributionType.UniformType)
                            {
                                BarUniformlyDistributedLoad barUniformLoad = rfLoad.FromRFEM(bhLoadcase, barGroup);
                                loadList.Add(barUniformLoad);
                            }
                            else if (rfLoad.Distribution == rf.LoadDistributionType.ConcentratedType)
                            {
                                BarPointLoad barPointLoad = new BarPointLoad();
                                //...
                            }
                            else
                            {
                                Engine.Base.Compute.RecordWarning("Load distribution of type: " + rfLoad.Distribution.ToString() + " is not supported!");
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (string id in ids)
                {
                    //loadList.Add();
                }
            }

            return(loadList);
        }