Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure_Engine: Add wall(panel) and floor(panel) and SurfaceElement(panel) #2883

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Physical_Engine/Create/Floor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using System.ComponentModel;

using BH.oM.Physical.Constructions;
using BH.oM.Base.Attributes;
using BH.oM.Physical.Elements;
Expand All @@ -47,7 +46,6 @@ public static partial class Create
public static Floor Floor(oM.Geometry.ISurface location, IConstruction construction, List<IOpening> openings = null, Offset offset = Offset.Undefined, string name = "")
{
openings = openings ?? new List<IOpening>();

return new Floor
{
Location = location,
Expand All @@ -58,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).")]
Expand All @@ -74,35 +74,35 @@ 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<ICurve> internalEdges)
public static Floor Floor(Construction construction, ICurve edges, IEnumerable<ICurve> internalEdges = null)
{
if (construction == null || edges == null)
{
Base.Compute.RecordError("Physical Roof could not be created because some input data are null.");
Base.Compute.RecordError("Physical Floor could not be created because some input data are null.");
return null;
}

List<ICurve> 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 invalid geometry of edges.");
Base.Compute.RecordError("Physical Floor could not be created because of invalid geometry of edges.");
return null;
}

return new Floor()
//Create the openings
List<IOpening> openings = new List<IOpening>();

if (internalEdges != null && internalEdges.Count() > 0)
{
Construction = construction,
Location = aPlanarSurface
};
}
foreach (ICurve openingCurve in internalEdges)
if (openingCurve != null)
openings.Add(new Void { Location = Geometry.Create.PlanarSurface(openingCurve) });
}

return Floor(location, construction, openings);
}

/***************************************************/
}
}



}
48 changes: 22 additions & 26 deletions Physical_Engine/Create/Wall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

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;
Expand Down Expand Up @@ -61,15 +55,15 @@ 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();

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()
return new Wall
{
Construction = construction,
Location = Geometry.Create.PlanarSurface(aPolyCurve)
Expand All @@ -87,7 +81,7 @@ 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;
Expand All @@ -107,8 +101,7 @@ public static Wall Wall(Line line, double height, IConstruction construction, Of
{
Location = Geometry.Create.PlanarSurface(boundary),
Construction = construction,
Offset = offset,
Name = name
Offset = offset, Name = name
};
}

Expand All @@ -119,26 +112,33 @@ 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<ICurve> internalEdges)
public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable<ICurve> internalEdges = null)
JosefTaylor marked this conversation as resolved.
Show resolved Hide resolved
{
if (construction == null || edges == null)
{
Base.Compute.RecordError("Physical Wall could not be created because some input data are null.");
return null;
}

PlanarSurface aPlanarSurface = Geometry.Create.PlanarSurface(edges);
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 invalid geometry of edges.");
Base.Compute.RecordError("Physical Wall could not be created because of invalid geometry of edges.");
return null;
}

return new Wall()
//Create the openings
List<IOpening> openings = new List<IOpening>();

if (internalEdges != null && internalEdges.Count() > 0)
{
Construction = construction,
Location = aPlanarSurface
};
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);
}

/***************************************************/
Expand All @@ -153,7 +153,6 @@ public static Wall Wall(IConstruction construction, ICurve edges, IEnumerable<IC
public static Wall Wall(oM.Geometry.ISurface location, IConstruction construction, List<IOpening> openings = null, Offset offset = Offset.Undefined, string name = "")
{
openings = openings ?? new List<IOpening>();

return new Wall
{
Location = location,
Expand All @@ -174,10 +173,7 @@ public static Wall Wall(IConstruction construction, ICurve edges)
{
return Wall(construction, edges, null);
}

/***************************************************/
}
}



}
71 changes: 46 additions & 25 deletions Physical_Engine/Query/MaterialComposition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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;
Expand All @@ -41,12 +40,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;
Expand All @@ -57,17 +56,18 @@ 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;
Expand All @@ -78,14 +78,15 @@ 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;
Expand Down Expand Up @@ -122,9 +123,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)
Expand All @@ -137,14 +138,15 @@ 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)
Expand All @@ -157,13 +159,17 @@ 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 ****/
/******************************************************/

[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);
Expand Down Expand Up @@ -193,12 +199,28 @@ private static MaterialComposition IMaterialComposition(this IOpening prop)

private static MaterialComposition MaterialComposition(this Construction prop)
{
if (prop.Layers.Any(x => x.Material == null))
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.All(x => x.Material == null))
{
Engine.Base.Compute.RecordError("The Construction MaterialComposition could not be queried as no Material has been assigned.");
Compute.RecordError("Cannote evaluate MaterialComposition because all of the materials are null.");
return null;
}
return Matter.Create.MaterialComposition(prop.Layers.Select(x => x.Material), prop.Layers.Select(x => x.Thickness));

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.");
}

IEnumerable<Layer> layers = prop.Layers.Where(x => x.Material != null);
return Matter.Create.MaterialComposition(layers.Select(x => x.Material), layers.Select(x => x.Thickness));
}

/***************************************************/
Expand All @@ -219,6 +241,7 @@ 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;
}

Expand All @@ -231,8 +254,6 @@ private static MaterialComposition MaterialComposition(this IFramingElementPrope
throw new NotImplementedException();
}


/***************************************************/
}
}


}
Loading