コード例 #1
0
        /***************************************************/

        public static List <ICurve> Visualize(this BarUniformlyDistributedLoad barUDL, double scaleFactor = 1.0, bool displayForces = true, bool displayMoments = true, bool asResultants = true)
        {
            List <ICurve> arrows = new List <ICurve>();

            Vector forceVec  = barUDL.Force * scaleFactor;
            Vector momentVec = barUDL.Moment * scaleFactor;

            double sqTol = Tolerance.Distance * Tolerance.Distance;

            foreach (Bar bar in barUDL.Objects.Elements)
            {
                Cartesian system;

                Vector[] forceVectors = BarForceVectors(bar, forceVec, momentVec, barUDL.Axis, barUDL.Projected, out system);

                if (displayForces && forceVectors[0].SquareLength() > sqTol)
                {
                    arrows.AddRange(ConnectedArrows(new List <ICurve> {
                        bar.Centreline()
                    }, forceVectors[0], asResultants, system, 1, true));
                }
                if (displayMoments && forceVectors[1].SquareLength() > sqTol)
                {
                    arrows.AddRange(ConnectedArrows(new List <ICurve> {
                        bar.Centreline()
                    }, forceVectors[1], asResultants, system, 1, false));
                }
            }


            return(arrows);
        }
コード例 #2
0
        /***************************************************/

        private bool CreateLoad(BarUniformlyDistributedLoad bhLoad)
        {
            List <Bar> bars    = bhLoad.Objects.Elements.ToList();
            string     loadPat = GetAdapterId <string>(bhLoad.Loadcase);
            double     dist1   = 0;
            double     dist2   = 1;

            int[]    dirs       = null;
            double[] forceVals  = null;
            double[] momentVals = null;
            switch (bhLoad.Axis)
            {
            case LoadAxis.Global:
                if (bhLoad.Projected)
                {
                    dirs = new int[] { 7, 8, 9 };
                }
                else
                {
                    dirs = new int[] { 4, 5, 6 };
                }
                forceVals  = bhLoad.Force.ToDoubleArray();
                momentVals = bhLoad.Moment.ToDoubleArray();
                break;

            case LoadAxis.Local:
                dirs       = new int[] { 1, 2, 3 };
                forceVals  = bhLoad.Force.BarLocalAxisToCSI().ToDoubleArray();
                momentVals = bhLoad.Moment.BarLocalAxisToCSI().ToDoubleArray();
                break;
            }
            bool      relDist = true;
            string    cSys    = bhLoad.Axis.ToCSI();
            eItemType type    = eItemType.Objects;

            bool replace = SAPPushConfig.ReplaceLoads;

            foreach (Bar bhBar in bars)
            {
                string name       = GetAdapterId <string>(bhBar);
                bool   replaceNow = replace;
                for (int i = 0; i < dirs.Count(); i++)
                {
                    if (m_model.FrameObj.SetLoadDistributed(name, loadPat, 1, dirs[i], dist1, dist2, forceVals[i], forceVals[i], cSys, relDist, replaceNow, type) != 0)
                    {
                        CreateElementError("BarLoad", bhBar.Name + dirs[i]);
                    }
                    replaceNow = false;
                    if (m_model.FrameObj.SetLoadDistributed(name, loadPat, 2, dirs[i], dist1, dist2, momentVals[i], momentVals[i], cSys, relDist, replaceNow, type) != 0)
                    {
                        CreateElementError("BarLoad", bhBar.Name + dirs[i]);
                    }
                }
            }

            SetAdapterId(bhLoad, null);

            return(true);
        }
コード例 #3
0
ファイル: DistributedLoad.cs プロジェクト: BHoM/Lusas_Toolkit
        /***************************************************/

        private IFLoadingLocalDistributed CreateLocalDistributedLine(BarUniformlyDistributedLoad distributedLoad, object[] lusasLines)
        {
            IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(distributedLoad.Loadcase.AdapterId <int>(typeof(LusasId)));
            IFLoadingLocalDistributed lusasLocalDistributed = CreateLocalDistributed(distributedLoad.Name,
                                                                                     "Line", assignedLoadcase, distributedLoad.Force, lusasLines);

            int adapterIdName = lusasLocalDistributed.getID();

            distributedLoad.SetAdapterId(typeof(LusasId), adapterIdName);

            return(lusasLocalDistributed);
        }
コード例 #4
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/
        public static BarUniformlyDistributedLoad ToBarUniformlyDistributed(IFLoading lusasDistributed,
            IEnumerable<IFAssignment> lusasAssignments, Dictionary<string, Bar> bars)
        {
            IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset();
            Loadcase loadcase = ToLoadcase(assignedLoadcase);

            IEnumerable<Bar> assignedBars = GetLineAssignments(lusasAssignments, bars);

            Vector forceVector = new Vector
            {
                X = lusasDistributed.getValue("WX"),
                Y = lusasDistributed.getValue("WY"),
                Z = lusasDistributed.getValue("WZ")
            };

            BarUniformlyDistributedLoad barUniformlyDistributed = null;

            if (lusasDistributed.getAttributeType() == "Global Distributed Load")
            {
                Vector momentVector = new Vector
                {
                    X = lusasDistributed.getValue("MX"),
                    Y = lusasDistributed.getValue("MY"),
                    Z = lusasDistributed.getValue("MZ")
                };

                barUniformlyDistributed = Engine.Structure.Create.BarUniformlyDistributedLoad(
                    loadcase,
                    assignedBars,
                    forceVector,
                    momentVector,
                    LoadAxis.Global,
                    true,
                    GetName(lusasDistributed));
            }
            else if (lusasDistributed.getAttributeType() == "Distributed Load")
            {
                barUniformlyDistributed = Engine.Structure.Create.BarUniformlyDistributedLoad(
                    loadcase,
                    assignedBars,
                    forceVector,
                    null,
                    LoadAxis.Local,
                    true,
                    GetName(lusasDistributed));
            }

            int adapterNameId = lusasDistributed.getID();
            barUniformlyDistributed.SetAdapterId(typeof(LusasId), adapterNameId);

            return barUniformlyDistributed;
        }
コード例 #5
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);
        }
コード例 #6
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static BarUniformlyDistributedLoad FromRFEM(this rf.MemberLoad rfMemberLoad, Loadcase bhLoadcase, oM.Base.BHoMGroup <Bar> objectGroup)
        {
            LoadAxis loadAxis;
            bool     projected;
            string   direction;

            BarUniformlyDistributedLoad barUniformLoad = new BarUniformlyDistributedLoad();

            barUniformLoad.Loadcase = bhLoadcase;
            barUniformLoad.Objects  = objectGroup;
            barUniformLoad.SetAdapterId(typeof(RFEMId), rfMemberLoad.No);

            GetLoadingParameters(rfMemberLoad, out loadAxis, out projected, out direction);
            barUniformLoad.Axis      = loadAxis;
            barUniformLoad.Projected = projected;

            switch (direction)
            {
            case "FX":
                barUniformLoad.Force.X = rfMemberLoad.Magnitude1;
                break;

            case "FY":
                barUniformLoad.Force.Y = rfMemberLoad.Magnitude1;
                break;

            case "FZ":
                barUniformLoad.Force.Z = rfMemberLoad.Magnitude1;
                break;

            case "UX":
                barUniformLoad.Moment.X = rfMemberLoad.Magnitude1;
                break;

            case "UY":
                barUniformLoad.Moment.Y = rfMemberLoad.Magnitude1;
                break;

            case "UZ":
                barUniformLoad.Moment.Z = rfMemberLoad.Magnitude1;
                break;

            default:
                break;
            }

            return(barUniformLoad);
        }
コード例 #7
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <ILoad> ReadBarUniformlyDistributedLoads(List <string> ids = null)
        {
            List <ILoad> barUniformlyDistributedLoads = new List <ILoad>();

            object[] lusasGlobalDistributedLoads = d_LusasData.getAttributes("Global Distributed Load");
            object[] lusasLocalDistributedLoads  = d_LusasData.getAttributes("Distributed Load");

            object[] lusasDistributedLoads = lusasGlobalDistributedLoads.Concat(
                lusasLocalDistributedLoads).ToArray();

            if (!(lusasDistributedLoads.Count() == 0))
            {
                List <Bar> barsList           = ReadBars();
                Dictionary <string, Bar> bars = barsList.ToDictionary(
                    x => x.AdapterId <string>(typeof(LusasId)));

                List <IFLoadcase> allLoadcases = new List <IFLoadcase>();

                for (int i = 0; i < lusasDistributedLoads.Count(); i++)
                {
                    IFLoading lusasDistributedLoad = (IFLoading)lusasDistributedLoads[i];

                    IEnumerable <IGrouping <string, IFAssignment> > groupedByLoadcases = GetLoadAssignments(
                        lusasDistributedLoad);

                    if (lusasDistributedLoad.getValue("type") == "Length" || lusasDistributedLoad.getValue("type") == "line")
                    {
                        foreach (IEnumerable <IFAssignment> groupedAssignment in groupedByLoadcases)
                        {
                            BarUniformlyDistributedLoad barUniformlyDistributedLoad =
                                Adapters.Lusas.Convert.ToBarUniformlyDistributed(
                                    lusasDistributedLoad, groupedAssignment, bars);

                            List <string> analysisName = new List <string> {
                                lusasDistributedLoad.getAttributeType()
                            };
                            barUniformlyDistributedLoad.Tags = new HashSet <string>(analysisName);
                            barUniformlyDistributedLoads.Add(barUniformlyDistributedLoad);
                        }
                    }
                }
            }

            return(barUniformlyDistributedLoads);
        }
コード例 #8
0
ファイル: Load.cs プロジェクト: takeiteasy6649/ETABS_Toolkit
        public static void SetLoad(cSapModel model, BarUniformlyDistributedLoad barUniformLoad, bool replace)
        {
            foreach (Bar bar in barUniformLoad.Objects.Elements)
            {
                for (int direction = 1; direction <= 3; direction++)
                {
                    int    ret = 1;
                    double val = direction == 1 ? barUniformLoad.Force.X : direction == 2 ? barUniformLoad.Force.Y : barUniformLoad.Force.Z; //note: etabs acts different then stated in API documentstion

                    if (val != 0)
                    {
                        string csiCaseName = CaseNameToCSI(barUniformLoad.Loadcase);
                        ret = model.FrameObj.SetLoadDistributed(bar.CustomData[AdapterId].ToString(), csiCaseName, 1, direction + 3, 0, 1, val, val, "Global", true, replace);
                    }
                }
                //moments ? does not exist in old toolkit either!
            }
        }
コード例 #9
0
        private bool CreateObject(BarUniformlyDistributedLoad uniDistributedLoad)
        {
            BarVaryingDistributedLoad vardistributedLoad = new BarVaryingDistributedLoad()
            {
                StartPosition = 0,
                EndPosition   = 0,
                MomentAtStart = uniDistributedLoad.Moment,
                MomentAtEnd   = uniDistributedLoad.Moment,
                ForceAtStart  = uniDistributedLoad.Force,
                ForceAtEnd    = uniDistributedLoad.Force,
                Loadcase      = uniDistributedLoad.Loadcase,
                Projected     = uniDistributedLoad.Projected,
                Axis          = uniDistributedLoad.Axis,
                Objects       = uniDistributedLoad.Objects
            };

            return(CreateObject(vardistributedLoad));
        }
コード例 #10
0
ファイル: Load.cs プロジェクト: BHoM/ETABS_Toolkit
        /***************************************************/

        public void SetLoad(BarUniformlyDistributedLoad barUniformLoad, bool replace)
        {
            string axis;
            int    shift;

            GetDirectionData(barUniformLoad, out axis, out shift);
            foreach (Bar bar in barUniformLoad.Objects.Elements)
            {
                bool stepReplace = replace;

                string caseName = GetAdapterId <string>(barUniformLoad.Loadcase);
                string barName  = GetAdapterId <string>(bar);

                for (int direction = 1; direction <= 3; direction++)
                {
                    int    ret = 1;
                    double val = direction == 1 ? barUniformLoad.Force.X : barUniformLoad.Axis == LoadAxis.Global ?
                                 direction == 2 ? barUniformLoad.Force.Y : (shift == 6 ? -barUniformLoad.Force.Z : barUniformLoad.Force.Z) :
                                 direction == 2 ? barUniformLoad.Force.Z : -barUniformLoad.Force.Y; //note: etabs acts different then stated in API documentstion

                    if (val != 0)
                    {
                        ret         = m_model.FrameObj.SetLoadDistributed(barName, caseName, 1, direction + shift, 0, 1, val, val, axis, true, stepReplace);
                        stepReplace = false;
                    }
                }
                // Moment
                for (int direction = 1; direction <= 3; direction++)
                {
                    int    ret = 1;
                    double val = direction == 1 ? barUniformLoad.Moment.X : barUniformLoad.Axis == LoadAxis.Global ?
                                 direction == 2 ? barUniformLoad.Moment.Y : (shift == 6 ? -barUniformLoad.Moment.Z : barUniformLoad.Moment.Z) :
                                 direction == 2 ? barUniformLoad.Moment.Z : -barUniformLoad.Moment.Y; //note: etabs acts different then stated in API documentstion

                    if (val != 0)
                    {
                        ret         = m_model.FrameObj.SetLoadDistributed(barName, caseName, 2, direction + shift, 0, 1, val, val, axis, true, stepReplace);
                        stepReplace = false;
                    }
                }
            }
        }
コード例 #11
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <rf.MemberLoad> ToRFEM(this BarUniformlyDistributedLoad load, int loadId, int loadcaseId)
        {
            List <rf.MemberLoad> rfLoadList = new List <rf.MemberLoad>();

            rf.MemberLoad rfLoad = new rf.MemberLoad();
            rfLoad.Distribution      = rf.LoadDistributionType.UniformType;
            rfLoad.RelativeDistances = false;
            rfLoad.ReferenceTo       = rf.MemberLoadReferenceType.MembersType;

            List <string> objectIds      = load.Objects.Elements.Select(x => x.AdapterId <int>(typeof(RFEMId)).ToString()).ToList();
            string        objectIdString = string.Join(",", objectIds);

            rfLoad.ObjectList = objectIdString;

            rfLoad.IsValid = true;
            rfLoad.Comment = "";
            rfLoad.ID      = "";
            rfLoad.Tag     = "";

            if (load.Force.Length() == 0 & load.Moment.Length() == 0)
            {
                Engine.Base.Compute.RecordWarning("Zero forces set. No load pushed!");
                return(rfLoadList);
            }

            if (load.Force.Length() != 0)
            {
                rfLoad.Type = rf.LoadType.ForceType;
                if (load.Force.X != 0)
                {
                    rfLoad.No = loadId;
                    rf.MemberLoad xLoad = rfLoad;
                    xLoad.Direction  = load.Axis == LoadAxis.Global ? rf.LoadDirectionType.GlobalXType : rf.LoadDirectionType.LocalXType;
                    xLoad.Magnitude1 = load.Force.X;
                    rfLoadList.Add(xLoad);
                    loadId++;
                }

                if (load.Force.Y != 0)
                {
                    rfLoad.No = loadId;
                    rf.MemberLoad yLoad = rfLoad;
                    yLoad.Direction  = load.Axis == LoadAxis.Global ? rf.LoadDirectionType.GlobalYType : rf.LoadDirectionType.LocalYType;
                    yLoad.Magnitude1 = load.Force.Y;
                    rfLoadList.Add(yLoad);
                    loadId++;
                }

                if (load.Force.Z != 0)
                {
                    rfLoad.No = loadId;
                    rf.MemberLoad zLoad = rfLoad;
                    zLoad.Direction  = load.Axis == LoadAxis.Global ? rf.LoadDirectionType.GlobalZType : rf.LoadDirectionType.LocalZType;
                    zLoad.Magnitude1 = load.Force.Z;
                    rfLoadList.Add(zLoad);
                    loadId++;
                }
            }

            if (load.Moment.Length() != 0)
            {
                rfLoad.Type = rf.LoadType.MomentType;
                if (load.Moment.X != 0)
                {
                    rfLoad.No = loadId;
                    rf.MemberLoad uxLoad = rfLoad;
                    uxLoad.Direction  = load.Axis == LoadAxis.Global ? rf.LoadDirectionType.GlobalXType : rf.LoadDirectionType.LocalXType;
                    uxLoad.Magnitude1 = load.Moment.X;
                    rfLoadList.Add(uxLoad);
                    loadId++;
                }

                if (load.Moment.Y != 0)
                {
                    rfLoad.No = loadId;
                    rf.MemberLoad uyLoad = rfLoad;
                    uyLoad.Direction  = load.Axis == LoadAxis.Global ? rf.LoadDirectionType.GlobalXType : rf.LoadDirectionType.LocalXType;
                    uyLoad.Magnitude1 = load.Moment.X;
                    rfLoadList.Add(uyLoad);
                    loadId++;
                }

                if (load.Moment.X != 0)
                {
                    rfLoad.No = loadId;
                    rf.MemberLoad uzLoad = rfLoad;
                    uzLoad.Direction  = load.Axis == LoadAxis.Global ? rf.LoadDirectionType.GlobalXType : rf.LoadDirectionType.LocalXType;
                    uzLoad.Magnitude1 = load.Moment.X;
                    rfLoadList.Add(uzLoad);
                    loadId++;
                }
            }


            return(rfLoadList);
        }
コード例 #12
0
 public static LoadType LoadType(this BarUniformlyDistributedLoad load)
 {
     return(oM.Structure.Loads.LoadType.BarUniformLoad);
 }
コード例 #13
0
        /***************************************************/

        private List <ILoad> ReadBarLoad(List <Loadcase> loadcases)
        {
            List <ILoad> bhLoads = new List <ILoad>();

            Dictionary <string, Bar> bhomBars = ReadBar().ToDictionary(x => GetAdapterId <string>(x));

            string[] names     = null;
            string[] loadcase  = null;
            string[] CSys      = null;
            int[]    myType    = null;
            int[]    dir       = null;
            int      nameCount = 0;

            double[] rd1   = null;
            double[] rd2   = null;
            double[] dist1 = null;
            double[] dist2 = null;
            double[] val1  = null;
            double[] val2  = null;

            if (m_model.FrameObj.GetLoadDistributed("All", ref nameCount, ref names, ref loadcase, ref myType, ref CSys, ref dir, ref rd1, ref rd2, ref dist1, ref dist2, ref val1, ref val2, eItemType.Group) != 0)
            {
                return(bhLoads);
            }

            for (int i = 0; i < nameCount; i++)
            {
                Loadcase bhLoadcase = loadcases.FirstOrDefault(x => x.Name == loadcase[i]);

                if (bhLoadcase == null)
                {
                    continue;
                }
                if (dist1[i] != 0 || rd2[i] != 1 || Math.Abs(val1[i] - val2[i]) > Tolerance.Distance)   //Is Varying
                {
                    continue;
                }

                Vector force = Direction(dir[i], val1[i]);

                BHoMGroup <Bar> barObjects = new BHoMGroup <Bar>()
                {
                    Elements = { bhomBars[names[i]] }
                };

                BarUniformlyDistributedLoad bhLoad = new BarUniformlyDistributedLoad()
                {
                    Loadcase = bhLoadcase,
                    Objects  = barObjects
                };

                switch (myType[i])
                {
                case 1:
                    bhLoad.Force = force;
                    break;

                case 2:
                    bhLoad.Moment = force;
                    break;

                default:
                    BH.Engine.Base.Compute.RecordWarning("Could not create the load. It's not 'MyType'. MyType = " + myType[i].ToString());
                    break;
                }

                SetDirection(bhLoad, dir[i], CSys[i]);

                bhLoads.Add(bhLoad);
            }
            return(bhLoads);
        }
コード例 #14
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);
        }
コード例 #15
0
        private static List <ILoad> DistributedBarLoadsFromSt7(double loadX, double loadY, double loadZ, int distributionType, double barLength, double[] forces, double[] moments, Loadcase ldcase, Bar bar, bool projected, LoadAxis loadAxis)
        {
            List <ILoad> bhLoads = new List <ILoad>();
            double       a;
            double       b;

            if (IsZeroSqLength(forces))
            {
                a = moments[4];
                b = moments[5];
            }
            else
            {
                a = forces[4];
                b = forces[5];
            }
            ILoad bhLoad;
            ILoad bhLoad2;
            ILoad bhLoad3;

            switch (distributionType)
            {
            case St7.dlConstant:
                bhLoad = new BarUniformlyDistributedLoad()
                {
                    Moment    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    Force     = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    Loadcase  = ldcase,
                    Projected = projected,
                    Axis      = loadAxis,
                    Objects   = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad);
                break;

            case St7.dlLinear:
                if (moments[0] == moments[1] && forces[0] == forces[1] && a == 0 && b == 0)
                {
                    bhLoad = new BarUniformlyDistributedLoad()
                    {
                        Moment    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                        Force     = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                        Loadcase  = ldcase,
                        Projected = projected,
                        Axis      = loadAxis,
                        Objects   = new BHoMGroup <Bar>()
                        {
                            Elements = { bar }
                        }
                    };
                }
                else
                {
                    bhLoad = new BarVaryingDistributedLoad()
                    {
                        StartPosition = barLength * a,
                        EndPosition   = barLength * b,
                        MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                        MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[1],
                        ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                        ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[1],
                        Loadcase      = ldcase,
                        Projected     = projected,
                        Axis          = loadAxis,
                        Objects       = new BHoMGroup <Bar>()
                        {
                            Elements = { bar }
                        }
                    };
                }
                bhLoads.Add(bhLoad);
                break;

            case St7.dlTriangular:
                bhLoad = new BarVaryingDistributedLoad()
                {
                    StartPosition = 0,
                    EndPosition   = barLength * (1 - a),
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[2],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[2],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad);
                bhLoad2 = new BarVaryingDistributedLoad()
                {
                    StartPosition = barLength * a,
                    EndPosition   = 0,
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[3],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[3],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad2);
                break;

            case St7.dlThreePoint0:
                bhLoad = new BarVaryingDistributedLoad()
                {
                    StartPosition = 0,
                    EndPosition   = barLength * (1 - a),
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[2],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[2],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad);
                bhLoad2 = new BarVaryingDistributedLoad()
                {
                    StartPosition = barLength * a,
                    EndPosition   = barLength * b,
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[1],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[1],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad2);
                break;

            case St7.dlThreePoint1:
                bhLoad = new BarVaryingDistributedLoad()
                {
                    StartPosition = barLength * a,
                    EndPosition   = barLength * b,
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[1],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[1],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad);
                bhLoad2 = new BarVaryingDistributedLoad()
                {
                    StartPosition = barLength * (1 - b),
                    EndPosition   = 0,
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[1],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[3],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[1],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[3],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad2);
                break;

            case St7.dlTrapezoidal:
                bhLoad = new BarVaryingDistributedLoad()
                {
                    StartPosition = 0,
                    EndPosition   = barLength * (1 - a),
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[2],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[2],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad);
                bhLoad2 = new BarVaryingDistributedLoad()
                {
                    StartPosition = barLength * a,
                    EndPosition   = barLength * b,
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[0],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[1],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[0],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[1],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad2);
                bhLoad3 = new BarVaryingDistributedLoad()
                {
                    StartPosition = barLength * (1 - b),
                    EndPosition   = 0,
                    MomentAtStart = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[1],
                    MomentAtEnd   = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * moments[3],
                    ForceAtStart  = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[1],
                    ForceAtEnd    = BH.Engine.Geometry.Create.Vector(loadX, loadY, loadZ) * forces[3],
                    Loadcase      = ldcase,
                    Projected     = projected,
                    Axis          = loadAxis,
                    Objects       = new BHoMGroup <Bar>()
                    {
                        Elements = { bar }
                    }
                };
                bhLoads.Add(bhLoad3);
                break;
            }
            return(bhLoads);
        }