From 95100cbd477b3937e31f3bff7d5300f72aba2405 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 7 Jul 2022 20:21:41 -0400 Subject: [PATCH 01/17] Adding Floor(Panel) and Wall(Panel) --- .../ConstantFramingProperty.cs | 0 .../Create/Physical/Construction.cs | 200 ++++++++++++++++++ .../{Framing => Physical}/FramingElement.cs | 0 .../Create/Physical/SurfaceElement.cs | 148 +++++++++++++ 4 files changed, 348 insertions(+) rename Structure_Engine/Create/{Framing => Physical}/ConstantFramingProperty.cs (100%) create mode 100644 Structure_Engine/Create/Physical/Construction.cs rename Structure_Engine/Create/{Framing => Physical}/FramingElement.cs (100%) create mode 100644 Structure_Engine/Create/Physical/SurfaceElement.cs diff --git a/Structure_Engine/Create/Framing/ConstantFramingProperty.cs b/Structure_Engine/Create/Physical/ConstantFramingProperty.cs similarity index 100% rename from Structure_Engine/Create/Framing/ConstantFramingProperty.cs rename to Structure_Engine/Create/Physical/ConstantFramingProperty.cs diff --git a/Structure_Engine/Create/Physical/Construction.cs b/Structure_Engine/Create/Physical/Construction.cs new file mode 100644 index 000000000..e822a5e2f --- /dev/null +++ b/Structure_Engine/Create/Physical/Construction.cs @@ -0,0 +1,200 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.ComponentModel; +using BH.oM.Base.Attributes; +using BH.oM.Physical.Constructions; +using BH.oM.Structure.SurfaceProperties; +using BH.oM.Quantities.Attributes; + +namespace BH.Engine.Structure +{ + public static partial class Create + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + [Description("Creates a ConstantFramingProperty from a ISectionProperty and orientation angle. Extracts the SectionProfile (if existing) and Structural MaterialFragment and creates a physical material with the same name.")] + [Input("sectionProperty", "Structural section property to extract profile and material from. For explicit sections lacking a profile only the material will get extracted.")] + [Input("orientationAngle", "Defines the sections rotation around its own axis.", typeof(Angle))] + [Input("name", "Name of the property. If null/empty the name of the section property will be used.")] + [Output("FramingProperty", "The constructed physical Constant Framing Property to be used with IFramingElements such as Beams/Columns/Bracing.")] + public static Construction IConstruction(this ISurfaceProperty property) + { + if (property.IsNull()) + return null; + + return Construction(property as dynamic); + } + + /***************************************************/ + public static Construction Construction(this ConstantThickness property) + { + if (property.IsNull()) + return null; + + //Set Material + oM.Physical.Materials.Material material = property.GetMaterial(); + + oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = property.Thickness, Name = property.Name }; + + return Physical.Create.Construction(property.Name, new List() { physicalLayer }); + } + + /***************************************************/ + public static Construction Construction(this CorrugatedDeck property) + { + if (property.IsNull()) + return null; + + //Set Material + oM.Physical.Materials.Material material = property.GetMaterial(); + + double thickness = property.Thickness * property.VolumeFactor; + + oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = thickness, Name = property.Name }; + + return Physical.Create.Construction(property.Name, new List() { physicalLayer }); + } + + /***************************************************/ + public static Construction Construction(this Layered property) + { + if (property.IsNull()) + return null; + + //Set Material + oM.Physical.Materials.Material material = property.GetMaterial(); + + List layers = property.Layers.Select(x => Physical.Create.Layer(x.Name, x.GetMaterial(), x.Thickness)).ToList(); + + return Physical.Create.Construction(property.Name, layers); + } + + /***************************************************/ + public static Construction Construction(this Ribbed property) + { + if (property.IsNull()) + return null; + + //Set Material + oM.Physical.Materials.Material material = property.GetMaterial(); + + double topThickness = property.Thickness; + double bottomThickness = property.TotalDepth - topThickness; + + oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = property.Name }; + oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = property.Name }; + + return Physical.Create.Construction(property.Name, new List() { topLayer, bottomLayer }); + } + + /***************************************************/ + public static Construction Construction(this SlabOnDeck property) + { + if (property.IsNull()) + return null; + + //Set Material + oM.Physical.Materials.Material slabMaterial = property.GetMaterial(); + oM.Physical.Materials.Material deckMaterial = Physical.Create.Material(property.DeckMaterial.Name, new List() { property.DeckMaterial }); + + double topThickness = property.SlabThickness; + double bottomThickness = property.DeckHeight; + double deckThickness = property.DeckThickness * property.DeckVolumeFactor; + + oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = topThickness, Name = property.Name }; + oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = bottomThickness, Name = property.Name }; + oM.Physical.Constructions.Layer deckLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = deckThickness, Name = property.Name }; + + return Physical.Create.Construction(property.Name, new List() { topLayer, bottomLayer, deckLayer}); + } + + /***************************************************/ + public static Construction Construction(this Waffle property) + { + if (property.IsNull()) + return null; + + //Set Material + oM.Physical.Materials.Material material = property.GetMaterial(); + + double topThickness = property.Thickness; + double bottomThickness = Math.Max(property.TotalDepthX, property.TotalDepthY); + + oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = property.Name }; + oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = property.Name }; + + return Physical.Create.Construction(property.Name, new List() { topLayer, bottomLayer }); + } + + /***************************************************/ + public static Construction Construction(this ISurfaceProperty property) + { + Base.Compute.RecordError($"Construction() not implemented for type {property.GetType()}."); + return null; + } + + private static oM.Physical.Materials.Material GetMaterial(this ISurfaceProperty property) + { + //Set Material + oM.Physical.Materials.Material material = null; + + if (property.Material != null) + { + string matName = property.Material.DescriptionOrName(); + material = Physical.Create.Material(matName, new List { property.Material }); + } + else + { + Base.Compute.RecordWarning("Material from the SurfaceProperty is null."); + } + + return material; + } + + private static oM.Physical.Materials.Material GetMaterial(this oM.Structure.SurfaceProperties.Layer layer) + { + //Set Material + oM.Physical.Materials.Material material = null; + + if (layer.Material != null) + { + string matName = layer.Material.DescriptionOrName(); + material = Physical.Create.Material(matName, new List { layer.Material }); + } + else + { + Base.Compute.RecordWarning("Material from the Layer is null."); + } + + return material; + } + } +} + + + diff --git a/Structure_Engine/Create/Framing/FramingElement.cs b/Structure_Engine/Create/Physical/FramingElement.cs similarity index 100% rename from Structure_Engine/Create/Framing/FramingElement.cs rename to Structure_Engine/Create/Physical/FramingElement.cs diff --git a/Structure_Engine/Create/Physical/SurfaceElement.cs b/Structure_Engine/Create/Physical/SurfaceElement.cs new file mode 100644 index 000000000..c1baf610d --- /dev/null +++ b/Structure_Engine/Create/Physical/SurfaceElement.cs @@ -0,0 +1,148 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System.Collections.Generic; +using System.Linq; +using BH.oM.Structure.Elements; +using BH.oM.Geometry; +using BH.oM.Base.Attributes; +using System.ComponentModel; +using BHPE = BH.oM.Physical.Elements; +using BHPC = BH.oM.Physical.Constructions; +using BH.oM.Physical.Reinforcement; +using BH.oM.Structure.SurfaceProperties; +using BH.oM.Structure.Reinforcement; +using BH.oM.Structure.Fragments; +using BH.Engine.Base; +using BH.oM.Quantities.Attributes; + +namespace BH.Engine.Structure +{ + public static partial class Create + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + [Description("Creates a physical IFramingElement from a Bar. The framing element will be assigned a ConstantFramingProperty based on the SectionProperty of the Bar and have a type based on the structural usage.")] + [Input("bar", "The Bar to use as the base for the framing element.")] + [Input("structuralUsage", "Used to determine which type of framing element that should be constructed.")] + [Output("framing", "The created physical FramingElement based on the Bar element provided.")] + public static BHPE.Wall Wall(Panel panel) + { + if (panel.IsNull()) + return null; + + //Get Construction + ISurfaceProperty prop = panel.Property; + BHPC.Construction construction = null; + + if (prop == null) + Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); + else + construction = panel.Property.IConstruction(); + + //Get Location + PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); + List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); + + BHPE.Wall surfaceElement = Physical.Create.Wall(construction, externalEdges, internalEdges); + + string name = panel.Name ?? ""; + surfaceElement.Name = name; + + if (panel.FindFragment() != null || panel.Property.FindFragment() != null) + { + Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); + } + + return surfaceElement; + } + + /***************************************************/ + public static BHPE.Floor Floor(Panel panel) + { + if (panel.IsNull()) + return null; + + //Get Construction + ISurfaceProperty prop = panel.Property; + BHPC.Construction construction = null; + + if (prop == null) + Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); + else + construction = panel.Property.IConstruction(); + + //Get Location + PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); + List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); + + BHPE.Floor surfaceElement = Physical.Create.Floor(construction, externalEdges, internalEdges); + + string name = panel.Name ?? ""; + surfaceElement.Name = name; + + if (panel.FindFragment() != null || panel.Property.FindFragment() != null) + { + Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); + } + + return surfaceElement; + } + + + public static BHPE.ISurface SurfaceElement(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) + { + if (structuralUsage == StructuralUsage2D.Undefined) + { + object result = panel.Property.PropertyValue("PanelType"); + if (result != null) + { + structuralUsage = (StructuralUsage2D)result; + } + } + + switch (structuralUsage) + { + case StructuralUsage2D.Wall: + return Wall(panel); + case StructuralUsage2D.DropPanel: + case StructuralUsage2D.PileCap: + case StructuralUsage2D.Slab: + case StructuralUsage2D.Undefined: + default: + return Floor(panel); + } + } + + /***************************************************/ + + public static BHPE.Void Void(Opening opening) + { + return new BHPE.Void() { Location = Geometry.Create.PlanarSurface(opening.Edges.Select(edge => edge.Curve).FirstOrDefault()) }; + } + } +} + + + From 588971af456c7d82cff5031351bbc18c1bc947f8 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 7 Jul 2022 20:22:16 -0400 Subject: [PATCH 02/17] Fixing Physical.Create.Floor and Physical.Create.Wall --- Physical_Engine/Create/Floor.cs | 4 ++-- Physical_Engine/Create/Wall.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Physical_Engine/Create/Floor.cs b/Physical_Engine/Create/Floor.cs index f3d336745..30e986f45 100644 --- a/Physical_Engine/Create/Floor.cs +++ b/Physical_Engine/Create/Floor.cs @@ -78,7 +78,7 @@ public static Floor Floor(Construction construction, ICurve edges, IEnumerable aInternalCurveList = null; + if (internalEdges != null && internalEdges.Count() > 0) + aInternalCurveList = internalEdges.ToList().ConvertAll(x => x as ICurve); + + PlanarSurface aPlanarSurface = Geometry.Create.PlanarSurface(edges, aInternalCurveList); if (aPlanarSurface == null) { - Base.Compute.RecordError("Physical Wall could not be created because invalid geometry of edges."); + Base.Compute.RecordError("Physical Wall could not be created because of invalid geometry of edges."); return null; } From 670a95dc5be61974b3e6f5bfc72ae969cbed4d39 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 7 Jul 2022 20:34:13 -0400 Subject: [PATCH 03/17] Cleanup --- .../Create/Physical/SurfaceElement.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Structure_Engine/Create/Physical/SurfaceElement.cs b/Structure_Engine/Create/Physical/SurfaceElement.cs index c1baf610d..c91ee76fb 100644 --- a/Structure_Engine/Create/Physical/SurfaceElement.cs +++ b/Structure_Engine/Create/Physical/SurfaceElement.cs @@ -43,10 +43,9 @@ public static partial class Create /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical IFramingElement from a Bar. The framing element will be assigned a ConstantFramingProperty based on the SectionProperty of the Bar and have a type based on the structural usage.")] - [Input("bar", "The Bar to use as the base for the framing element.")] - [Input("structuralUsage", "Used to determine which type of framing element that should be constructed.")] - [Output("framing", "The created physical FramingElement based on the Bar element provided.")] + [Description("Creates a physical Wall from a Panel. The Wall will be assigned a Construction based on the SurfaceProperty of the Panel.")] + [Input("panel", "The Panel to use as the base for the framing element.")] + [Output("wall", "The created physical Wall based on the Panel element provided.")] public static BHPE.Wall Wall(Panel panel) { if (panel.IsNull()) @@ -79,6 +78,10 @@ public static BHPE.Wall Wall(Panel panel) } /***************************************************/ + + [Description("Creates a physical Floor from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel.")] + [Input("panel", "The Panel to use as the base for the framing element.")] + [Output("floor", "The created physical Floor based on the Panel element provided.")] public static BHPE.Floor Floor(Panel panel) { if (panel.IsNull()) @@ -110,7 +113,12 @@ public static BHPE.Floor Floor(Panel panel) return surfaceElement; } + /***************************************************/ + [Description("Creates a physical surface element from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel, and the PanelType of the SufaceProperty will determine what type of surface element to create, unless overridden.")] + [Input("panel", "The Panel to use as the base for the framing element.")] + [Input("structuralUsage", "The type of surface element to create. if Undefined, the type will be based on the panel's SurfaceProperty.")] + [Output("surfaceElement", "The created surface element based on the Panel element provided.")] public static BHPE.ISurface SurfaceElement(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) { if (structuralUsage == StructuralUsage2D.Undefined) @@ -137,10 +145,6 @@ public static BHPE.ISurface SurfaceElement(Panel panel, StructuralUsage2D struct /***************************************************/ - public static BHPE.Void Void(Opening opening) - { - return new BHPE.Void() { Location = Geometry.Create.PlanarSurface(opening.Edges.Select(edge => edge.Curve).FirstOrDefault()) }; - } } } From df1386c895e119524ce514ceddfa99b7a7f7a6a8 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 7 Jul 2022 20:46:18 -0400 Subject: [PATCH 04/17] Compliance Cleanup Descriptions in Construction.cs, splitting up SurfaceElements into three separate files, one for each return type. --- .../Create/Physical/Construction.cs | 42 +++++++-- .../Physical/{SurfaceElement.cs => Floor.cs} | 67 --------------- Structure_Engine/Create/Physical/ISurface.cs | 80 +++++++++++++++++ Structure_Engine/Create/Physical/Wall.cs | 86 +++++++++++++++++++ 4 files changed, 203 insertions(+), 72 deletions(-) rename Structure_Engine/Create/Physical/{SurfaceElement.cs => Floor.cs} (54%) create mode 100644 Structure_Engine/Create/Physical/ISurface.cs create mode 100644 Structure_Engine/Create/Physical/Wall.cs diff --git a/Structure_Engine/Create/Physical/Construction.cs b/Structure_Engine/Create/Physical/Construction.cs index e822a5e2f..ef3a740b0 100644 --- a/Structure_Engine/Create/Physical/Construction.cs +++ b/Structure_Engine/Create/Physical/Construction.cs @@ -37,11 +37,9 @@ public static partial class Create /**** Public Methods ****/ /***************************************************/ - [Description("Creates a ConstantFramingProperty from a ISectionProperty and orientation angle. Extracts the SectionProfile (if existing) and Structural MaterialFragment and creates a physical material with the same name.")] - [Input("sectionProperty", "Structural section property to extract profile and material from. For explicit sections lacking a profile only the material will get extracted.")] - [Input("orientationAngle", "Defines the sections rotation around its own axis.", typeof(Angle))] - [Input("name", "Name of the property. If null/empty the name of the section property will be used.")] - [Output("FramingProperty", "The constructed physical Constant Framing Property to be used with IFramingElements such as Beams/Columns/Bracing.")] + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction IConstruction(this ISurfaceProperty property) { if (property.IsNull()) @@ -51,6 +49,10 @@ public static Construction IConstruction(this ISurfaceProperty property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this ConstantThickness property) { if (property.IsNull()) @@ -65,6 +67,10 @@ public static Construction Construction(this ConstantThickness property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this CorrugatedDeck property) { if (property.IsNull()) @@ -81,6 +87,10 @@ public static Construction Construction(this CorrugatedDeck property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this Layered property) { if (property.IsNull()) @@ -95,6 +105,10 @@ public static Construction Construction(this Layered property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this Ribbed property) { if (property.IsNull()) @@ -113,6 +127,10 @@ public static Construction Construction(this Ribbed property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this SlabOnDeck property) { if (property.IsNull()) @@ -134,6 +152,10 @@ public static Construction Construction(this SlabOnDeck property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this Waffle property) { if (property.IsNull()) @@ -152,12 +174,20 @@ public static Construction Construction(this Waffle property) } /***************************************************/ + + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] public static Construction Construction(this ISurfaceProperty property) { Base.Compute.RecordError($"Construction() not implemented for type {property.GetType()}."); return null; } + /***************************************************/ + /**** Private Methods ****/ + /***************************************************/ + private static oM.Physical.Materials.Material GetMaterial(this ISurfaceProperty property) { //Set Material @@ -176,6 +206,8 @@ private static oM.Physical.Materials.Material GetMaterial(this ISurfaceProperty return material; } + /***************************************************/ + private static oM.Physical.Materials.Material GetMaterial(this oM.Structure.SurfaceProperties.Layer layer) { //Set Material diff --git a/Structure_Engine/Create/Physical/SurfaceElement.cs b/Structure_Engine/Create/Physical/Floor.cs similarity index 54% rename from Structure_Engine/Create/Physical/SurfaceElement.cs rename to Structure_Engine/Create/Physical/Floor.cs index c91ee76fb..e6c905a2e 100644 --- a/Structure_Engine/Create/Physical/SurfaceElement.cs +++ b/Structure_Engine/Create/Physical/Floor.cs @@ -43,42 +43,6 @@ public static partial class Create /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical Wall from a Panel. The Wall will be assigned a Construction based on the SurfaceProperty of the Panel.")] - [Input("panel", "The Panel to use as the base for the framing element.")] - [Output("wall", "The created physical Wall based on the Panel element provided.")] - public static BHPE.Wall Wall(Panel panel) - { - if (panel.IsNull()) - return null; - - //Get Construction - ISurfaceProperty prop = panel.Property; - BHPC.Construction construction = null; - - if (prop == null) - Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); - else - construction = panel.Property.IConstruction(); - - //Get Location - PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); - List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); - - BHPE.Wall surfaceElement = Physical.Create.Wall(construction, externalEdges, internalEdges); - - string name = panel.Name ?? ""; - surfaceElement.Name = name; - - if (panel.FindFragment() != null || panel.Property.FindFragment() != null) - { - Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); - } - - return surfaceElement; - } - - /***************************************************/ - [Description("Creates a physical Floor from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel.")] [Input("panel", "The Panel to use as the base for the framing element.")] [Output("floor", "The created physical Floor based on the Panel element provided.")] @@ -114,37 +78,6 @@ public static BHPE.Floor Floor(Panel panel) } /***************************************************/ - - [Description("Creates a physical surface element from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel, and the PanelType of the SufaceProperty will determine what type of surface element to create, unless overridden.")] - [Input("panel", "The Panel to use as the base for the framing element.")] - [Input("structuralUsage", "The type of surface element to create. if Undefined, the type will be based on the panel's SurfaceProperty.")] - [Output("surfaceElement", "The created surface element based on the Panel element provided.")] - public static BHPE.ISurface SurfaceElement(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) - { - if (structuralUsage == StructuralUsage2D.Undefined) - { - object result = panel.Property.PropertyValue("PanelType"); - if (result != null) - { - structuralUsage = (StructuralUsage2D)result; - } - } - - switch (structuralUsage) - { - case StructuralUsage2D.Wall: - return Wall(panel); - case StructuralUsage2D.DropPanel: - case StructuralUsage2D.PileCap: - case StructuralUsage2D.Slab: - case StructuralUsage2D.Undefined: - default: - return Floor(panel); - } - } - - /***************************************************/ - } } diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/ISurface.cs new file mode 100644 index 000000000..afc1d527e --- /dev/null +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -0,0 +1,80 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System.Collections.Generic; +using System.Linq; +using BH.oM.Structure.Elements; +using BH.oM.Geometry; +using BH.oM.Base.Attributes; +using System.ComponentModel; +using BHPE = BH.oM.Physical.Elements; +using BHPC = BH.oM.Physical.Constructions; +using BH.oM.Physical.Reinforcement; +using BH.oM.Structure.SurfaceProperties; +using BH.oM.Structure.Reinforcement; +using BH.oM.Structure.Fragments; +using BH.Engine.Base; +using BH.oM.Quantities.Attributes; + +namespace BH.Engine.Structure +{ + public static partial class Create + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + [Description("Creates a physical surface element from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel, and the PanelType of the SufaceProperty will determine what type of surface element to create, unless overridden.")] + [Input("panel", "The Panel to use as the base for the framing element.")] + [Input("structuralUsage", "The type of surface element to create. if Undefined, the type will be based on the panel's SurfaceProperty.")] + [Output("surfaceElement", "The created surface element based on the Panel element provided.")] + public static BHPE.ISurface SurfaceElement(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) + { + if (structuralUsage == StructuralUsage2D.Undefined) + { + object result = panel.Property.PropertyValue("PanelType"); + if (result != null) + { + structuralUsage = (StructuralUsage2D)result; + } + } + + switch (structuralUsage) + { + case StructuralUsage2D.Wall: + return Wall(panel); + case StructuralUsage2D.DropPanel: + case StructuralUsage2D.PileCap: + case StructuralUsage2D.Slab: + case StructuralUsage2D.Undefined: + default: + return Floor(panel); + } + } + + /***************************************************/ + + } +} + + + diff --git a/Structure_Engine/Create/Physical/Wall.cs b/Structure_Engine/Create/Physical/Wall.cs new file mode 100644 index 000000000..de8361fa9 --- /dev/null +++ b/Structure_Engine/Create/Physical/Wall.cs @@ -0,0 +1,86 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System.Collections.Generic; +using System.Linq; +using BH.oM.Structure.Elements; +using BH.oM.Geometry; +using BH.oM.Base.Attributes; +using System.ComponentModel; +using BHPE = BH.oM.Physical.Elements; +using BHPC = BH.oM.Physical.Constructions; +using BH.oM.Physical.Reinforcement; +using BH.oM.Structure.SurfaceProperties; +using BH.oM.Structure.Reinforcement; +using BH.oM.Structure.Fragments; +using BH.Engine.Base; +using BH.oM.Quantities.Attributes; + +namespace BH.Engine.Structure +{ + public static partial class Create + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + [Description("Creates a physical Wall from a Panel. The Wall will be assigned a Construction based on the SurfaceProperty of the Panel.")] + [Input("panel", "The Panel to use as the base for the framing element.")] + [Output("wall", "The created physical Wall based on the Panel element provided.")] + public static BHPE.Wall Wall(Panel panel) + { + if (panel.IsNull()) + return null; + + //Get Construction + ISurfaceProperty prop = panel.Property; + BHPC.Construction construction = null; + + if (prop == null) + Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); + else + construction = panel.Property.IConstruction(); + + //Get Location + PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); + List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); + + BHPE.Wall surfaceElement = Physical.Create.Wall(construction, externalEdges, internalEdges); + + string name = panel.Name ?? ""; + surfaceElement.Name = name; + + if (panel.FindFragment() != null || panel.Property.FindFragment() != null) + { + Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); + } + + return surfaceElement; + } + + /***************************************************/ + + } +} + + + From 5b0c0245fe24e0a7e5508a1bc8e3b90b3a75905d Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Mon, 11 Jul 2022 09:22:50 -0400 Subject: [PATCH 05/17] Compliance fixes - Construction to Query space, and rename ISurface --- .../{ISurface.cs => SurfaceElement.cs} | 0 .../Physical => Query}/Construction.cs | 98 +++++++++---------- 2 files changed, 49 insertions(+), 49 deletions(-) rename Structure_Engine/Create/Physical/{ISurface.cs => SurfaceElement.cs} (100%) rename Structure_Engine/{Create/Physical => Query}/Construction.cs (72%) diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/SurfaceElement.cs similarity index 100% rename from Structure_Engine/Create/Physical/ISurface.cs rename to Structure_Engine/Create/Physical/SurfaceElement.cs diff --git a/Structure_Engine/Create/Physical/Construction.cs b/Structure_Engine/Query/Construction.cs similarity index 72% rename from Structure_Engine/Create/Physical/Construction.cs rename to Structure_Engine/Query/Construction.cs index ef3a740b0..852f38208 100644 --- a/Structure_Engine/Create/Physical/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -31,7 +31,7 @@ namespace BH.Engine.Structure { - public static partial class Create + public static partial class Query { /***************************************************/ /**** Public Methods ****/ @@ -40,12 +40,12 @@ public static partial class Create [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction IConstruction(this ISurfaceProperty property) + public static Construction IConstruction(this ISurfaceProperty surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; - return Construction(property as dynamic); + return Construction(surfaceProperty as dynamic); } /***************************************************/ @@ -53,17 +53,17 @@ public static Construction IConstruction(this ISurfaceProperty property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this ConstantThickness property) + public static Construction Construction(this ConstantThickness surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; //Set Material - oM.Physical.Materials.Material material = property.GetMaterial(); + oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = property.Thickness, Name = property.Name }; + oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = surfaceProperty.Thickness, Name = surfaceProperty.Name }; - return Physical.Create.Construction(property.Name, new List() { physicalLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer }); } /***************************************************/ @@ -71,19 +71,19 @@ public static Construction Construction(this ConstantThickness property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this CorrugatedDeck property) + public static Construction Construction(this CorrugatedDeck surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; //Set Material - oM.Physical.Materials.Material material = property.GetMaterial(); + oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - double thickness = property.Thickness * property.VolumeFactor; + double thickness = surfaceProperty.Thickness * surfaceProperty.VolumeFactor; - oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = thickness, Name = property.Name }; + oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = thickness, Name = surfaceProperty.Name }; - return Physical.Create.Construction(property.Name, new List() { physicalLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer }); } /***************************************************/ @@ -91,17 +91,17 @@ public static Construction Construction(this CorrugatedDeck property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this Layered property) + public static Construction Construction(this Layered surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; //Set Material - oM.Physical.Materials.Material material = property.GetMaterial(); + oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - List layers = property.Layers.Select(x => Physical.Create.Layer(x.Name, x.GetMaterial(), x.Thickness)).ToList(); + List layers = surfaceProperty.Layers.Select(x => Physical.Create.Layer(x.Name, x.GetMaterial(), x.Thickness)).ToList(); - return Physical.Create.Construction(property.Name, layers); + return Physical.Create.Construction(surfaceProperty.Name, layers); } /***************************************************/ @@ -109,21 +109,21 @@ public static Construction Construction(this Layered property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this Ribbed property) + public static Construction Construction(this Ribbed surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; //Set Material - oM.Physical.Materials.Material material = property.GetMaterial(); + oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - double topThickness = property.Thickness; - double bottomThickness = property.TotalDepth - topThickness; + double topThickness = surfaceProperty.Thickness; + double bottomThickness = surfaceProperty.TotalDepth - topThickness; - oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = property.Name }; - oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = property.Name }; + oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = surfaceProperty.Name }; - return Physical.Create.Construction(property.Name, new List() { topLayer, bottomLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { topLayer, bottomLayer }); } /***************************************************/ @@ -131,24 +131,24 @@ public static Construction Construction(this Ribbed property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this SlabOnDeck property) + public static Construction Construction(this SlabOnDeck surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; //Set Material - oM.Physical.Materials.Material slabMaterial = property.GetMaterial(); - oM.Physical.Materials.Material deckMaterial = Physical.Create.Material(property.DeckMaterial.Name, new List() { property.DeckMaterial }); + oM.Physical.Materials.Material slabMaterial = surfaceProperty.GetMaterial(); + oM.Physical.Materials.Material deckMaterial = Physical.Create.Material(surfaceProperty.DeckMaterial.Name, new List() { surfaceProperty.DeckMaterial }); - double topThickness = property.SlabThickness; - double bottomThickness = property.DeckHeight; - double deckThickness = property.DeckThickness * property.DeckVolumeFactor; + double topThickness = surfaceProperty.SlabThickness; + double bottomThickness = surfaceProperty.DeckHeight; + double deckThickness = surfaceProperty.DeckThickness * surfaceProperty.DeckVolumeFactor; - oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = topThickness, Name = property.Name }; - oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = bottomThickness, Name = property.Name }; - oM.Physical.Constructions.Layer deckLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = deckThickness, Name = property.Name }; + oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = topThickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = bottomThickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer deckLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = deckThickness, Name = surfaceProperty.Name }; - return Physical.Create.Construction(property.Name, new List() { topLayer, bottomLayer, deckLayer}); + return Physical.Create.Construction(surfaceProperty.Name, new List() { topLayer, bottomLayer, deckLayer}); } /***************************************************/ @@ -156,21 +156,21 @@ public static Construction Construction(this SlabOnDeck property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this Waffle property) + public static Construction Construction(this Waffle surfaceProperty) { - if (property.IsNull()) + if (surfaceProperty.IsNull()) return null; //Set Material - oM.Physical.Materials.Material material = property.GetMaterial(); + oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - double topThickness = property.Thickness; - double bottomThickness = Math.Max(property.TotalDepthX, property.TotalDepthY); + double topThickness = surfaceProperty.Thickness; + double bottomThickness = Math.Max(surfaceProperty.TotalDepthX, surfaceProperty.TotalDepthY); - oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = property.Name }; - oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = property.Name }; + oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = surfaceProperty.Name }; - return Physical.Create.Construction(property.Name, new List() { topLayer, bottomLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { topLayer, bottomLayer }); } /***************************************************/ @@ -178,9 +178,9 @@ public static Construction Construction(this Waffle property) [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this ISurfaceProperty property) + public static Construction Construction(this ISurfaceProperty surfaceProperty) { - Base.Compute.RecordError($"Construction() not implemented for type {property.GetType()}."); + Base.Compute.RecordError($"Construction() not implemented for type {surfaceProperty.GetType()}."); return null; } From 30ea06c64bb99e90ab67972a547a407bb21db467 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Mon, 11 Jul 2022 09:32:24 -0400 Subject: [PATCH 06/17] Rename SurfaceElement so method name, return type, and filename match. --- .../Create/Physical/{SurfaceElement.cs => ISurface.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Structure_Engine/Create/Physical/{SurfaceElement.cs => ISurface.cs} (96%) diff --git a/Structure_Engine/Create/Physical/SurfaceElement.cs b/Structure_Engine/Create/Physical/ISurface.cs similarity index 96% rename from Structure_Engine/Create/Physical/SurfaceElement.cs rename to Structure_Engine/Create/Physical/ISurface.cs index afc1d527e..c4baeadc8 100644 --- a/Structure_Engine/Create/Physical/SurfaceElement.cs +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -47,7 +47,7 @@ public static partial class Create [Input("panel", "The Panel to use as the base for the framing element.")] [Input("structuralUsage", "The type of surface element to create. if Undefined, the type will be based on the panel's SurfaceProperty.")] [Output("surfaceElement", "The created surface element based on the Panel element provided.")] - public static BHPE.ISurface SurfaceElement(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) + public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) { if (structuralUsage == StructuralUsage2D.Undefined) { From d474e2df39f2619152a3488bdbbb4aad126e7a0c Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 28 Jul 2022 10:40:27 -0400 Subject: [PATCH 07/17] Maintain mass and total thickness in converting ISurfaceProperty to IConstruction --- Structure_Engine/Query/Construction.cs | 52 +++++++++++++++----------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index 852f38208..9bd4cf8e8 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -28,6 +28,7 @@ using BH.oM.Physical.Constructions; using BH.oM.Structure.SurfaceProperties; using BH.oM.Quantities.Attributes; +using BH.oM.Physical.Materials; namespace BH.Engine.Structure { @@ -80,10 +81,12 @@ public static Construction Construction(this CorrugatedDeck surfaceProperty) oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); double thickness = surfaceProperty.Thickness * surfaceProperty.VolumeFactor; + double voidThickness = surfaceProperty.Height - thickness; oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = thickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = null, Thickness = voidThickness, Name = "void" }; - return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer, voidLayer }); } /***************************************************/ @@ -115,15 +118,15 @@ public static Construction Construction(this Ribbed surfaceProperty) return null; //Set Material - oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); + Material material = surfaceProperty.GetMaterial(); - double topThickness = surfaceProperty.Thickness; - double bottomThickness = surfaceProperty.TotalDepth - topThickness; + double physicalThickness = surfaceProperty.VolumePerArea(); + double voidThickness = surfaceProperty.TotalThickness() - physicalThickness; - oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = surfaceProperty.Name }; - oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = physicalThickness, Name = "Slab" }; + oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = voidThickness, Name = "Void" }; - return Physical.Create.Construction(surfaceProperty.Name, new List() { topLayer, bottomLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer, voidLayer }); } /***************************************************/ @@ -137,18 +140,23 @@ public static Construction Construction(this SlabOnDeck surfaceProperty) return null; //Set Material - oM.Physical.Materials.Material slabMaterial = surfaceProperty.GetMaterial(); - oM.Physical.Materials.Material deckMaterial = Physical.Create.Material(surfaceProperty.DeckMaterial.Name, new List() { surfaceProperty.DeckMaterial }); + MaterialComposition matComp = surfaceProperty.MaterialComposition(); - double topThickness = surfaceProperty.SlabThickness; - double bottomThickness = surfaceProperty.DeckHeight; - double deckThickness = surfaceProperty.DeckThickness * surfaceProperty.DeckVolumeFactor; + Material slabMaterial = matComp.Materials[0]; + Material deckMaterial = matComp.Materials[1]; + Material rebarMaterial = matComp.Materials[2]; - oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = topThickness, Name = surfaceProperty.Name }; - oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = bottomThickness, Name = surfaceProperty.Name }; - oM.Physical.Constructions.Layer deckLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = deckThickness, Name = surfaceProperty.Name }; + double slabThickness = surfaceProperty.VolumePerArea() * matComp.Ratios[0]; + double deckThickness = surfaceProperty.VolumePerArea() * matComp.Ratios[1]; + double rebarThickness = surfaceProperty.VolumePerArea() * matComp.Ratios[2]; + double voidThickness = surfaceProperty.TotalThickness() - (slabThickness + deckThickness + rebarThickness); - return Physical.Create.Construction(surfaceProperty.Name, new List() { topLayer, bottomLayer, deckLayer}); + oM.Physical.Constructions.Layer slabLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = slabThickness, Name = "Slab" }; + oM.Physical.Constructions.Layer deckLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = deckThickness, Name = "Deck" }; + oM.Physical.Constructions.Layer rebarLayer = new oM.Physical.Constructions.Layer() { Material = rebarMaterial, Thickness = rebarThickness, Name = "Rebar" }; + oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = voidThickness, Name = "Void" }; + + return Physical.Create.Construction(surfaceProperty.Name, new List() { slabLayer, rebarLayer, deckLayer, voidLayer }); } /***************************************************/ @@ -162,15 +170,15 @@ public static Construction Construction(this Waffle surfaceProperty) return null; //Set Material - oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); + Material material = surfaceProperty.GetMaterial(); - double topThickness = surfaceProperty.Thickness; - double bottomThickness = Math.Max(surfaceProperty.TotalDepthX, surfaceProperty.TotalDepthY); + double physicalThickness = surfaceProperty.VolumePerArea(); + double voidThickness = surfaceProperty.TotalThickness() - physicalThickness; - oM.Physical.Constructions.Layer topLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = topThickness, Name = surfaceProperty.Name }; - oM.Physical.Constructions.Layer bottomLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = bottomThickness, Name = surfaceProperty.Name }; + oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = physicalThickness, Name = "Slab" }; + oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = voidThickness, Name = "Void" }; - return Physical.Create.Construction(surfaceProperty.Name, new List() { topLayer, bottomLayer }); + return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer, voidLayer }); } /***************************************************/ From 440e316b5092855c72155a8ed9c8349076f42ad1 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 28 Jul 2022 15:34:12 -0400 Subject: [PATCH 08/17] Fixing Physical methods for constructions with void area --- Physical_Engine/Query/MaterialComposition.cs | 8 +- Physical_Engine/Query/SolidVolume.cs | 2 +- Physical_Engine/Query/VolumePerArea.cs | 76 ++++++++++ Structure_Engine/Query/Construction.cs | 138 ++----------------- 4 files changed, 94 insertions(+), 130 deletions(-) create mode 100644 Physical_Engine/Query/VolumePerArea.cs diff --git a/Physical_Engine/Query/MaterialComposition.cs b/Physical_Engine/Query/MaterialComposition.cs index ef9528474..ef836f2f1 100644 --- a/Physical_Engine/Query/MaterialComposition.cs +++ b/Physical_Engine/Query/MaterialComposition.cs @@ -195,10 +195,12 @@ private static MaterialComposition MaterialComposition(this Construction prop) { if (prop.Layers.Any(x => x.Material == null)) { - Engine.Base.Compute.RecordError("The Construction MaterialComposition could not be queried as no Material has been assigned."); - return null; + Engine.Base.Compute.RecordWarning("At least one Material in a Layered surface property was null. MaterialConstruction excludes this layer, assuming it is void space."); } - return Matter.Create.MaterialComposition(prop.Layers.Select(x => x.Material), prop.Layers.Select(x => x.Thickness)); + + IEnumerable layers = prop.Layers.Where(x => x.Material != null); + + return Matter.Create.MaterialComposition(layers.Select(x => x.Material), layers.Select(x => x.Thickness)); } /***************************************************/ diff --git a/Physical_Engine/Query/SolidVolume.cs b/Physical_Engine/Query/SolidVolume.cs index 85e2f0efa..00c409515 100644 --- a/Physical_Engine/Query/SolidVolume.cs +++ b/Physical_Engine/Query/SolidVolume.cs @@ -89,7 +89,7 @@ public static double SolidVolume(this oM.Physical.Elements.ISurface surface) double area = surface.Location.IArea(); area -= surface.Openings.Sum(x => x.Location.IArea()); - return area * surface.Construction.IThickness(); + return area * surface.Construction.IVolumePerArea(); } /***************************************************/ diff --git a/Physical_Engine/Query/VolumePerArea.cs b/Physical_Engine/Query/VolumePerArea.cs new file mode 100644 index 000000000..ca5179492 --- /dev/null +++ b/Physical_Engine/Query/VolumePerArea.cs @@ -0,0 +1,76 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using BH.oM.Physical.Constructions; +using BH.oM.Base.Attributes; +using BH.oM.Quantities.Attributes; +using System.ComponentModel; + +namespace BH.Engine.Physical +{ + public static partial class Query + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + [Description("Gets the average thickness of the property for the purpose of calculating solid volume.")] + [Input("construction", "The property to evaluate the average thickness of.")] + [Output("volumePerArea", "The average thickness of the property for the purpose of calculating solid volume.", typeof(Length))] + public static double IVolumePerArea(this IConstruction construction) + { + if (construction == null) + { + BH.Engine.Base.Compute.RecordError("Cannot query the thickness of a null construction."); + return 0; + } + + return VolumePerArea(construction as dynamic); + } + + [Description("Gets the average thickness of the property for the purpose of calculating solid volume.")] + [Input("construction", "The property to evaluate the average thickness of.")] + [Output("volumePerArea", "The average thickness of the property for the purpose of calculating solid volume.", typeof(Length))] + public static double VolumePerArea(this Construction construction) + { + if (construction == null) + return 0; + + if (construction.Layers.Any(x => x.Material == null)) + Base.Compute.RecordWarning("At least one Material in a Construction was null. VolumePerArea excludes this layer, assuming it is void space."); + + return construction.Layers.Where(x => x.Material != null).Sum(x => x.Thickness); + } + + private static double VolumePerArea(this object construction) + { + return 0; //Fallback method + } + } +} + + diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index 9bd4cf8e8..e56679b55 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -49,147 +49,33 @@ public static Construction IConstruction(this ISurfaceProperty surfaceProperty) return Construction(surfaceProperty as dynamic); } - /***************************************************/ - - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] - [Input("surfaceProperty", "Structural surface property to convert.")] - [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this ConstantThickness surfaceProperty) - { - if (surfaceProperty.IsNull()) - return null; - - //Set Material - oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - - oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = surfaceProperty.Thickness, Name = surfaceProperty.Name }; - - return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer }); - } - - /***************************************************/ - - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] - [Input("surfaceProperty", "Structural surface property to convert.")] - [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this CorrugatedDeck surfaceProperty) - { - if (surfaceProperty.IsNull()) - return null; - - //Set Material - oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - - double thickness = surfaceProperty.Thickness * surfaceProperty.VolumeFactor; - double voidThickness = surfaceProperty.Height - thickness; - - oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = thickness, Name = surfaceProperty.Name }; - oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = null, Thickness = voidThickness, Name = "void" }; - - return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer, voidLayer }); - } - - /***************************************************/ - - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] - [Input("surfaceProperty", "Structural surface property to convert.")] - [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this Layered surfaceProperty) - { - if (surfaceProperty.IsNull()) - return null; - - //Set Material - oM.Physical.Materials.Material material = surfaceProperty.GetMaterial(); - - List layers = surfaceProperty.Layers.Select(x => Physical.Create.Layer(x.Name, x.GetMaterial(), x.Thickness)).ToList(); - - return Physical.Create.Construction(surfaceProperty.Name, layers); - } + //Write specific methods here if building a Construction from a SurfaceProperty via MaterialComposition is not valid /***************************************************/ - - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] - [Input("surfaceProperty", "Structural surface property to convert.")] - [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this Ribbed surfaceProperty) - { - if (surfaceProperty.IsNull()) - return null; - - //Set Material - Material material = surfaceProperty.GetMaterial(); - - double physicalThickness = surfaceProperty.VolumePerArea(); - double voidThickness = surfaceProperty.TotalThickness() - physicalThickness; - - oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = physicalThickness, Name = "Slab" }; - oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = voidThickness, Name = "Void" }; - - return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer, voidLayer }); - } - - /***************************************************/ - - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] - [Input("surfaceProperty", "Structural surface property to convert.")] - [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this SlabOnDeck surfaceProperty) - { - if (surfaceProperty.IsNull()) - return null; - - //Set Material - MaterialComposition matComp = surfaceProperty.MaterialComposition(); - - Material slabMaterial = matComp.Materials[0]; - Material deckMaterial = matComp.Materials[1]; - Material rebarMaterial = matComp.Materials[2]; - - double slabThickness = surfaceProperty.VolumePerArea() * matComp.Ratios[0]; - double deckThickness = surfaceProperty.VolumePerArea() * matComp.Ratios[1]; - double rebarThickness = surfaceProperty.VolumePerArea() * matComp.Ratios[2]; - double voidThickness = surfaceProperty.TotalThickness() - (slabThickness + deckThickness + rebarThickness); - - oM.Physical.Constructions.Layer slabLayer = new oM.Physical.Constructions.Layer() { Material = slabMaterial, Thickness = slabThickness, Name = "Slab" }; - oM.Physical.Constructions.Layer deckLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = deckThickness, Name = "Deck" }; - oM.Physical.Constructions.Layer rebarLayer = new oM.Physical.Constructions.Layer() { Material = rebarMaterial, Thickness = rebarThickness, Name = "Rebar" }; - oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = deckMaterial, Thickness = voidThickness, Name = "Void" }; - - return Physical.Create.Construction(surfaceProperty.Name, new List() { slabLayer, rebarLayer, deckLayer, voidLayer }); - } - + /**** Fallback Method ****/ /***************************************************/ [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this Waffle surfaceProperty) + public static Construction Construction(this ISurfaceProperty surfaceProperty) { if (surfaceProperty.IsNull()) return null; - //Set Material - Material material = surfaceProperty.GetMaterial(); + MaterialComposition comp = surfaceProperty.IMaterialComposition(); + double volume = surfaceProperty.IVolumePerArea(); + double thickness = surfaceProperty.ITotalThickness(); - double physicalThickness = surfaceProperty.VolumePerArea(); - double voidThickness = surfaceProperty.TotalThickness() - physicalThickness; + List layers = new List(); - oM.Physical.Constructions.Layer physicalLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = physicalThickness, Name = "Slab" }; - oM.Physical.Constructions.Layer voidLayer = new oM.Physical.Constructions.Layer() { Material = material, Thickness = voidThickness, Name = "Void" }; + for (int i = 0; i < comp.Materials.Count(); i++) + layers.Add(new oM.Physical.Constructions.Layer() { Material = comp.Materials[i], Thickness = volume*comp.Ratios[i], Name = comp.Materials[i].Name }); - return Physical.Create.Construction(surfaceProperty.Name, new List() { physicalLayer, voidLayer }); - } + if (volume < thickness) + layers.Add(new oM.Physical.Constructions.Layer() { Material = null, Thickness = thickness - volume, Name = "void" }); - /***************************************************/ - - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] - [Input("surfaceProperty", "Structural surface property to convert.")] - [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] - public static Construction Construction(this ISurfaceProperty surfaceProperty) - { - Base.Compute.RecordError($"Construction() not implemented for type {surfaceProperty.GetType()}."); - return null; + return Physical.Create.Construction(surfaceProperty.Name, layers); } /***************************************************/ From c1ba3eccb0286c190cdeba3c052971fe43239870 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 28 Jul 2022 15:38:59 -0400 Subject: [PATCH 09/17] add null handling --- Structure_Engine/Create/Physical/ISurface.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/ISurface.cs index c4baeadc8..37551b722 100644 --- a/Structure_Engine/Create/Physical/ISurface.cs +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -49,6 +49,9 @@ public static partial class Create [Output("surfaceElement", "The created surface element based on the Panel element provided.")] public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUsage = StructuralUsage2D.Undefined) { + if (panel.IsNull()) + return null; + if (structuralUsage == StructuralUsage2D.Undefined) { object result = panel.Property.PropertyValue("PanelType"); From 0466db2ca84d589f9b833e0b6c4ce09aaa37b31e Mon Sep 17 00:00:00 2001 From: BHoMBot Date: Thu, 28 Jul 2022 20:54:57 +0100 Subject: [PATCH 10/17] Add documentation punctuation --- Physical_Engine/Create/Floor.cs | 28 ++------- Physical_Engine/Create/Wall.cs | 57 +++--------------- Physical_Engine/Query/MaterialComposition.cs | 60 +++++++------------ Physical_Engine/Query/SolidVolume.cs | 36 ++++------- Physical_Engine/Query/VolumePerArea.cs | 8 +-- .../Physical/ConstantFramingProperty.cs | 18 +----- Structure_Engine/Create/Physical/Floor.cs | 16 +---- .../Create/Physical/FramingElement.cs | 18 ++---- Structure_Engine/Create/Physical/ISurface.cs | 12 +--- Structure_Engine/Create/Physical/Wall.cs | 17 +----- Structure_Engine/Query/Construction.cs | 29 +++------ 11 files changed, 68 insertions(+), 231 deletions(-) diff --git a/Physical_Engine/Create/Floor.cs b/Physical_Engine/Create/Floor.cs index 30e986f45..dd8323507 100644 --- a/Physical_Engine/Create/Floor.cs +++ b/Physical_Engine/Create/Floor.cs @@ -19,9 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System.ComponentModel; - using BH.oM.Physical.Constructions; using BH.oM.Base.Attributes; using BH.oM.Physical.Elements; @@ -36,7 +34,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical floor element. For elements for structral analytical applications look at BH.oM.Structure.Elements.Panel. For elements for environmental analytical applications look at BH.oM.Environments.Elements.Panel.")] [Input("location", "Location surface which represents the outer geometry of the floor. Should not contain any openings.")] [Input("construction", "Construction representing the thickness and materiality of the floor.")] @@ -47,15 +44,7 @@ public static partial class Create public static Floor Floor(oM.Geometry.ISurface location, IConstruction construction, List openings = null, Offset offset = Offset.Undefined, string name = "") { openings = openings ?? new List(); - - return new Floor - { - Location = location, - Construction = construction, - Openings = openings, - Offset = offset, - Name = name - }; + return new Floor{Location = location, Construction = construction, Openings = openings, Offset = offset, Name = name}; } [Description("Creates physical floor based on given construction and external edges.")] @@ -68,7 +57,6 @@ public static Floor Floor(Construction construction, ICurve edges) } /***************************************************/ - [Description("Creates physical floor based on given construction, external and internal edges.")] [Input("construction", "Construction of the floor.")] [Input("edges", "External edges of the floor (Profile - planar closed curve).")] @@ -85,7 +73,6 @@ public static Floor Floor(Construction construction, ICurve edges, IEnumerable aInternalCurveList = null; if (internalEdges != null && internalEdges.Count() > 0) aInternalCurveList = internalEdges.ToList().ConvertAll(x => x as ICurve); - PlanarSurface aPlanarSurface = Geometry.Create.PlanarSurface(edges, aInternalCurveList); if (aPlanarSurface == null) { @@ -94,15 +81,8 @@ public static Floor Floor(Construction construction, ICurve edges, IEnumerable. */ - using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - using BH.oM.Physical.Constructions; using BH.oM.Physical.Materials; - using BH.oM.Base.Attributes; using System.ComponentModel; using BH.oM.Physical.Elements; @@ -42,7 +39,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates physical wall based on given construction, bottom curve and height.")] [Input("construction", "Construction of the wall.")] [Input("bottomEdge", "Curve representing bottom edge of the wall.")] @@ -61,23 +57,16 @@ public static Wall Wall(IConstruction construction, ICurve bottomEdge, double he Base.Compute.RecordError("Physical Wall could not be created because bottom edge cannot be closed curve."); return null; } - - ICurve aICurve = bottomEdge.ITranslate(Geometry.Create.Vector(0, 0, height)).IFlip(); + ICurve aICurve = bottomEdge.ITranslate(Geometry.Create.Vector(0, 0, height)).IFlip(); Line aLine_1 = Geometry.Create.Line(bottomEdge.IEndPoint(), aICurve.IStartPoint()); Line aLine_2 = Geometry.Create.Line(aICurve.IEndPoint(), bottomEdge.IStartPoint()); - - PolyCurve aPolyCurve = Geometry.Create.PolyCurve(new ICurve[] { bottomEdge, aLine_1, aICurve, aLine_2 }); - + PolyCurve aPolyCurve = Geometry.Create.PolyCurve(new ICurve[]{bottomEdge, aLine_1, aICurve, aLine_2}); return new Wall() - { - Construction = construction, - Location = Geometry.Create.PlanarSurface(aPolyCurve) - }; + {Construction = construction, Location = Geometry.Create.PlanarSurface(aPolyCurve)}; } /***************************************************/ - [Description("Creates a physical Wall element. For elements for structral analytical applications look at BH.oM.Structure.Elements.Panel. For elements for environmental analytical applications look at BH.oM.Environments.Elements.Panel.")] [Input("line", "Base line of the wall.")] [Input("height", "Height of the wall.")] @@ -87,33 +76,23 @@ public static Wall Wall(IConstruction construction, ICurve bottomEdge, double he [Output("Wall", "The created physical Wall.")] public static Wall Wall(Line line, double height, IConstruction construction, Offset offset = Offset.Undefined, string name = "") { - if(line == null) + if (line == null) { BH.Engine.Base.Compute.RecordError("Cannot create a Physical.Wall from a null line."); return null; } Polyline boundary = new Polyline(); - Vector move = Vector.ZAxis * height; - boundary.ControlPoints.Add(line.Start); boundary.ControlPoints.Add(line.End); boundary.ControlPoints.Add(line.End + move); boundary.ControlPoints.Add(line.Start + move); boundary.ControlPoints.Add(line.Start); - - return new Wall - { - Location = Geometry.Create.PlanarSurface(boundary), - Construction = construction, - Offset = offset, - Name = name - }; + return new Wall{Location = Geometry.Create.PlanarSurface(boundary), Construction = construction, Offset = offset, Name = name}; } /***************************************************/ - [Description("Creates physical wall object.")] [Input("construction", "Construction of the wall.")] [Input("edges", "External edges of the wall (Profile - planar closed curve).")] @@ -130,7 +109,6 @@ public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable aInternalCurveList = null; if (internalEdges != null && internalEdges.Count() > 0) aInternalCurveList = internalEdges.ToList().ConvertAll(x => x as ICurve); - PlanarSurface aPlanarSurface = Geometry.Create.PlanarSurface(edges, aInternalCurveList); if (aPlanarSurface == null) { @@ -139,14 +117,10 @@ public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable openings = null, Offset offset = Offset.Undefined, string name = "") { openings = openings ?? new List(); - - return new Wall - { - Location = location, - Construction = construction, - Openings = openings, - Offset = offset, - Name = name - }; + return new Wall{Location = location, Construction = construction, Openings = openings, Offset = offset, Name = name}; } /***************************************************/ - [Description("Creates physical wall object.")] [Input("construction", "Construction of the wall.")] [Input("edges", "External edges of the wall (Profile - planar closed curve).")] @@ -178,10 +143,6 @@ public static Wall Wall(IConstruction construction, ICurve edges) { return Wall(construction, edges, null); } - - /***************************************************/ + /***************************************************/ } -} - - - +} \ No newline at end of file diff --git a/Physical_Engine/Query/MaterialComposition.cs b/Physical_Engine/Query/MaterialComposition.cs index ef836f2f1..5997f12b4 100644 --- a/Physical_Engine/Query/MaterialComposition.cs +++ b/Physical_Engine/Query/MaterialComposition.cs @@ -19,14 +19,12 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using BH.oM.Base.Attributes; using BH.oM.Physical.Elements; - using BH.Engine.Base; using BH.oM.Physical.Materials; using BH.oM.Physical.FramingProperties; @@ -40,13 +38,12 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ - - [Description("Gets all the Materials a IFramingElement is composed of and in which ratios")] - [Input("framingElement", "The IFramingElement to get the MaterialComposition from")] - [Output("materialComposition", "The kind of matter the IFramingElement is composed of and in which ratios")] + [Description("Gets all the Materials a IFramingElement is composed of and in which ratios.")] + [Input("framingElement", "The IFramingElement to get the MaterialComposition from.")] + [Output("materialComposition", "The kind of matter the IFramingElement is composed of and in which ratios.")] public static MaterialComposition MaterialComposition(this IFramingElement framingElement) { - if(framingElement == null) + if (framingElement == null) { BH.Engine.Base.Compute.RecordError("Cannot query the material composition of a null framing element."); return null; @@ -57,17 +54,17 @@ public static MaterialComposition MaterialComposition(this IFramingElement frami Engine.Base.Compute.RecordError("The MaterialComposition could not be queried as no Property has been assigned to the IFramingElement."); return null; } + return framingElement.Property.IMaterialComposition(); } /***************************************************/ - - [Description("Gets all the Materials a ISurface is composed of and in which ratios")] - [Input("surface", "The ISurface to get the MaterialComposition from")] - [Output("materialComposition", "The kind of matter the ISurface is composed of and in which ratios")] + [Description("Gets all the Materials a ISurface is composed of and in which ratios.")] + [Input("surface", "The ISurface to get the MaterialComposition from.")] + [Output("materialComposition", "The kind of matter the ISurface is composed of and in which ratios.")] public static MaterialComposition MaterialComposition(this ISurface surface) { - if(surface == null) + if (surface == null) { BH.Engine.Base.Compute.RecordError("Cannot query the material composition of a null surface."); return null; @@ -78,14 +75,14 @@ public static MaterialComposition MaterialComposition(this ISurface surface) Engine.Base.Compute.RecordError("The MaterialComposition could not be queried as no IConstruction has been assigned to the ISurface."); return null; } + return surface.Construction.IMaterialComposition(); } /***************************************************/ - - [Description("Gets all the Materials an IOpening is composed of and in which ratios")] - [Input("opening", "The IOpening to get the MaterialComposition from")] - [Output("materialComposition", "The kind of matter the IOpening is composed of and in which ratios")] + [Description("Gets all the Materials an IOpening is composed of and in which ratios.")] + [Input("opening", "The IOpening to get the MaterialComposition from.")] + [Output("materialComposition", "The kind of matter the IOpening is composed of and in which ratios.")] public static MaterialComposition MaterialComposition(this IOpening opening) { MaterialComposition materialComposition = null; @@ -121,10 +118,9 @@ public static MaterialComposition MaterialComposition(this IOpening opening) } /***************************************************/ - - [Description("Gets all the Materials a SolidBulk is composed of and in which ratios")] - [Input("solidBulk", "The SolidBulk to get the MaterialComposition from")] - [Output("materialComposition", "The kind of matter the SolidBulk is composed of and in which ratios", typeof(Ratio))] + [Description("Gets all the Materials a SolidBulk is composed of and in which ratios.")] + [Input("solidBulk", "The SolidBulk to get the MaterialComposition from.")] + [Output("materialComposition", "The kind of matter the SolidBulk is composed of and in which ratios.", typeof(Ratio))] public static MaterialComposition MaterialComposition(this SolidBulk solidBulk) { if (solidBulk == null) @@ -137,14 +133,14 @@ public static MaterialComposition MaterialComposition(this SolidBulk solidBulk) Engine.Base.Compute.RecordError("The SolidBulk MaterialComposition could not be queried as no Materials have been assigned to at least one of the layers of the Construction."); return null; } + return solidBulk.MaterialComposition; } /***************************************************/ - - [Description("Gets all the Materials a ExplicitBulk is composed of and in which ratios")] - [Input("explicitBulk", "The ExplicitBulk to get the MaterialComposition from")] - [Output("materialComposition", "The kind of matter the ExplicitBulk is composed of and in which ratios", typeof(Ratio))] + [Description("Gets all the Materials a ExplicitBulk is composed of and in which ratios.")] + [Input("explicitBulk", "The ExplicitBulk to get the MaterialComposition from.")] + [Output("materialComposition", "The kind of matter the ExplicitBulk is composed of and in which ratios.", typeof(Ratio))] public static MaterialComposition MaterialComposition(this ExplicitBulk explicitBulk) { if (explicitBulk == null) @@ -157,13 +153,13 @@ public static MaterialComposition MaterialComposition(this ExplicitBulk explicit Engine.Base.Compute.RecordError("The ExplicitBulk MaterialComposition could not be queried as no Materials have been assigned to at least one of the layers of the Construction."); return null; } + return explicitBulk.MaterialComposition; } /******************************************************/ /**** IConstruction Methods ****/ /******************************************************/ - public static MaterialComposition IMaterialComposition(this IConstruction prop) { return MaterialComposition(prop as dynamic); @@ -172,7 +168,6 @@ public static MaterialComposition IMaterialComposition(this IConstruction prop) /******************************************************/ /**** IFramingElementProperty Methods ****/ /******************************************************/ - private static MaterialComposition IMaterialComposition(this IFramingElementProperty prop) { return MaterialComposition(prop as dynamic); @@ -181,7 +176,6 @@ private static MaterialComposition IMaterialComposition(this IFramingElementProp /******************************************************/ /**** IOpening Methods ****/ /******************************************************/ - private static MaterialComposition IMaterialComposition(this IOpening prop) { return MaterialComposition(prop as dynamic); @@ -190,7 +184,6 @@ private static MaterialComposition IMaterialComposition(this IOpening prop) /***************************************************/ /**** Private Methods ****/ /***************************************************/ - private static MaterialComposition MaterialComposition(this Construction prop) { if (prop.Layers.Any(x => x.Material == null)) @@ -199,21 +192,18 @@ private static MaterialComposition MaterialComposition(this Construction prop) } IEnumerable layers = prop.Layers.Where(x => x.Material != null); - return Matter.Create.MaterialComposition(layers.Select(x => x.Material), layers.Select(x => x.Thickness)); } /***************************************************/ /**** Private Fallback Methods ****/ /***************************************************/ - private static MaterialComposition MaterialComposition(this IConstruction prop) { throw new NotImplementedException(); } /***************************************************/ - private static MaterialComposition MaterialComposition(this ConstantFramingProperty prop) { if (prop.Material == null) @@ -221,20 +211,16 @@ private static MaterialComposition MaterialComposition(this ConstantFramingPrope Engine.Base.Compute.RecordError("The ConstantFramingProperty MaterialComposition could not be queried as no Material has been assigned to the ConstantFramingProperty."); return null; } + return (MaterialComposition)prop.Material; } /***************************************************/ /**** Private Fallback Methods ****/ /***************************************************/ - private static MaterialComposition MaterialComposition(this IFramingElementProperty prop) { throw new NotImplementedException(); } - - } -} - - +} \ No newline at end of file diff --git a/Physical_Engine/Query/SolidVolume.cs b/Physical_Engine/Query/SolidVolume.cs index 00c409515..91365fec3 100644 --- a/Physical_Engine/Query/SolidVolume.cs +++ b/Physical_Engine/Query/SolidVolume.cs @@ -19,14 +19,12 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using BH.oM.Base.Attributes; using BH.oM.Physical.Elements; - using BH.Engine.Base; using BH.oM.Physical.FramingProperties; using BH.oM.Geometry; @@ -43,13 +41,12 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ - - [Description("Gets an IFramingElement's solid volume from the average area and length")] - [Input("framingElement", "the IFramingElement to get the volume from")] + [Description("Gets an IFramingElement's solid volume from the average area and length.")] + [Input("framingElement", "the IFramingElement to get the volume from.")] [Output("volume", "The IFramingElement's solid material volume.", typeof(Volume))] public static double SolidVolume(this IFramingElement framingElement) { - if(framingElement == null) + if (framingElement == null) { BH.Engine.Base.Compute.RecordError("Cannot query the solid volume of a null framing element."); return 0; @@ -60,18 +57,17 @@ public static double SolidVolume(this IFramingElement framingElement) Engine.Base.Compute.RecordError("The IFramingElement Solid Volume could not be calculated as no property has been assigned. Returning zero volume."); return 0; } + return framingElement.Location.Length() * IAverageProfileArea(framingElement.Property); } /***************************************************/ - - [Description("Returns an ISurface's solid volume based on thickness and area." + - "ISurfaces with offsets other than Centre are not fully supported.")] - [Input("surface", "the ISurface to get the volume from")] + [Description("Returns an ISurface's solid volume based on thickness and area." + "ISurfaces with offsets other than Centre are not fully supported.")] + [Input("surface", "the ISurface to get the volume from.")] [Output("volume", "The ISurface's solid material volume.", typeof(Volume))] public static double SolidVolume(this oM.Physical.Elements.ISurface surface) { - if(surface == null) + if (surface == null) { BH.Engine.Base.Compute.RecordError("Cannot query the solid volume of a null surface."); return 0; @@ -85,15 +81,12 @@ public static double SolidVolume(this oM.Physical.Elements.ISurface surface) if (surface.Offset != Offset.Centre && !surface.Location.IIsPlanar()) Base.Compute.RecordWarning("The SolidVolume for non-Planar ISurfaces with offsets other than Centre is approxamite at best"); - double area = surface.Location.IArea(); area -= surface.Openings.Sum(x => x.Location.IArea()); - return area * surface.Construction.IVolumePerArea(); } /***************************************************/ - [Description("Return the total volume of SolidBulk.")] [Input("solidBulk", "Solid geometric elements that have a MaterialComposition.")] [Output("volume", "The combined volume of SolidBulk.", typeof(Volume))] @@ -106,7 +99,6 @@ public static double SolidVolume(this SolidBulk solidBulk) } double solidVolume = solidBulk.Geometry.Select(x => x.IVolume()).Sum(); - if (solidVolume <= 0) { Engine.Base.Compute.RecordError("The queried volume has been nonpositive. Returning zero instead."); @@ -117,7 +109,6 @@ public static double SolidVolume(this SolidBulk solidBulk) } /***************************************************/ - [Description("Return the total volume of ExplicitBulk.")] [Input("explicitBulk", "Elements containing Volume and MaterialComposition properties.")] [Output("volume", "The combined volume of ExplicitBulk.", typeof(Volume))] @@ -135,11 +126,12 @@ public static double SolidVolume(this ExplicitBulk explicitBulk) Engine.Base.Compute.RecordError("The queried volume has been nonpositive. Returning zero instead."); return 0; } + return solidVolume; } [Description("Returns an IOpening's solid volume based on thickness and area.")] - [Input("window", "the window to get the volume from")] + [Input("window", "the window to get the volume from.")] [Output("volume", "The window's solid material volume.", typeof(Volume))] public static double SolidVolume(this IOpening opening) { @@ -150,15 +142,12 @@ public static double SolidVolume(this IOpening opening) } double area = opening.IArea(); - double thickness = 0; if (opening is Window) thickness = (opening as Window).Construction.IThickness(); else if (opening is Door) thickness = (opening as Door).Construction.IThickness(); - double solidVolume = area * thickness; - if (solidVolume <= 0) { Engine.Base.Compute.RecordError("Solid volume cannot be calculated for element of type :" + opening.GetType() + ". Returning zero volume."); @@ -167,9 +156,6 @@ public static double SolidVolume(this IOpening opening) return solidVolume; } - - /***************************************************/ + /***************************************************/ } -} - - +} \ No newline at end of file diff --git a/Physical_Engine/Query/VolumePerArea.cs b/Physical_Engine/Query/VolumePerArea.cs index ca5179492..fb32b93f7 100644 --- a/Physical_Engine/Query/VolumePerArea.cs +++ b/Physical_Engine/Query/VolumePerArea.cs @@ -19,13 +19,11 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - using BH.oM.Physical.Constructions; using BH.oM.Base.Attributes; using BH.oM.Quantities.Attributes; @@ -59,10 +57,8 @@ public static double VolumePerArea(this Construction construction) { if (construction == null) return 0; - if (construction.Layers.Any(x => x.Material == null)) Base.Compute.RecordWarning("At least one Material in a Construction was null. VolumePerArea excludes this layer, assuming it is void space."); - return construction.Layers.Where(x => x.Material != null).Sum(x => x.Thickness); } @@ -71,6 +67,4 @@ private static double VolumePerArea(this object construction) return 0; //Fallback method } } -} - - +} \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/ConstantFramingProperty.cs b/Structure_Engine/Create/Physical/ConstantFramingProperty.cs index a9b9aa425..62a029730 100644 --- a/Structure_Engine/Create/Physical/ConstantFramingProperty.cs +++ b/Structure_Engine/Create/Physical/ConstantFramingProperty.cs @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System; using System.Linq; using System.Collections.Generic; @@ -37,7 +36,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a ConstantFramingProperty from a ISectionProperty and orientation angle. Extracts the SectionProfile (if existing) and Structural MaterialFragment and creates a physical material with the same name.")] [Input("sectionProperty", "Structural section property to extract profile and material from. For explicit sections lacking a profile only the material will get extracted.")] [Input("orientationAngle", "Defines the sections rotation around its own axis.", typeof(Angle))] @@ -47,20 +45,16 @@ public static ConstantFramingProperty ConstantFramingProperty(ISectionProperty s { if (sectionProperty.IsNull()) return null; - IProfile profile = null; if (sectionProperty is IGeometricalSection) profile = (sectionProperty as IGeometricalSection).SectionProfile; else Base.Compute.RecordWarning("Was not able to extract any section profile."); - - oM.Physical.Materials.Material material = null; - if (sectionProperty.Material != null) { string matName = sectionProperty.Material.Name ?? ""; - material = Physical.Create.Material(matName, new List { sectionProperty.Material }); + material = Physical.Create.Material(matName, new List{sectionProperty.Material}); } else { @@ -68,14 +62,8 @@ public static ConstantFramingProperty ConstantFramingProperty(ISectionProperty s } name = string.IsNullOrEmpty(name) ? sectionProperty.Name : name; - return Physical.Create.ConstantFramingProperty(profile, material, orientationAngle, name); - } - - /***************************************************/ + /***************************************************/ } -} - - - +} \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/Floor.cs b/Structure_Engine/Create/Physical/Floor.cs index e6c905a2e..30c86864a 100644 --- a/Structure_Engine/Create/Physical/Floor.cs +++ b/Structure_Engine/Create/Physical/Floor.cs @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System.Collections.Generic; using System.Linq; using BH.oM.Structure.Elements; @@ -42,7 +41,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical Floor from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel.")] [Input("panel", "The Panel to use as the base for the framing element.")] [Output("floor", "The created physical Floor based on the Panel element provided.")] @@ -50,25 +48,19 @@ public static BHPE.Floor Floor(Panel panel) { if (panel.IsNull()) return null; - //Get Construction ISurfaceProperty prop = panel.Property; BHPC.Construction construction = null; - if (prop == null) Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); else construction = panel.Property.IConstruction(); - //Get Location PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); - BHPE.Floor surfaceElement = Physical.Create.Floor(construction, externalEdges, internalEdges); - string name = panel.Name ?? ""; surfaceElement.Name = name; - if (panel.FindFragment() != null || panel.Property.FindFragment() != null) { Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); @@ -76,10 +68,6 @@ public static BHPE.Floor Floor(Panel panel) return surfaceElement; } - - /***************************************************/ + /***************************************************/ } -} - - - +} \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/FramingElement.cs b/Structure_Engine/Create/Physical/FramingElement.cs index 15c0d09d4..72d8e09ea 100644 --- a/Structure_Engine/Create/Physical/FramingElement.cs +++ b/Structure_Engine/Create/Physical/FramingElement.cs @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System.Collections.Generic; using BH.oM.Structure.Elements; using BH.oM.Structure.SectionProperties; @@ -38,7 +37,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical IFramingElement from a Bar. The framing element will be assigned a ConstantFramingProperty based on the SectionProperty of the Bar and have a type based on the structural usage.")] [Input("bar", "The Bar to use as the base for the framing element.")] [Input("structuralUsage", "Used to determine which type of framing element that should be constructed.")] @@ -47,19 +45,15 @@ public static BHPE.IFramingElement FramingElement(Bar bar, StructuralUsage1D str { if (bar.IsNull()) return null; - ISectionProperty prop = bar.SectionProperty; BHPP.ConstantFramingProperty framingProp = null; if (prop == null) Base.Compute.RecordWarning("The bar does not contain a sectionProperty. Can not extract profile or material"); else framingProp = Create.ConstantFramingProperty(bar.SectionProperty, bar.OrientationAngle); - Line location = bar.Centreline(); string name = bar.Name ?? ""; - BHPE.IFramingElement framingElement; - switch (structuralUsage) { case StructuralUsage1D.Column: @@ -81,21 +75,17 @@ public static BHPE.IFramingElement FramingElement(Bar bar, StructuralUsage1D str break; } - if (bar.HasReinforcement()) { List reinforcement = bar.ReinforcingBars(); if (reinforcement.Count != 0) { - framingElement.Fragments.Add(new ReinforcementFragment { ReinforcingBars = reinforcement }); + framingElement.Fragments.Add(new ReinforcementFragment{ReinforcingBars = reinforcement}); } } + return framingElement; } - - /***************************************************/ + /***************************************************/ } -} - - - +} \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/ISurface.cs index 37551b722..7331555aa 100644 --- a/Structure_Engine/Create/Physical/ISurface.cs +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System.Collections.Generic; using System.Linq; using BH.oM.Structure.Elements; @@ -42,7 +41,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical surface element from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel, and the PanelType of the SufaceProperty will determine what type of surface element to create, unless overridden.")] [Input("panel", "The Panel to use as the base for the framing element.")] [Input("structuralUsage", "The type of surface element to create. if Undefined, the type will be based on the panel's SurfaceProperty.")] @@ -51,7 +49,6 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs { if (panel.IsNull()) return null; - if (structuralUsage == StructuralUsage2D.Undefined) { object result = panel.Property.PropertyValue("PanelType"); @@ -73,11 +70,6 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs return Floor(panel); } } - - /***************************************************/ - + /***************************************************/ } -} - - - +} \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/Wall.cs b/Structure_Engine/Create/Physical/Wall.cs index de8361fa9..0133f13aa 100644 --- a/Structure_Engine/Create/Physical/Wall.cs +++ b/Structure_Engine/Create/Physical/Wall.cs @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System.Collections.Generic; using System.Linq; using BH.oM.Structure.Elements; @@ -42,7 +41,6 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical Wall from a Panel. The Wall will be assigned a Construction based on the SurfaceProperty of the Panel.")] [Input("panel", "The Panel to use as the base for the framing element.")] [Output("wall", "The created physical Wall based on the Panel element provided.")] @@ -50,25 +48,19 @@ public static BHPE.Wall Wall(Panel panel) { if (panel.IsNull()) return null; - //Get Construction ISurfaceProperty prop = panel.Property; BHPC.Construction construction = null; - if (prop == null) Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); else construction = panel.Property.IConstruction(); - //Get Location PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); - BHPE.Wall surfaceElement = Physical.Create.Wall(construction, externalEdges, internalEdges); - string name = panel.Name ?? ""; surfaceElement.Name = name; - if (panel.FindFragment() != null || panel.Property.FindFragment() != null) { Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); @@ -76,11 +68,6 @@ public static BHPE.Wall Wall(Panel panel) return surfaceElement; } - - /***************************************************/ - + /***************************************************/ } -} - - - +} \ No newline at end of file diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index e56679b55..429a8c783 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ - using System; using System.Linq; using System.Collections.Generic; @@ -37,7 +36,6 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] @@ -45,16 +43,13 @@ public static Construction IConstruction(this ISurfaceProperty surfaceProperty) { if (surfaceProperty.IsNull()) return null; - return Construction(surfaceProperty as dynamic); } //Write specific methods here if building a Construction from a SurfaceProperty via MaterialComposition is not valid - /***************************************************/ /**** Fallback Method ****/ /***************************************************/ - [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] @@ -62,35 +57,30 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) { if (surfaceProperty.IsNull()) return null; - MaterialComposition comp = surfaceProperty.IMaterialComposition(); double volume = surfaceProperty.IVolumePerArea(); double thickness = surfaceProperty.ITotalThickness(); - List layers = new List(); - for (int i = 0; i < comp.Materials.Count(); i++) - layers.Add(new oM.Physical.Constructions.Layer() { Material = comp.Materials[i], Thickness = volume*comp.Ratios[i], Name = comp.Materials[i].Name }); - + layers.Add(new oM.Physical.Constructions.Layer() + {Material = comp.Materials[i], Thickness = volume * comp.Ratios[i], Name = comp.Materials[i].Name}); if (volume < thickness) - layers.Add(new oM.Physical.Constructions.Layer() { Material = null, Thickness = thickness - volume, Name = "void" }); - + layers.Add(new oM.Physical.Constructions.Layer() + {Material = null, Thickness = thickness - volume, Name = "void"}); return Physical.Create.Construction(surfaceProperty.Name, layers); } /***************************************************/ /**** Private Methods ****/ /***************************************************/ - private static oM.Physical.Materials.Material GetMaterial(this ISurfaceProperty property) { //Set Material oM.Physical.Materials.Material material = null; - if (property.Material != null) { string matName = property.Material.DescriptionOrName(); - material = Physical.Create.Material(matName, new List { property.Material }); + material = Physical.Create.Material(matName, new List{property.Material}); } else { @@ -101,16 +91,14 @@ private static oM.Physical.Materials.Material GetMaterial(this ISurfaceProperty } /***************************************************/ - private static oM.Physical.Materials.Material GetMaterial(this oM.Structure.SurfaceProperties.Layer layer) { //Set Material oM.Physical.Materials.Material material = null; - if (layer.Material != null) { string matName = layer.Material.DescriptionOrName(); - material = Physical.Create.Material(matName, new List { layer.Material }); + material = Physical.Create.Material(matName, new List{layer.Material}); } else { @@ -120,7 +108,4 @@ private static oM.Physical.Materials.Material GetMaterial(this oM.Structure.Surf return material; } } -} - - - +} \ No newline at end of file From c86f7242c8e49628f90f25b6703c5724d4ffaf6e Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 28 Jul 2022 16:01:05 -0400 Subject: [PATCH 11/17] documentation fixes --- Physical_Engine/Query/MaterialComposition.cs | 3 +++ Physical_Engine/Query/SolidVolume.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Physical_Engine/Query/MaterialComposition.cs b/Physical_Engine/Query/MaterialComposition.cs index 5997f12b4..e39c1717a 100644 --- a/Physical_Engine/Query/MaterialComposition.cs +++ b/Physical_Engine/Query/MaterialComposition.cs @@ -160,6 +160,9 @@ public static MaterialComposition MaterialComposition(this ExplicitBulk explicit /******************************************************/ /**** IConstruction Methods ****/ /******************************************************/ + [Description("Gets all the Materials a ExplicitBulk is composed of and in which ratios.")] + [Input("prop", "The ExplicitBulk to get the MaterialComposition from.")] + [Output("materialComposition", "The kind of matter the ExplicitBulk is composed of and in which ratios.", typeof(Ratio))] public static MaterialComposition IMaterialComposition(this IConstruction prop) { return MaterialComposition(prop as dynamic); diff --git a/Physical_Engine/Query/SolidVolume.cs b/Physical_Engine/Query/SolidVolume.cs index 91365fec3..733fd9f4f 100644 --- a/Physical_Engine/Query/SolidVolume.cs +++ b/Physical_Engine/Query/SolidVolume.cs @@ -131,7 +131,7 @@ public static double SolidVolume(this ExplicitBulk explicitBulk) } [Description("Returns an IOpening's solid volume based on thickness and area.")] - [Input("window", "the window to get the volume from.")] + [Input("opening", "the window to get the volume from.")] [Output("volume", "The window's solid material volume.", typeof(Volume))] public static double SolidVolume(this IOpening opening) { From bb539081a4dc84800a5470c2daef0eb5d9bf1f87 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Tue, 2 Aug 2022 14:57:21 -0400 Subject: [PATCH 12/17] fixing Physical Create Floor and Wall to handle openings properly. --- Physical_Engine/Create/Floor.cs | 23 ++++++++++++------- Physical_Engine/Create/Wall.cs | 27 +++++++++++++---------- Structure_Engine/Create/Physical/Floor.cs | 2 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Physical_Engine/Create/Floor.cs b/Physical_Engine/Create/Floor.cs index dd8323507..0bac30f6f 100644 --- a/Physical_Engine/Create/Floor.cs +++ b/Physical_Engine/Create/Floor.cs @@ -70,18 +70,25 @@ public static Floor Floor(Construction construction, ICurve edges, IEnumerable aInternalCurveList = null; - if (internalEdges != null && internalEdges.Count() > 0) - aInternalCurveList = internalEdges.ToList().ConvertAll(x => x as ICurve); - PlanarSurface aPlanarSurface = Geometry.Create.PlanarSurface(edges, aInternalCurveList); - if (aPlanarSurface == null) + //Create the location for the floor + PlanarSurface location = Geometry.Create.PlanarSurface(edges); + if (location == null) { - Base.Compute.RecordError("Physical Roof could not be created because of invalid geometry of edges."); + Base.Compute.RecordError("Physical Floor could not be created because of invalid geometry of edges."); return null; } - return new Floor() - {Construction = construction, Location = aPlanarSurface}; + //Create the openings + List openings = new List(); + + if (internalEdges != null && internalEdges.Count() > 0) + { + foreach (ICurve openingCurve in internalEdges) + if (openingCurve != null) + openings.Add(new Void() { Location = Geometry.Create.PlanarSurface(openingCurve) }); + } + + return Floor(location, construction, openings); } /***************************************************/ } diff --git a/Physical_Engine/Create/Wall.cs b/Physical_Engine/Create/Wall.cs index c0b2ce51a..26bd3ab15 100644 --- a/Physical_Engine/Create/Wall.cs +++ b/Physical_Engine/Create/Wall.cs @@ -19,13 +19,9 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using BH.oM.Physical.Constructions; -using BH.oM.Physical.Materials; using BH.oM.Base.Attributes; using System.ComponentModel; using BH.oM.Physical.Elements; @@ -98,7 +94,7 @@ public static Wall Wall(Line line, double height, IConstruction construction, Of [Input("edges", "External edges of the wall (Profile - planar closed curve).")] [Input("internalEdges", "Internal edges of wall (profile).")] [Output("wall", "A physical wall.")] - public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable internalEdges) + public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable internalEdges = null) { if (construction == null || edges == null) { @@ -106,18 +102,25 @@ public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable aInternalCurveList = null; - if (internalEdges != null && internalEdges.Count() > 0) - aInternalCurveList = internalEdges.ToList().ConvertAll(x => x as ICurve); - PlanarSurface aPlanarSurface = Geometry.Create.PlanarSurface(edges, aInternalCurveList); - if (aPlanarSurface == null) + //Create the location for the wall + PlanarSurface location = Geometry.Create.PlanarSurface(edges); + if (location == null) { Base.Compute.RecordError("Physical Wall could not be created because of invalid geometry of edges."); return null; } - return new Wall() - {Construction = construction, Location = aPlanarSurface}; + //Create the openings + List openings = new List(); + + if (internalEdges != null && internalEdges.Count() > 0) + { + foreach (ICurve openingCurve in internalEdges) + if (openingCurve != null) + openings.Add(new oM.Physical.Elements.Void() { Location = Geometry.Create.PlanarSurface(openingCurve) }); + } + + return Wall(location, construction, openings); } /***************************************************/ diff --git a/Structure_Engine/Create/Physical/Floor.cs b/Structure_Engine/Create/Physical/Floor.cs index 30c86864a..e123c7955 100644 --- a/Structure_Engine/Create/Physical/Floor.cs +++ b/Structure_Engine/Create/Physical/Floor.cs @@ -63,7 +63,7 @@ public static BHPE.Floor Floor(Panel panel) surfaceElement.Name = name; if (panel.FindFragment() != null || panel.Property.FindFragment() != null) { - Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); + Base.Compute.RecordWarning("The panel has reinforcement, but embedding this information in the physical element is not yet implemented."); } return surfaceElement; From dc6ff97b84633c222ff33b0ae4416a4e6f7ee76c Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Tue, 2 Aug 2022 17:48:34 -0400 Subject: [PATCH 13/17] null checks, error messages, redundant methods. --- Structure_Engine/Create/Physical/Floor.cs | 3 ++ Structure_Engine/Create/Physical/ISurface.cs | 17 ++++++-- Structure_Engine/Create/Physical/Wall.cs | 5 ++- Structure_Engine/Query/Construction.cs | 46 +++----------------- 4 files changed, 27 insertions(+), 44 deletions(-) diff --git a/Structure_Engine/Create/Physical/Floor.cs b/Structure_Engine/Create/Physical/Floor.cs index e123c7955..9508b1320 100644 --- a/Structure_Engine/Create/Physical/Floor.cs +++ b/Structure_Engine/Create/Physical/Floor.cs @@ -48,13 +48,16 @@ public static BHPE.Floor Floor(Panel panel) { if (panel.IsNull()) return null; + //Get Construction ISurfaceProperty prop = panel.Property; BHPC.Construction construction = null; + if (prop == null) Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); else construction = panel.Property.IConstruction(); + //Get Location PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/ISurface.cs index 7331555aa..b66fda518 100644 --- a/Structure_Engine/Create/Physical/ISurface.cs +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -32,7 +32,9 @@ using BH.oM.Structure.Reinforcement; using BH.oM.Structure.Fragments; using BH.Engine.Base; +using BH.Engine.Geometry; using BH.oM.Quantities.Attributes; +using System; namespace BH.Engine.Structure { @@ -51,8 +53,8 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs return null; if (structuralUsage == StructuralUsage2D.Undefined) { - object result = panel.Property.PropertyValue("PanelType"); - if (result != null) + object result = panel.Property?.PropertyValue("PanelType"); + if (result != null ) { structuralUsage = (StructuralUsage2D)result; } @@ -65,11 +67,18 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs case StructuralUsage2D.DropPanel: case StructuralUsage2D.PileCap: case StructuralUsage2D.Slab: + return Floor(panel); case StructuralUsage2D.Undefined: default: - return Floor(panel); + { + if (Math.Abs(panel.Normal().DotProduct(Vector.ZAxis)) == 1) + return Floor(panel); + else if (panel.Normal().DotProduct(Vector.ZAxis) == 0) + return Wall(panel); + else + return null; + } } } - /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/Wall.cs b/Structure_Engine/Create/Physical/Wall.cs index 0133f13aa..f81826c8b 100644 --- a/Structure_Engine/Create/Physical/Wall.cs +++ b/Structure_Engine/Create/Physical/Wall.cs @@ -48,13 +48,16 @@ public static BHPE.Wall Wall(Panel panel) { if (panel.IsNull()) return null; + //Get Construction ISurfaceProperty prop = panel.Property; BHPC.Construction construction = null; + if (prop == null) Base.Compute.RecordWarning("The panel does not contain a surfaceProperty. Can not extract profile or material"); else construction = panel.Property.IConstruction(); + //Get Location PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); @@ -63,7 +66,7 @@ public static BHPE.Wall Wall(Panel panel) surfaceElement.Name = name; if (panel.FindFragment() != null || panel.Property.FindFragment() != null) { - Base.Compute.RecordWarning("The panel has reinforcement, but this is not yet implemented."); + Base.Compute.RecordWarning("The panel has reinforcement, but embedding this information in the physical element is not yet implemented."); } return surfaceElement; diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index 429a8c783..892567a2a 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -65,47 +65,15 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) layers.Add(new oM.Physical.Constructions.Layer() {Material = comp.Materials[i], Thickness = volume * comp.Ratios[i], Name = comp.Materials[i].Name}); if (volume < thickness) - layers.Add(new oM.Physical.Constructions.Layer() - {Material = null, Thickness = thickness - volume, Name = "void"}); - return Physical.Create.Construction(surfaceProperty.Name, layers); - } - - /***************************************************/ - /**** Private Methods ****/ - /***************************************************/ - private static oM.Physical.Materials.Material GetMaterial(this ISurfaceProperty property) - { - //Set Material - oM.Physical.Materials.Material material = null; - if (property.Material != null) - { - string matName = property.Material.DescriptionOrName(); - material = Physical.Create.Material(matName, new List{property.Material}); - } - else - { - Base.Compute.RecordWarning("Material from the SurfaceProperty is null."); - } - - return material; - } - - /***************************************************/ - private static oM.Physical.Materials.Material GetMaterial(this oM.Structure.SurfaceProperties.Layer layer) - { - //Set Material - oM.Physical.Materials.Material material = null; - if (layer.Material != null) - { - string matName = layer.Material.DescriptionOrName(); - material = Physical.Create.Material(matName, new List{layer.Material}); - } - else { - Base.Compute.RecordWarning("Material from the Layer is null."); + layers.Add(new oM.Physical.Constructions.Layer() { + Material = null, + Thickness = thickness - volume, + Name = "void" + }); + Base.Compute.RecordNote("Void space was found in the makeup of the SurfaceProperty; This is often the result of ribbed or waffle properties, or layered properties with null materials. A void layer has been added to the Construction to maintain the total thickness."); } - - return material; + return Physical.Create.Construction(surfaceProperty.Name, layers); } } } \ No newline at end of file From 2347fe3983ed6faf885ddd02c2eac4ed5dec200d Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Wed, 3 Aug 2022 10:17:14 -0400 Subject: [PATCH 14/17] Pawel's comments consistent defaults for wall and floor formatting Tolerance for detecting wall/floor from panel orientation null check for structuralUsage specific method for Layered surface props to respect order of void layers --- Physical_Engine/Create/Floor.cs | 13 +++++++--- Physical_Engine/Query/VolumePerArea.cs | 6 +++++ Structure_Engine/Create/Physical/Floor.cs | 4 +++ Structure_Engine/Create/Physical/ISurface.cs | 11 ++++++--- Structure_Engine/Create/Physical/Wall.cs | 4 +++ Structure_Engine/Query/Construction.cs | 26 ++++++++++++++++++-- 6 files changed, 55 insertions(+), 9 deletions(-) diff --git a/Physical_Engine/Create/Floor.cs b/Physical_Engine/Create/Floor.cs index 0bac30f6f..7b145bd08 100644 --- a/Physical_Engine/Create/Floor.cs +++ b/Physical_Engine/Create/Floor.cs @@ -44,7 +44,14 @@ public static partial class Create public static Floor Floor(oM.Geometry.ISurface location, IConstruction construction, List openings = null, Offset offset = Offset.Undefined, string name = "") { openings = openings ?? new List(); - return new Floor{Location = location, Construction = construction, Openings = openings, Offset = offset, Name = name}; + return new Floor + { + Location = location, + Construction = construction, + Openings = openings, + Offset = offset, + Name = name + }; } [Description("Creates physical floor based on given construction and external edges.")] @@ -62,7 +69,7 @@ public static Floor Floor(Construction construction, ICurve edges) [Input("edges", "External edges of the floor (Profile - planar closed curve).")] [Input("internalEdges", "Internal edges of openings.")] [Output("floor", "A physical floor.")] - public static Floor Floor(Construction construction, ICurve edges, IEnumerable internalEdges) + public static Floor Floor(Construction construction, ICurve edges, IEnumerable internalEdges = null) { if (construction == null || edges == null) { @@ -85,7 +92,7 @@ public static Floor Floor(Construction construction, ICurve edges, IEnumerable x.Material != null).Sum(x => x.Thickness); } + /***************************************************/ + /**** Private Methods ****/ + /***************************************************/ + private static double VolumePerArea(this object construction) { return 0; //Fallback method diff --git a/Structure_Engine/Create/Physical/Floor.cs b/Structure_Engine/Create/Physical/Floor.cs index 9508b1320..316f0ac6b 100644 --- a/Structure_Engine/Create/Physical/Floor.cs +++ b/Structure_Engine/Create/Physical/Floor.cs @@ -61,9 +61,13 @@ public static BHPE.Floor Floor(Panel panel) //Get Location PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); + + //Create the physical element BHPE.Floor surfaceElement = Physical.Create.Floor(construction, externalEdges, internalEdges); + string name = panel.Name ?? ""; surfaceElement.Name = name; + if (panel.FindFragment() != null || panel.Property.FindFragment() != null) { Base.Compute.RecordWarning("The panel has reinforcement, but embedding this information in the physical element is not yet implemented."); diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/ISurface.cs index b66fda518..e89d5e894 100644 --- a/Structure_Engine/Create/Physical/ISurface.cs +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -54,7 +54,7 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs if (structuralUsage == StructuralUsage2D.Undefined) { object result = panel.Property?.PropertyValue("PanelType"); - if (result != null ) + if (result is StructuralUsage2D ) { structuralUsage = (StructuralUsage2D)result; } @@ -71,12 +71,15 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs case StructuralUsage2D.Undefined: default: { - if (Math.Abs(panel.Normal().DotProduct(Vector.ZAxis)) == 1) + if (1 - Math.Abs(panel.Normal().DotProduct(Vector.ZAxis)) <= BH.oM.Geometry.Tolerance.Angle) return Floor(panel); - else if (panel.Normal().DotProduct(Vector.ZAxis) == 0) + else if (panel.Normal().DotProduct(Vector.ZAxis) <= BH.oM.Geometry.Tolerance.Angle) return Wall(panel); - else + else + { + Base.Compute.RecordError("Could not identify whether the panel is a Floor or a Wall based on the structural property, input structuralUsage, or panel orientation. Please specify a StructuralUsage2D."); return null; + } } } } diff --git a/Structure_Engine/Create/Physical/Wall.cs b/Structure_Engine/Create/Physical/Wall.cs index f81826c8b..5c354d6a6 100644 --- a/Structure_Engine/Create/Physical/Wall.cs +++ b/Structure_Engine/Create/Physical/Wall.cs @@ -61,9 +61,13 @@ public static BHPE.Wall Wall(Panel panel) //Get Location PolyCurve externalEdges = Geometry.Create.PolyCurve(panel.ExternalEdges.Select(x => x.Curve)); List internalEdges = panel.Openings.Select(opening => Geometry.Create.PolyCurve(opening.Edges.Select(edge => edge.Curve))).ToList(); + + //Create the physical element BHPE.Wall surfaceElement = Physical.Create.Wall(construction, externalEdges, internalEdges); + string name = panel.Name ?? ""; surfaceElement.Name = name; + if (panel.FindFragment() != null || panel.Property.FindFragment() != null) { Base.Compute.RecordWarning("The panel has reinforcement, but embedding this information in the physical element is not yet implemented."); diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index 892567a2a..dd5e4bff8 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -36,6 +36,7 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] @@ -46,7 +47,21 @@ public static Construction IConstruction(this ISurfaceProperty surfaceProperty) return Construction(surfaceProperty as dynamic); } - //Write specific methods here if building a Construction from a SurfaceProperty via MaterialComposition is not valid + /***************************************************/ + + [Description("Creates a physical Construction from a structural Layered SurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] + public static Construction Construction(this Layered surfaceProperty) + { + if (surfaceProperty.IsNull()) + return null; + + List layers = surfaceProperty.Layers.Select(x => Physical.Create.Layer(x.Name, Physical.Create.Material(x.Material) , x.Thickness)).ToList(); + + return Physical.Create.Construction(surfaceProperty.Name, layers); + } + /***************************************************/ /**** Fallback Method ****/ /***************************************************/ @@ -57,22 +72,29 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) { if (surfaceProperty.IsNull()) return null; + MaterialComposition comp = surfaceProperty.IMaterialComposition(); double volume = surfaceProperty.IVolumePerArea(); double thickness = surfaceProperty.ITotalThickness(); + List layers = new List(); + for (int i = 0; i < comp.Materials.Count(); i++) layers.Add(new oM.Physical.Constructions.Layer() {Material = comp.Materials[i], Thickness = volume * comp.Ratios[i], Name = comp.Materials[i].Name}); + if (volume < thickness) { - layers.Add(new oM.Physical.Constructions.Layer() { + layers.Add(new oM.Physical.Constructions.Layer() + { Material = null, Thickness = thickness - volume, Name = "void" }); + Base.Compute.RecordNote("Void space was found in the makeup of the SurfaceProperty; This is often the result of ribbed or waffle properties, or layered properties with null materials. A void layer has been added to the Construction to maintain the total thickness."); } + return Physical.Create.Construction(surfaceProperty.Name, layers); } } From f08efe1dae00cf75efd54362fdf90bff1b1d811b Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Wed, 3 Aug 2022 10:50:06 -0400 Subject: [PATCH 15/17] fixing BHoMBot's weird formatting --- Physical_Engine/Create/Floor.cs | 8 +++- Physical_Engine/Create/Wall.cs | 38 ++++++++++++++++--- Physical_Engine/Query/MaterialComposition.cs | 15 ++++++++ Physical_Engine/Query/SolidVolume.cs | 11 +++++- Physical_Engine/Query/VolumePerArea.cs | 8 +++- .../Physical/ConstantFramingProperty.cs | 8 +++- Structure_Engine/Create/Physical/Floor.cs | 5 ++- .../Create/Physical/FramingElement.cs | 10 ++++- Structure_Engine/Create/Physical/ISurface.cs | 6 +++ Structure_Engine/Create/Physical/Wall.cs | 4 +- Structure_Engine/Query/Construction.cs | 14 +++++-- 11 files changed, 112 insertions(+), 15 deletions(-) diff --git a/Physical_Engine/Create/Floor.cs b/Physical_Engine/Create/Floor.cs index 7b145bd08..60d2b7e75 100644 --- a/Physical_Engine/Create/Floor.cs +++ b/Physical_Engine/Create/Floor.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System.ComponentModel; using BH.oM.Physical.Constructions; using BH.oM.Base.Attributes; @@ -34,6 +35,7 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates a physical floor element. For elements for structral analytical applications look at BH.oM.Structure.Elements.Panel. For elements for environmental analytical applications look at BH.oM.Environments.Elements.Panel.")] [Input("location", "Location surface which represents the outer geometry of the floor. Should not contain any openings.")] [Input("construction", "Construction representing the thickness and materiality of the floor.")] @@ -54,6 +56,8 @@ public static Floor Floor(oM.Geometry.ISurface location, IConstruction construct }; } + /***************************************************/ + [Description("Creates physical floor based on given construction and external edges.")] [Input("construction", "Construction of the floor.")] [Input("edges", "External edges of the floor (Profile - planar closed curve).")] @@ -64,6 +68,7 @@ public static Floor Floor(Construction construction, ICurve edges) } /***************************************************/ + [Description("Creates physical floor based on given construction, external and internal edges.")] [Input("construction", "Construction of the floor.")] [Input("edges", "External edges of the floor (Profile - planar closed curve).")] @@ -97,6 +102,7 @@ public static Floor Floor(Construction construction, ICurve edges, IEnumerable. */ + using System.Collections.Generic; using System.Linq; using BH.oM.Physical.Constructions; @@ -35,6 +36,7 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates physical wall based on given construction, bottom curve and height.")] [Input("construction", "Construction of the wall.")] [Input("bottomEdge", "Curve representing bottom edge of the wall.")] @@ -55,14 +57,21 @@ public static Wall Wall(IConstruction construction, ICurve bottomEdge, double he } ICurve aICurve = bottomEdge.ITranslate(Geometry.Create.Vector(0, 0, height)).IFlip(); + Line aLine_1 = Geometry.Create.Line(bottomEdge.IEndPoint(), aICurve.IStartPoint()); Line aLine_2 = Geometry.Create.Line(aICurve.IEndPoint(), bottomEdge.IStartPoint()); + PolyCurve aPolyCurve = Geometry.Create.PolyCurve(new ICurve[]{bottomEdge, aLine_1, aICurve, aLine_2}); - return new Wall() - {Construction = construction, Location = Geometry.Create.PlanarSurface(aPolyCurve)}; + + return new Wall + { + Construction = construction, + Location = Geometry.Create.PlanarSurface(aPolyCurve) + }; } /***************************************************/ + [Description("Creates a physical Wall element. For elements for structral analytical applications look at BH.oM.Structure.Elements.Panel. For elements for environmental analytical applications look at BH.oM.Environments.Elements.Panel.")] [Input("line", "Base line of the wall.")] [Input("height", "Height of the wall.")] @@ -79,16 +88,25 @@ public static Wall Wall(Line line, double height, IConstruction construction, Of } Polyline boundary = new Polyline(); + Vector move = Vector.ZAxis * height; + boundary.ControlPoints.Add(line.Start); boundary.ControlPoints.Add(line.End); boundary.ControlPoints.Add(line.End + move); boundary.ControlPoints.Add(line.Start + move); boundary.ControlPoints.Add(line.Start); - return new Wall{Location = Geometry.Create.PlanarSurface(boundary), Construction = construction, Offset = offset, Name = name}; + + return new Wall + { + Location = Geometry.Create.PlanarSurface(boundary), + Construction = construction, + Offset = offset, Name = name + }; } /***************************************************/ + [Description("Creates physical wall object.")] [Input("construction", "Construction of the wall.")] [Input("edges", "External edges of the wall (Profile - planar closed curve).")] @@ -124,6 +142,7 @@ public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable openings = null, Offset offset = Offset.Undefined, string name = "") { openings = openings ?? new List(); - return new Wall{Location = location, Construction = construction, Openings = openings, Offset = offset, Name = name}; + return new Wall + { + Location = location, + Construction = construction, + Openings = openings, + Offset = offset, + Name = name + }; } /***************************************************/ + [Description("Creates physical wall object.")] [Input("construction", "Construction of the wall.")] [Input("edges", "External edges of the wall (Profile - planar closed curve).")] @@ -146,6 +173,7 @@ public static Wall Wall(IConstruction construction, ICurve edges) { return Wall(construction, edges, null); } - /***************************************************/ + + /***************************************************/ } } \ No newline at end of file diff --git a/Physical_Engine/Query/MaterialComposition.cs b/Physical_Engine/Query/MaterialComposition.cs index e39c1717a..e56c963fc 100644 --- a/Physical_Engine/Query/MaterialComposition.cs +++ b/Physical_Engine/Query/MaterialComposition.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System; using System.Linq; using System.Collections.Generic; @@ -38,6 +39,7 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Gets all the Materials a IFramingElement is composed of and in which ratios.")] [Input("framingElement", "The IFramingElement to get the MaterialComposition from.")] [Output("materialComposition", "The kind of matter the IFramingElement is composed of and in which ratios.")] @@ -59,6 +61,7 @@ public static MaterialComposition MaterialComposition(this IFramingElement frami } /***************************************************/ + [Description("Gets all the Materials a ISurface is composed of and in which ratios.")] [Input("surface", "The ISurface to get the MaterialComposition from.")] [Output("materialComposition", "The kind of matter the ISurface is composed of and in which ratios.")] @@ -80,6 +83,7 @@ public static MaterialComposition MaterialComposition(this ISurface surface) } /***************************************************/ + [Description("Gets all the Materials an IOpening is composed of and in which ratios.")] [Input("opening", "The IOpening to get the MaterialComposition from.")] [Output("materialComposition", "The kind of matter the IOpening is composed of and in which ratios.")] @@ -118,6 +122,7 @@ public static MaterialComposition MaterialComposition(this IOpening opening) } /***************************************************/ + [Description("Gets all the Materials a SolidBulk is composed of and in which ratios.")] [Input("solidBulk", "The SolidBulk to get the MaterialComposition from.")] [Output("materialComposition", "The kind of matter the SolidBulk is composed of and in which ratios.", typeof(Ratio))] @@ -138,6 +143,7 @@ public static MaterialComposition MaterialComposition(this SolidBulk solidBulk) } /***************************************************/ + [Description("Gets all the Materials a ExplicitBulk is composed of and in which ratios.")] [Input("explicitBulk", "The ExplicitBulk to get the MaterialComposition from.")] [Output("materialComposition", "The kind of matter the ExplicitBulk is composed of and in which ratios.", typeof(Ratio))] @@ -160,6 +166,7 @@ public static MaterialComposition MaterialComposition(this ExplicitBulk explicit /******************************************************/ /**** IConstruction Methods ****/ /******************************************************/ + [Description("Gets all the Materials a ExplicitBulk is composed of and in which ratios.")] [Input("prop", "The ExplicitBulk to get the MaterialComposition from.")] [Output("materialComposition", "The kind of matter the ExplicitBulk is composed of and in which ratios.", typeof(Ratio))] @@ -171,6 +178,7 @@ public static MaterialComposition IMaterialComposition(this IConstruction prop) /******************************************************/ /**** IFramingElementProperty Methods ****/ /******************************************************/ + private static MaterialComposition IMaterialComposition(this IFramingElementProperty prop) { return MaterialComposition(prop as dynamic); @@ -179,6 +187,7 @@ private static MaterialComposition IMaterialComposition(this IFramingElementProp /******************************************************/ /**** IOpening Methods ****/ /******************************************************/ + private static MaterialComposition IMaterialComposition(this IOpening prop) { return MaterialComposition(prop as dynamic); @@ -187,6 +196,7 @@ private static MaterialComposition IMaterialComposition(this IOpening prop) /***************************************************/ /**** Private Methods ****/ /***************************************************/ + private static MaterialComposition MaterialComposition(this Construction prop) { if (prop.Layers.Any(x => x.Material == null)) @@ -201,12 +211,14 @@ private static MaterialComposition MaterialComposition(this Construction prop) /***************************************************/ /**** Private Fallback Methods ****/ /***************************************************/ + private static MaterialComposition MaterialComposition(this IConstruction prop) { throw new NotImplementedException(); } /***************************************************/ + private static MaterialComposition MaterialComposition(this ConstantFramingProperty prop) { if (prop.Material == null) @@ -221,9 +233,12 @@ private static MaterialComposition MaterialComposition(this ConstantFramingPrope /***************************************************/ /**** Private Fallback Methods ****/ /***************************************************/ + private static MaterialComposition MaterialComposition(this IFramingElementProperty prop) { throw new NotImplementedException(); } + + /***************************************************/ } } \ No newline at end of file diff --git a/Physical_Engine/Query/SolidVolume.cs b/Physical_Engine/Query/SolidVolume.cs index 733fd9f4f..66b7cb179 100644 --- a/Physical_Engine/Query/SolidVolume.cs +++ b/Physical_Engine/Query/SolidVolume.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System; using System.Linq; using System.Collections.Generic; @@ -41,6 +42,7 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Gets an IFramingElement's solid volume from the average area and length.")] [Input("framingElement", "the IFramingElement to get the volume from.")] [Output("volume", "The IFramingElement's solid material volume.", typeof(Volume))] @@ -62,6 +64,7 @@ public static double SolidVolume(this IFramingElement framingElement) } /***************************************************/ + [Description("Returns an ISurface's solid volume based on thickness and area." + "ISurfaces with offsets other than Centre are not fully supported.")] [Input("surface", "the ISurface to get the volume from.")] [Output("volume", "The ISurface's solid material volume.", typeof(Volume))] @@ -87,6 +90,7 @@ public static double SolidVolume(this oM.Physical.Elements.ISurface surface) } /***************************************************/ + [Description("Return the total volume of SolidBulk.")] [Input("solidBulk", "Solid geometric elements that have a MaterialComposition.")] [Output("volume", "The combined volume of SolidBulk.", typeof(Volume))] @@ -109,6 +113,7 @@ public static double SolidVolume(this SolidBulk solidBulk) } /***************************************************/ + [Description("Return the total volume of ExplicitBulk.")] [Input("explicitBulk", "Elements containing Volume and MaterialComposition properties.")] [Output("volume", "The combined volume of ExplicitBulk.", typeof(Volume))] @@ -143,11 +148,14 @@ public static double SolidVolume(this IOpening opening) double area = opening.IArea(); double thickness = 0; + if (opening is Window) thickness = (opening as Window).Construction.IThickness(); else if (opening is Door) thickness = (opening as Door).Construction.IThickness(); + double solidVolume = area * thickness; + if (solidVolume <= 0) { Engine.Base.Compute.RecordError("Solid volume cannot be calculated for element of type :" + opening.GetType() + ". Returning zero volume."); @@ -156,6 +164,7 @@ public static double SolidVolume(this IOpening opening) return solidVolume; } - /***************************************************/ + + /***************************************************/ } } \ No newline at end of file diff --git a/Physical_Engine/Query/VolumePerArea.cs b/Physical_Engine/Query/VolumePerArea.cs index 6fc7ba822..70314e23e 100644 --- a/Physical_Engine/Query/VolumePerArea.cs +++ b/Physical_Engine/Query/VolumePerArea.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System; using System.Collections.Generic; using System.Linq; @@ -36,6 +37,7 @@ public static partial class Query /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Gets the average thickness of the property for the purpose of calculating solid volume.")] [Input("construction", "The property to evaluate the average thickness of.")] [Output("volumePerArea", "The average thickness of the property for the purpose of calculating solid volume.", typeof(Length))] @@ -59,18 +61,22 @@ public static double VolumePerArea(this Construction construction) { if (construction == null) return 0; + if (construction.Layers.Any(x => x.Material == null)) Base.Compute.RecordWarning("At least one Material in a Construction was null. VolumePerArea excludes this layer, assuming it is void space."); + return construction.Layers.Where(x => x.Material != null).Sum(x => x.Thickness); } /***************************************************/ - /**** Private Methods ****/ + /**** Private Methods ****/ /***************************************************/ private static double VolumePerArea(this object construction) { return 0; //Fallback method } + + /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/ConstantFramingProperty.cs b/Structure_Engine/Create/Physical/ConstantFramingProperty.cs index 62a029730..9042ab107 100644 --- a/Structure_Engine/Create/Physical/ConstantFramingProperty.cs +++ b/Structure_Engine/Create/Physical/ConstantFramingProperty.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System; using System.Linq; using System.Collections.Generic; @@ -36,6 +37,7 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates a ConstantFramingProperty from a ISectionProperty and orientation angle. Extracts the SectionProfile (if existing) and Structural MaterialFragment and creates a physical material with the same name.")] [Input("sectionProperty", "Structural section property to extract profile and material from. For explicit sections lacking a profile only the material will get extracted.")] [Input("orientationAngle", "Defines the sections rotation around its own axis.", typeof(Angle))] @@ -45,11 +47,13 @@ public static ConstantFramingProperty ConstantFramingProperty(ISectionProperty s { if (sectionProperty.IsNull()) return null; + IProfile profile = null; if (sectionProperty is IGeometricalSection) profile = (sectionProperty as IGeometricalSection).SectionProfile; else Base.Compute.RecordWarning("Was not able to extract any section profile."); + oM.Physical.Materials.Material material = null; if (sectionProperty.Material != null) { @@ -62,8 +66,10 @@ public static ConstantFramingProperty ConstantFramingProperty(ISectionProperty s } name = string.IsNullOrEmpty(name) ? sectionProperty.Name : name; + return Physical.Create.ConstantFramingProperty(profile, material, orientationAngle, name); } - /***************************************************/ + + /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/Floor.cs b/Structure_Engine/Create/Physical/Floor.cs index 316f0ac6b..a63fc84b5 100644 --- a/Structure_Engine/Create/Physical/Floor.cs +++ b/Structure_Engine/Create/Physical/Floor.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System.Collections.Generic; using System.Linq; using BH.oM.Structure.Elements; @@ -41,6 +42,7 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates a physical Floor from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel.")] [Input("panel", "The Panel to use as the base for the framing element.")] [Output("floor", "The created physical Floor based on the Panel element provided.")] @@ -75,6 +77,7 @@ public static BHPE.Floor Floor(Panel panel) return surfaceElement; } - /***************************************************/ + + /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/FramingElement.cs b/Structure_Engine/Create/Physical/FramingElement.cs index 72d8e09ea..cc766ccb7 100644 --- a/Structure_Engine/Create/Physical/FramingElement.cs +++ b/Structure_Engine/Create/Physical/FramingElement.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System.Collections.Generic; using BH.oM.Structure.Elements; using BH.oM.Structure.SectionProperties; @@ -37,6 +38,7 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates a physical IFramingElement from a Bar. The framing element will be assigned a ConstantFramingProperty based on the SectionProperty of the Bar and have a type based on the structural usage.")] [Input("bar", "The Bar to use as the base for the framing element.")] [Input("structuralUsage", "Used to determine which type of framing element that should be constructed.")] @@ -45,15 +47,19 @@ public static BHPE.IFramingElement FramingElement(Bar bar, StructuralUsage1D str { if (bar.IsNull()) return null; + ISectionProperty prop = bar.SectionProperty; BHPP.ConstantFramingProperty framingProp = null; if (prop == null) Base.Compute.RecordWarning("The bar does not contain a sectionProperty. Can not extract profile or material"); else framingProp = Create.ConstantFramingProperty(bar.SectionProperty, bar.OrientationAngle); + Line location = bar.Centreline(); string name = bar.Name ?? ""; + BHPE.IFramingElement framingElement; + switch (structuralUsage) { case StructuralUsage1D.Column: @@ -78,6 +84,7 @@ public static BHPE.IFramingElement FramingElement(Bar bar, StructuralUsage1D str if (bar.HasReinforcement()) { List reinforcement = bar.ReinforcingBars(); + if (reinforcement.Count != 0) { framingElement.Fragments.Add(new ReinforcementFragment{ReinforcingBars = reinforcement}); @@ -86,6 +93,7 @@ public static BHPE.IFramingElement FramingElement(Bar bar, StructuralUsage1D str return framingElement; } - /***************************************************/ + + /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/ISurface.cs b/Structure_Engine/Create/Physical/ISurface.cs index e89d5e894..486656681 100644 --- a/Structure_Engine/Create/Physical/ISurface.cs +++ b/Structure_Engine/Create/Physical/ISurface.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System.Collections.Generic; using System.Linq; using BH.oM.Structure.Elements; @@ -43,6 +44,7 @@ public static partial class Create /***************************************************/ /**** Public Methods ****/ /***************************************************/ + [Description("Creates a physical surface element from a Panel. The Floor will be assigned a Construction based on the SurfaceProperty of the Panel, and the PanelType of the SufaceProperty will determine what type of surface element to create, unless overridden.")] [Input("panel", "The Panel to use as the base for the framing element.")] [Input("structuralUsage", "The type of surface element to create. if Undefined, the type will be based on the panel's SurfaceProperty.")] @@ -51,9 +53,11 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs { if (panel.IsNull()) return null; + if (structuralUsage == StructuralUsage2D.Undefined) { object result = panel.Property?.PropertyValue("PanelType"); + if (result is StructuralUsage2D ) { structuralUsage = (StructuralUsage2D)result; @@ -83,5 +87,7 @@ public static BHPE.ISurface ISurface(Panel panel, StructuralUsage2D structuralUs } } } + + /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Create/Physical/Wall.cs b/Structure_Engine/Create/Physical/Wall.cs index 5c354d6a6..aef0e3028 100644 --- a/Structure_Engine/Create/Physical/Wall.cs +++ b/Structure_Engine/Create/Physical/Wall.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System.Collections.Generic; using System.Linq; using BH.oM.Structure.Elements; @@ -75,6 +76,7 @@ public static BHPE.Wall Wall(Panel panel) return surfaceElement; } - /***************************************************/ + + /***************************************************/ } } \ No newline at end of file diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index dd5e4bff8..371ca0e52 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -19,6 +19,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ + using System; using System.Linq; using System.Collections.Generic; @@ -65,6 +66,7 @@ public static Construction Construction(this Layered surfaceProperty) /***************************************************/ /**** Fallback Method ****/ /***************************************************/ + [Description("Creates a physical Construction from a structural ISurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] @@ -80,12 +82,16 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) List layers = new List(); for (int i = 0; i < comp.Materials.Count(); i++) - layers.Add(new oM.Physical.Constructions.Layer() - {Material = comp.Materials[i], Thickness = volume * comp.Ratios[i], Name = comp.Materials[i].Name}); + layers.Add(new oM.Physical.Constructions.Layer + { + Material = comp.Materials[i], + Thickness = volume * comp.Ratios[i], + Name = comp.Materials[i].Name + }); if (volume < thickness) { - layers.Add(new oM.Physical.Constructions.Layer() + layers.Add(new oM.Physical.Constructions.Layer { Material = null, Thickness = thickness - volume, @@ -97,5 +103,7 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) return Physical.Create.Construction(surfaceProperty.Name, layers); } + + /***************************************************/ } } \ No newline at end of file From 7cac90c71e46db4f3c8bbb16849bf6f2f681a76f Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 4 Aug 2022 12:03:46 -0400 Subject: [PATCH 16/17] Mike's Comments Better null-checking in MaterialComposition and VolumePerArea Use VolumePerArea for Windows and Doors New Construction(ConstantThickness) method Clarify Note message when adding voids (for Ribbed and Waffle slabs) --- Physical_Engine/Query/MaterialComposition.cs | 11 ++++++- Physical_Engine/Query/SolidVolume.cs | 4 +-- Physical_Engine/Query/VolumePerArea.cs | 12 ++++++-- Structure_Engine/Query/Construction.cs | 30 ++++++++++++++++++-- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Physical_Engine/Query/MaterialComposition.cs b/Physical_Engine/Query/MaterialComposition.cs index e56c963fc..3d88230aa 100644 --- a/Physical_Engine/Query/MaterialComposition.cs +++ b/Physical_Engine/Query/MaterialComposition.cs @@ -199,9 +199,18 @@ private static MaterialComposition IMaterialComposition(this IOpening prop) private static MaterialComposition MaterialComposition(this Construction prop) { + if (prop == null) + { + Compute.RecordError("Cannot evaluate MaterialComposition because the Construction was null."); + return null; + } + + if (prop.Layers.IsNullOrEmpty()) //.IsNullOrEmpty raises it's own error + return null; + if (prop.Layers.Any(x => x.Material == null)) { - Engine.Base.Compute.RecordWarning("At least one Material in a Layered surface property was null. MaterialConstruction excludes this layer, assuming it is void space."); + Compute.RecordWarning("At least one Material in a Layered surface property was null. MaterialConstruction excludes this layer, assuming it is void space."); } IEnumerable layers = prop.Layers.Where(x => x.Material != null); diff --git a/Physical_Engine/Query/SolidVolume.cs b/Physical_Engine/Query/SolidVolume.cs index 66b7cb179..3ce8796fb 100644 --- a/Physical_Engine/Query/SolidVolume.cs +++ b/Physical_Engine/Query/SolidVolume.cs @@ -150,9 +150,9 @@ public static double SolidVolume(this IOpening opening) double thickness = 0; if (opening is Window) - thickness = (opening as Window).Construction.IThickness(); + thickness = (opening as Window).Construction.IVolumePerArea(); else if (opening is Door) - thickness = (opening as Door).Construction.IThickness(); + thickness = (opening as Door).Construction.IVolumePerArea(); double solidVolume = area * thickness; diff --git a/Physical_Engine/Query/VolumePerArea.cs b/Physical_Engine/Query/VolumePerArea.cs index 70314e23e..a57bb123c 100644 --- a/Physical_Engine/Query/VolumePerArea.cs +++ b/Physical_Engine/Query/VolumePerArea.cs @@ -29,6 +29,7 @@ using BH.oM.Base.Attributes; using BH.oM.Quantities.Attributes; using System.ComponentModel; +using BH.Engine.Base; namespace BH.Engine.Physical { @@ -45,7 +46,7 @@ public static double IVolumePerArea(this IConstruction construction) { if (construction == null) { - BH.Engine.Base.Compute.RecordError("Cannot query the thickness of a null construction."); + Compute.RecordError("Cannot query the thickness of a null construction."); return 0; } @@ -60,10 +61,16 @@ public static double IVolumePerArea(this IConstruction construction) public static double VolumePerArea(this Construction construction) { if (construction == null) + { + Compute.RecordError("Could not evaluate the VolumePerArea of the Construction because it was null."); + return 0; + } + + if (construction.Layers.IsNullOrEmpty()) // .IsNullOrEmpty() raises it's own error. return 0; if (construction.Layers.Any(x => x.Material == null)) - Base.Compute.RecordWarning("At least one Material in a Construction was null. VolumePerArea excludes this layer, assuming it is void space."); + Compute.RecordWarning("At least one Material in a Construction was null. VolumePerArea excludes this layer, assuming it is void space."); return construction.Layers.Where(x => x.Material != null).Sum(x => x.Thickness); } @@ -74,6 +81,7 @@ public static double VolumePerArea(this Construction construction) private static double VolumePerArea(this object construction) { + Compute.RecordError("Could not evaluate the VolumePerArea of the Construction because that type of Construction is not supported by the VolumePerArea method."); return 0; //Fallback method } diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index 371ca0e52..3e7a2c361 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -29,6 +29,7 @@ using BH.oM.Structure.SurfaceProperties; using BH.oM.Quantities.Attributes; using BH.oM.Physical.Materials; +using BH.oM.Structure.MaterialFragments; namespace BH.Engine.Structure { @@ -50,6 +51,21 @@ public static Construction IConstruction(this ISurfaceProperty surfaceProperty) /***************************************************/ + [Description("Creates a physical Construction from a structural ConstantThickness SurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] + [Input("surfaceProperty", "Structural surface property to convert.")] + [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] + public static Construction Construction(this ConstantThickness surfaceProperty) + { + if (surfaceProperty.IsNull()) + return null; + + oM.Physical.Constructions.Layer layer = Physical.Create.Layer(surfaceProperty.Name, Physical.Create.Material(surfaceProperty.Material), surfaceProperty.Thickness); + + return Physical.Create.Construction(surfaceProperty.Name, new List { layer } ); + } + + /***************************************************/ + [Description("Creates a physical Construction from a structural Layered SurfaceProperty. Extracts the Structural MaterialFragment and creates a physical material with the same name.")] [Input("surfaceProperty", "Structural surface property to convert.")] [Output("construction", "The physical Construction to be used with ISurface such as Walls and Floors.")] @@ -58,7 +74,7 @@ public static Construction Construction(this Layered surfaceProperty) if (surfaceProperty.IsNull()) return null; - List layers = surfaceProperty.Layers.Select(x => Physical.Create.Layer(x.Name, Physical.Create.Material(x.Material) , x.Thickness)).ToList(); + List layers = surfaceProperty.Layers.Select(x => Physical.Create.Layer(x.Name, Material(x.Material), x.Thickness)).ToList(); return Physical.Create.Construction(surfaceProperty.Name, layers); } @@ -98,12 +114,22 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) Name = "void" }); - Base.Compute.RecordNote("Void space was found in the makeup of the SurfaceProperty; This is often the result of ribbed or waffle properties, or layered properties with null materials. A void layer has been added to the Construction to maintain the total thickness."); + Base.Compute.RecordNote("A void layer has been added to the Construction to maintain total thickness. Ribbed or Waffle properties, for example, are flattened, respecting volume, material composition, and total thickness. "); } return Physical.Create.Construction(surfaceProperty.Name, layers); } /***************************************************/ + /**** Private Methods ****/ + /***************************************************/ + + private static Material Material(IMaterialFragment material) + { + return material == null? null : Physical.Create.Material(material); + } + + /***************************************************/ + } } \ No newline at end of file From 655527872024e8abbfd5eacdc914d113e0c4bd37 Mon Sep 17 00:00:00 2001 From: Josef Taylor Date: Thu, 4 Aug 2022 13:19:26 -0400 Subject: [PATCH 17/17] null handling Removed a check that prevented getting MaterialComposition/VolumePerArea for Structural SurfaceProperties with no material, such as Layered properties. --- Physical_Engine/Query/MaterialComposition.cs | 6 ++++ Structure_Engine/Query/Construction.cs | 8 +++++ Structure_Engine/Query/MaterialComposition.cs | 31 ++++++++----------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Physical_Engine/Query/MaterialComposition.cs b/Physical_Engine/Query/MaterialComposition.cs index 3d88230aa..b8bc90e60 100644 --- a/Physical_Engine/Query/MaterialComposition.cs +++ b/Physical_Engine/Query/MaterialComposition.cs @@ -208,6 +208,12 @@ private static MaterialComposition MaterialComposition(this Construction prop) if (prop.Layers.IsNullOrEmpty()) //.IsNullOrEmpty raises it's own error return null; + if (prop.Layers.All(x => x.Material == null)) + { + Compute.RecordError("Cannote evaluate MaterialComposition because all of the materials are null."); + return null; + } + if (prop.Layers.Any(x => x.Material == null)) { Compute.RecordWarning("At least one Material in a Layered surface property was null. MaterialConstruction excludes this layer, assuming it is void space."); diff --git a/Structure_Engine/Query/Construction.cs b/Structure_Engine/Query/Construction.cs index 3e7a2c361..a5f921d9e 100644 --- a/Structure_Engine/Query/Construction.cs +++ b/Structure_Engine/Query/Construction.cs @@ -74,6 +74,9 @@ public static Construction Construction(this Layered surfaceProperty) if (surfaceProperty.IsNull()) return null; + if (surfaceProperty.Layers.All(x => x.Material == null)) + Base.Compute.RecordWarning("None of the layers in surfaceProperty have a valid material. A Construction has been created, but its materials will also be null."); + List layers = surfaceProperty.Layers.Select(x => Physical.Create.Layer(x.Name, Material(x.Material), x.Thickness)).ToList(); return Physical.Create.Construction(surfaceProperty.Name, layers); @@ -93,7 +96,12 @@ public static Construction Construction(this ISurfaceProperty surfaceProperty) MaterialComposition comp = surfaceProperty.IMaterialComposition(); double volume = surfaceProperty.IVolumePerArea(); + if (volume == 0) + Base.Compute.RecordWarning("the SurfaceProperty has zero volume - a Construction has been created, but will also have zero volume."); + double thickness = surfaceProperty.ITotalThickness(); + if (thickness == 0) + Base.Compute.RecordWarning("the SurfaceProperty has zero thickness - a Construction has been created, but will also have zero thickness."); List layers = new List(); diff --git a/Structure_Engine/Query/MaterialComposition.cs b/Structure_Engine/Query/MaterialComposition.cs index 8a8fb28e7..b4822c0ce 100644 --- a/Structure_Engine/Query/MaterialComposition.cs +++ b/Structure_Engine/Query/MaterialComposition.cs @@ -76,15 +76,9 @@ public static MaterialComposition MaterialComposition(this Bar bar) [Output("materialComposition", "The kind of matter the AreaElement is composed of.")] public static MaterialComposition MaterialComposition(this IAreaElement areaElement) { - if (areaElement.IIsNull()) + if (areaElement.IIsNull() || areaElement.Property.IsNull()) return null; - if (areaElement.Property == null || areaElement.Property.Material == null) - { - Engine.Base.Compute.RecordError("The areaElements MaterialComposition could not be calculated as no Material has been assigned."); - return null; - } - if (areaElement.FindFragment() != null) Engine.Base.Compute.RecordWarning("The areaElement has a PanelRebarIntent, which will not be included in the MaterialComposition. Please account for replacement of concrete volume with reinforcement externally."); @@ -155,9 +149,15 @@ public static MaterialComposition MaterialComposition(this ConcreteSection prope [Output("materialComposition", "The MaterialComposition of the SurfaceProperty.")] public static MaterialComposition MaterialComposition(this Layered property, ReinforcementDensity reinforcementDensity = null) { - if (property.IsNull()) + if (property.IsNull() || property.Layers.All(x => x.Material.IsNull())) return null; + if (property.Layers.All(x => x.Material == null)) //cull any null layers, raise a warning. + { + Base.Compute.RecordError("Cannote evaluate MaterialComposition because all of the materials are null."); + return null; + } + if (reinforcementDensity != null) Base.Compute.RecordWarning("the layered property has a ReinforcementDensity which will not be included in the MaterialComposition, because it is not known which layer to replace. Please account for this reinforcement externally."); @@ -176,10 +176,13 @@ public static MaterialComposition MaterialComposition(this Layered property, Rei [Output("materialComposition", "The MaterialComposition of the SurfaceProperty.")] public static MaterialComposition MaterialComposition(this CorrugatedDeck property, ReinforcementDensity reinforcementDensity = null) { + if (property.IsNull() || property.Material.IsNull()) + return null; + if (reinforcementDensity != null) Base.Compute.RecordWarning("the CorrugatedDeck property has a ReinforcementDensity which will not be included in the MaterialComposition, because it is inconceivable."); - return property.IsNull() ? null : (MaterialComposition)Physical.Create.Material(property.Material); + return (MaterialComposition)Physical.Create.Material(property.Material); } /***************************************************/ @@ -246,7 +249,7 @@ public static MaterialComposition IMaterialComposition(this ISectionProperty pro [Output("materialComposition", "The MaterialComposition of the SurfaceProperty.")] public static MaterialComposition IMaterialComposition(this ISurfaceProperty property, ReinforcementDensity reinforcementDensity = null) { - if (property.IsNull()) + if (property.IsNull()) //Specific MaterialComposition(SurfaceProp) methods must check for material null- some properties ignore the base material. return null; return MaterialComposition(property as dynamic, reinforcementDensity); @@ -273,10 +276,7 @@ private static MaterialComposition MaterialComposition(this ISectionProperty sec private static MaterialComposition MaterialComposition(this ISurfaceProperty property, ReinforcementDensity reinforcementDensity = null) { if (property.IsNull() || property.Material.IsNull()) - { - Engine.Base.Compute.RecordError("The MaterialComposition could not be queried as a Material was not assigned."); return null; - } if (reinforcementDensity == null) return (MaterialComposition)Physical.Create.Material(property.Material); @@ -319,11 +319,6 @@ private static MaterialComposition MaterialComposition(this IMaterialFragment ba /***************************************************/ - - - - - } }