-
Notifications
You must be signed in to change notification settings - Fork 13
Environment_Engine: Added ElementsInSpace and dependant IsContaining methods / optimisations #3195
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
Merged
FraserGreenroyd
merged 7 commits into
develop
from
Environment_Engine-#3194-ElementIsContaining
Oct 25, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18b94d5
Added ElementsInSpace and depndant IsContaining methods / optimizations
enarhi e46c174
Addition of method to check list of list of points for multi element …
enarhi 685a837
Implementation of simpler IElement method for checks
enarhi ada589b
Added partial containment option for element in space checks
enarhi 956f763
Ensure (point == null) check happens first
vietle-bh 9ed979d
Formatting cleanup
enarhi ef6f299
Removing whitespace
enarhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2023, 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 <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.Environment.Elements; | ||
using BH.oM.Architecture.Elements; | ||
|
||
using BH.Engine.Geometry; | ||
using BH.oM.Geometry; | ||
|
||
using BH.oM.Base.Attributes; | ||
using System.ComponentModel; | ||
|
||
using BH.oM.Analytical.Elements; | ||
using BH.oM.Dimensional; | ||
|
||
namespace BH.Engine.Environment | ||
{ | ||
public static partial class Compute | ||
{ | ||
[Description("Gets the elements that lie within the provided space.")] | ||
[Input("space", "An Environment Space object defining a perimeter to build a 3D volume from and check if the volume contains the provided point.")] | ||
[Input("spaceHeight", "The height of the space.", typeof(BH.oM.Quantities.Attributes.Length))] | ||
[Input("elements", "The elements being checked to see if they are contained within the bounds of the 3D volume.")] | ||
[Input("acceptOnEdges", "Decide whether to allow elements which sit on the edge of the space, default false.")] | ||
[Input("acceptPartial", "Decide whether to include elements only partially within the space, default false.")] | ||
[Output("elements", "The elements from the provided elements that are within the space.")] | ||
public static List<IElement> ElementsInSpace(this Space space, double spaceHeight, List<IElement> elements, bool acceptOnEdges = false, bool acceptPartial = false) | ||
{ | ||
if (space == null) | ||
return new List<IElement>(); | ||
|
||
List<bool> isContaining = space.IsContaining(spaceHeight, elements, acceptOnEdges, acceptPartial); | ||
|
||
return elements | ||
.Zip(isContaining, (elem, inSpace) => new { | ||
elem, | ||
inSpace, | ||
}) | ||
.Where(item => item.inSpace) | ||
.Select(item => item.elem) | ||
.ToList(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2023, 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 <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.Lighting; | ||
using BH.oM.Base.Attributes; | ||
using System.ComponentModel; | ||
using BH.oM.Geometry; | ||
using BH.oM.Lighting.Elements; | ||
|
||
namespace BH.Engine.Lighting | ||
{ | ||
public static partial class Query | ||
{ | ||
[Description("Gets the geometry of a Luminaire as a Point.")] | ||
[Input("luminaire", "Element to get the Point from.")] | ||
[Output("point", "The geometry of the Element.")] | ||
public static Point Geometry(this Luminaire luminaire) | ||
{ | ||
if(luminaire == null) | ||
{ | ||
BH.Engine.Base.Compute.RecordError("Cannot query the geometry of a null luminaire."); | ||
return null; | ||
} | ||
|
||
return luminaire.Position; | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.