diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs index 214edfa1..aeba99d2 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs @@ -116,12 +116,12 @@ public void InitializeOpenings() public void PushPullPanel() { - adapter.Push(new List() { panel1}); + //adapter.Push(new List() { panel1}); //// Pull it - //FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) }; - //var panelPulled = adapter.Pull(panelFilter).ToList(); - //Panel pp = (Panel)panelPulled[0]; + FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) }; + var panelPulled = adapter.Pull(panelFilter).ToList(); + Panel pp = (Panel)panelPulled[0]; //// Check //Assert.IsNotNull(pp); diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs index 5d1cb238..62b61e10 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs @@ -142,7 +142,7 @@ public void InitializeOpenings() [SetUp] public void SetUp() { - adapter.Push(new List() { panel1, panel2, panel3 }); + //adapter.Push(new List() { panel1, panel2, panel3 }); } @@ -268,7 +268,19 @@ public void PushOfReversedAreaUniformlyDistributedLoad() Assert.True(this.reverseAreaLoadList[i].Axis.Equals(areaLoadList[i].Axis)); } + [Test] + public void PullUniformlyDistributedLoad() + { + + //Act + + // Push + // Pull + FilterRequest loadFilter = new FilterRequest() { Type = typeof(AreaUniformlyDistributedLoad) }; + List areaLoadList = adapter.Pull(loadFilter).ToList().Select(p => (AreaUniformlyDistributedLoad)p).ToList(); + var a = areaLoadList.First(); + } } diff --git a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs index 1a9ce6de..9659a7c9 100644 --- a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs @@ -61,6 +61,10 @@ private bool CreateCollection(IEnumerable bhLoads) if (bhLoad is AreaUniformlyDistributedLoad) { + if (bhLoad.CustomData.Values.Any(l=>l is Polygon)) { + CreateLoad_Polygon(bhLoad as AreaUniformlyDistributedLoad); + continue; + } CreateLoad(bhLoad as AreaUniformlyDistributedLoad); continue; } @@ -233,6 +237,24 @@ private void CreateLoad(AreaUniformlyDistributedLoad bhLoad) } + private void CreateLoad_Polygon(AreaUniformlyDistributedLoad bhLoad) + { + try + { + UpdateLoadIdDictionary(bhLoad); + //Call Panel Load Methond to update the Panel ID Dictionary + this.GetCachedOrReadAsDictionary(); + int id = m_LoadcaseLoadIdDict[bhLoad.Loadcase][bhLoad.GetType().Name]; + free_polygon_load rfemAreaLoad = (bhLoad as AreaUniformlyDistributedLoad).ToRFEM6_Polygon(id); + var currrSurfaceIds = (bhLoad as AreaUniformlyDistributedLoad).Objects.Elements.ToList().Select(e => m_PanelIDdict[e as Panel]).ToArray(); + rfemAreaLoad.surfaces = currrSurfaceIds; + m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad); + + } catch (Exception ex) { + BH.Engine.Base.Compute.RecordError($"The creation of {bhLoad} failed.\nA potential cause is that the applied polygon is non-planar or not parallel to the XY, YZ, or ZX plane.\nException: {ex.Message}\nStackTrace: {ex.StackTrace}"); + } + } + private void CreateLoad(BarUniformlyDistributedLoad bhLoad) { diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index ea43e64b..4175c759 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -117,6 +117,7 @@ private List ReadPointLoad(List ids = null) private List ReadAreaLoad(List ids = null) { + List loads = new List(); //Find all possible Load cases @@ -136,7 +137,7 @@ private List ReadAreaLoad(List ids = null) if (!(surfaceLoad.load_distribution is rfModel.surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { - Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); continue; } @@ -144,10 +145,33 @@ private List ReadAreaLoad(List ids = null) } - return loads; + + rfModel.object_with_children[] numbers_ = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_FREE_POLYGON_LOAD); + + //IEnumerable foundSurfaceLoad = numbers.ToList().Select(n => m_Model.get_surface_load(n.children[0], n.no)); + IEnumerable foundPolygonLoad_ = numbers_.SelectMany(n => n.children.Select(child => m_Model.get_free_polygon_load(child, n.no))); + + foundPolygonLoad_ = foundPolygonLoad_.OrderBy(n => n.load_case).ThenBy(t => t.no); + foreach (rfModel.free_polygon_load polygonLoad in foundPolygonLoad_) + { + List panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); + if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) + { + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); + continue; + } + + loads.Add(polygonLoad.FromRFEM(loadCaseMap[polygonLoad.load_case], panels)); + + } + + + return loads; } - private List ReadFreeLineLoad(List ids = null) + + + private List ReadFreeLineLoad(List ids = null) { List loads = new List(); diff --git a/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs b/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs index 188a1a96..b35d04c8 100644 --- a/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs +++ b/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs @@ -43,7 +43,7 @@ private List ReadLines(List ids = null) List lineList = new List(); - var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE); + var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE).Where(l => l.no > 0); var allRfLInes = lineNumbers.ToList().Select(n => m_Model.get_line(n.no)); //var lineSupportNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE); diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs index a5033c4b..72c76db5 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs @@ -45,10 +45,6 @@ public static partial class Convert public static Panel FromRFEM(this rfModel.surface rfSurface, Dictionary edgeDict, Dictionary surfaceProperty, HashSet openingIDs, Dictionary surfaceOpening) { - //HashSet openingIDs = new HashSet(); - - //openingIDDict.TryGetValue(rfPanelNo,out openingIDs); - List rfEdgeNumbers = rfSurface.boundary_lines.ToList(); List bhEdges = rfEdgeNumbers.Select(n => edgeDict[n]).ToList(); diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs index 82220a9e..7486cffe 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs @@ -185,6 +185,121 @@ public static PointLoad FromRFEM(this rfModel.nodal_load nodeLoad, List bh return bhLoad; } + public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_load polygonLoad, Loadcase loadcase, List panels) + { + + Vector forceDirection; + bool isProjected = false; + LoadAxis axis = LoadAxis.Global; + List firstCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.first_coordinate).ToList(); + List secondCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.second_coordinate).ToList(); + List thirdCoordinate = Enumerable.Repeat(0.0, firstCoordinate.Count).ToList(); + List loadPolygon; + + switch (polygonLoad.load_projection) + { + case free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = x, + Y = secondCoordinate[i], + Z = thirdCoordinate[i] + }).ToList(); + + + break; + + case free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = thirdCoordinate[i], + Y = x, + Z = secondCoordinate[i] + }).ToList(); + + break; + + default: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = secondCoordinate[i], + Y = thirdCoordinate[i], + Z = x + }).ToList(); + + break; + + + } + + var polygon = BH.Engine.Geometry.Create.Polygon(loadPolygon); + + switch (polygonLoad.load_direction) + { + //case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_X: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Y: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Z: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_U_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + isProjected = true; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_V_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + isProjected = true; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_W_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + isProjected = true; + break; + + default: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + break; + } + + + AreaUniformlyDistributedLoad bhAreaload = BH.Engine.Structure.Create.AreaUniformlyDistributedLoad(loadcase, forceDirection, panels, axis, isProjected, polygonLoad.comment); + bhAreaload = bhAreaload.SetHashFragment("Polygon"); + bhAreaload.SetPropertyValue("Polygon", polygon); + + return bhAreaload; + } + public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.surface_load surfaceload, Loadcase loadcase, List panels) { diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 6c4b2380..e53c1f81 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -36,6 +36,7 @@ using Dlubal.WS.Rfem6.Model; using BH.Engine.Geometry; using BH.oM.Geometry; +using BH.Engine.Spatial; namespace BH.Adapter.RFEM6 { @@ -47,7 +48,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar //var i = bhBarLoad.Objects.Elements.ToList().Select(x => x.GetRFEM6ID()).ToList(); - double loadMagintude; + double loadMagnitude; member_load_load_direction loadDirecteion; Vector orientationVector = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force : bhBarLoad.Moment; @@ -72,7 +73,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.X : bhBarLoad.Moment.X; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.X : bhBarLoad.Moment.X; } @@ -90,7 +91,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Y : bhBarLoad.Moment.Y; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Y : bhBarLoad.Moment.Y; } else @@ -107,7 +108,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Z : bhBarLoad.Moment.Z; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Z : bhBarLoad.Moment.Z; } member_load rfLoadCase = new rfModel.member_load() @@ -121,7 +122,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar load_typeSpecified = true, load_direction = loadDirecteion, load_directionSpecified = true, - magnitude = loadMagintude, + magnitude = loadMagnitude, magnitudeSpecified = true, load_is_over_total_length = true, load_is_over_total_lengthSpecified = true, @@ -174,7 +175,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { - double loadMagintude; + double loadMagnitude; surface_load_load_direction loadDirection; Vector orientationVector = bhAreaLoad.Pressure; @@ -199,7 +200,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE; } - loadMagintude = orientationVector.X; + loadMagnitude = orientationVector.X; } else if (orientationVector.Y != 0) @@ -216,7 +217,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE; } - loadMagintude = orientationVector.Y; + loadMagnitude = orientationVector.Y; } else @@ -233,7 +234,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE; } - loadMagintude = orientationVector.Z; + loadMagnitude = orientationVector.Z; } @@ -246,9 +247,9 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA load_caseSpecified = true, load_distribution = surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, load_distributionSpecified = true, - magnitude_force_u = loadMagintude, + magnitude_force_u = loadMagnitude, magnitude_force_uSpecified = true, - uniform_magnitude = loadMagintude, + uniform_magnitude = loadMagnitude, uniform_magnitudeSpecified = true, is_generated = false, is_generatedSpecified = true, @@ -263,6 +264,149 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA } + public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistributedLoad bhAreaLoad, int loadCaseSpecificLoadId) + { + free_polygon_load_load_projection loadProjection; + + if (bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.XAxis)==0 + && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.YAxis) == 0 + && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.ZAxis) == 0) + { + BH.Engine.Base.Compute.RecordWarning($"Please make sure that the direction of {bhAreaLoad} is axis-aligned."); + } + + Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); + List polygonValues; + var fitPlane=polygon.IFitPlane(); + if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) + { + polygonValues= polygon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV; + } + else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) + { + polygonValues= polygon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; + } + else { + polygonValues= polygon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW; + + } + + free_polygon_load_load_location_row[] locationPolygons = polygonValues.Select((v, i) => new free_polygon_load_load_location_row() + { + no = (i+1), + description=(i+1)+"", + row = new free_polygon_load_load_location() + { + magnitude=0, + magnitudeSpecified=false, + first_coordinate = v[0], + first_coordinateSpecified = true, + second_coordinate = v[1], + second_coordinateSpecified = true + + } + } + + ).ToArray(); + + double loadMagnitude; + free_polygon_load_load_direction loadDirection; + Vector orientationVector = bhAreaLoad.Pressure; + + if (bhAreaLoad.Projected && bhAreaLoad.Axis == LoadAxis.Local) + { + BH.Engine.Base.Compute.RecordWarning("Projected Area Load is not supported for Local Axis. The Load will be projected to the Global Axis"); + } + + // Checkinf if Load is Orientied in X directin + if (orientationVector.X != 0) + { + // If the load Axis in slocal the load direction is local x + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE; + } + loadMagnitude = orientationVector.X; + + } + else if (orientationVector.Y != 0) + { + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE; + } + loadMagnitude = orientationVector.Y; + + } + else + { + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE; + } + loadMagnitude = orientationVector.Z; + } + + + + free_polygon_load rfSurfaceLoad = new rfModel.free_polygon_load() + { + no = loadCaseSpecificLoadId, + comment = bhAreaLoad.Name, + surfaces = bhAreaLoad.Objects.Elements.ToList().Select(x => (x as Panel).GetRFEM6ID()).ToArray(), + load_case = bhAreaLoad.Loadcase.Number, + load_caseSpecified = true, + load_distribution = free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, + load_distributionSpecified = true, + magnitude_linear_1 = loadMagnitude, + magnitude_linear_1Specified = true, + magnitude_uniform = loadMagnitude, + magnitude_uniformSpecified = true, + is_generated = false, + is_generatedSpecified = true, + load_direction = loadDirection, + load_directionSpecified = true, + load_location = locationPolygons, + load_projection = loadProjection, + load_projectionSpecified = true + }; + + + return rfSurfaceLoad; + + } + public static rfModel.free_line_load ToRFEM6(this GeometricalLineLoad bhLineLoad, int loadCaseSpecificID, int[] surfaceIds) {