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

Environment_Engine Fix opening query by level #1393

Merged
merged 4 commits into from
Dec 19, 2019
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
52 changes: 42 additions & 10 deletions Environment_Engine/Query/Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public static List<Level> Levels(this List<IBHoMObject> bhomObjects)
return levels;
}

[Description("Returns the minimum level of the given panel based on the z axis")]
[Input("panel", "An Environment Panel to find the minimum level from")]
[Output("minimumLevel", "The minimum level of the z axis of the panel")]
public static double MinimumLevel(this Panel panel)
[Description("Returns the minimum level of the given polyline based on the z axis")]
[Input("polyline", "An Environment polyline to find the minimum level from")]
[Output("minimumLevel", "The minimum level of the z axis of the polyline")]
public static double MinimumLevel(this Polyline polyline)
{
List<Point> crvPts = panel.Polyline().IControlPoints();
List<Point> crvPts = polyline.IControlPoints();

double min = 1e10;
foreach (Point p in crvPts)
Expand All @@ -71,12 +71,12 @@ public static double MinimumLevel(this Panel panel)
return Math.Round(min, 3);
}

[Description("Returns the maximum level of the given panel based on the z axis")]
[Input("panel", "An Environment Panel to find the maximum level from")]
[Output("maximumLevel", "The maximum level of the z axis of the panel")]
public static double MaximumLevel(this Panel panel)
[Description("Returns the maximum level of the given polyline based on the z axis")]
[Input("polyline", "An Environment polyline to find the maximum level from")]
[Output("maximumLevel", "The maximum level of the z axis of the polyline")]
public static double MaximumLevel(this Polyline polyline)
{
List<Point> crvPts = panel.Polyline().IControlPoints();
List<Point> crvPts = polyline.IControlPoints();

double max = -1e10;
foreach (Point p in crvPts)
Expand All @@ -85,6 +85,38 @@ public static double MaximumLevel(this Panel panel)
return Math.Round(max, 3);
}

[Description("Returns the minimum level of the given panel based on the z axis")]
[Input("panel", "An Environment Panel to find the minimum level from")]
[Output("minimumLevel", "The minimum level of the z axis of the panel")]
public static double MinimumLevel(this Panel panel)
{
return panel.Polyline().MinimumLevel();
}

[Description("Returns the maximum level of the given panel based on the z axis")]
[Input("panel", "An Environment Panel to find the maximum level from")]
[Output("maximumLevel", "The maximum level of the z axis of the panel")]
public static double MaximumLevel(this Panel panel)
{
return panel.Polyline().MaximumLevel();
}

[Description("Returns the minimum level of the given opening based on the z axis")]
[Input("opening", "An Environment Opening to find the minimum level from")]
[Output("minimumLevel", "The minimum level of the z axis of the opening")]
public static double MinimumLevel(this Opening opening)
{
return opening.Polyline().MinimumLevel();
}

[Description("Returns the maximum level of the given opening based on the z axis")]
[Input("opening", "An Environment Opening to find the maximum level from")]
[Output("maximumLevel", "The maximum level of the z axis of the opening")]
public static double MaximumLevel(this Opening opening)
{
return opening.Polyline().MaximumLevel();
}

[Description("Returns the Setting Out Level that the Environment Panel resides on")]
[Input("panel", "An Environment Panel to find the level from")]
[Input("levels", "A collection of Setting Out Levels to search from")]
Expand Down
56 changes: 56 additions & 0 deletions Environment_Engine/Query/Openings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
using BH.oM.Physical.Elements;
using BH.Engine.Geometry;

using BH.oM.Geometry.SettingOut;

namespace BH.Engine.Environment
{
public static partial class Query
Expand Down Expand Up @@ -156,5 +158,59 @@ public static List<Opening> OpeningsByName(this List<Opening> openings, string o
{
return openings.Where(x => x.Name == openingName).ToList();
}

[Description("Returns a collection of Environment Openings where the maximum level of the opening matches the elevation of the given search level")]
[Input("openings", "A collection of Environment Openings to filter")]
[Input("searchLevel", "The Setting Level to search by")]
[Output("openings", "A collection of Environment Openings where the maximum level meets the search level")]
public static List<Opening> OpeningsByMaximumLevel(this List<Opening> openings, Level searchLevel)
{
return openings.OpeningsByMaximumLevel(searchLevel.Elevation);
}

[Description("Returns a collection of Environment Openings where the maximum level of the panel matches the elevation of the given search level")]
[Input("openings", "A collection of Environment Openings to filter")]
[Input("searchLevel", "The level to search by")]
[Output("openings", "A collection of Environment Openings where the maximum level meets the search level")]
public static List<Opening> OpeningsByMaximumLevel(this List<Opening> openings, double searchLevel)
{
return openings.Where(x => x.MaximumLevel() == searchLevel).ToList();
}

[Description("Returns a collection of Environment Openings where the minimum level of the Opening matches the elevation of the given search level")]
[Input("openings", "A collection of Environment Openings to filter")]
[Input("searchLevel", "The Setting Out Level to search by")]
[Output("openings", "A collection of Environment Openings where the minimum level meets the search level")]
public static List<Opening> OpeningsByMinimumLevel(this List<Opening> openings, Level searchLevel)
{
return openings.OpeningsByMinimumLevel(searchLevel.Elevation);
}

[Description("Returns a collection of Environment Openings where the minimum level of the Opening matches the elevation of the given search level")]
[Input("openings", "A collection of Environment Opening to filter")]
[Input("searchLevel", "The level to search by")]
[Output("openings", "A collection of Environment Opening where the minimum level meets the search level")]
public static List<Opening> OpeningsByMinimumLevel(this List<Opening> openings, double searchLevel)
{
return openings.Where(x => x.MinimumLevel() == searchLevel).ToList();
}

[Description("Returns a collection of Environment Opening that sit entirely on a given levels elevation")]
[Input("openings", "A collection of Environment Openings to filter")]
[Input("searchLevel", "The Setting Out Level to search by")]
[Output("openings", "A collection of Environment Openings which match the given level")]
public static List<Opening> OpeningsByLevel(this List<Opening> openings, Level searchLevel)
{
return openings.OpeningsByLevel(searchLevel.Elevation);
}

[Description("Returns a collection of Environment Openings that sit entirely on a given levels elevation")]
[Input("openings", "A collection of Environment Openings to filter")]
[Input("searchLevel", "The level to search by")]
[Output("openings", "A collection of Environment Openings which match the given level")]
public static List<Opening> OpeningsByLevel(this List<Opening> openings, double searchLevel)
{
return openings.Where(x => x.MinimumLevel() == searchLevel && x.MaximumLevel() == searchLevel).ToList();
}
}
}