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: Update AssignSpaceTypeByPoint to provide output of spaces not assigned #3180

Merged
merged 1 commit into from
Sep 11, 2023
Merged
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
15 changes: 12 additions & 3 deletions Environment_Engine/Compute/AssignSpaceTypeByPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using BH.Engine.Base;
using BH.oM.Base.Attributes;
using BH.oM.Environment.Elements;
using BH.oM.Base;

namespace BH.Engine.Environment
{
Expand All @@ -45,9 +46,10 @@ public static partial class Compute
[Input("spaces", "A collection of Environment Spaces to set the type for.")]
[Input("searchPoints", "A collection of points to search. The points should be contained by the space geometry.")]
[Input("spaceType", "The space type to assign.")]
[Output("spaces", "A collection of modified Environment Spaces with assigned space types.")]
[MultiOutput(0, "spaces", "A collection of modified Environment Spaces with assigned space types.")]
[MultiOutput(1, "spacesNotAssigned", "Spaces which were not assigned the space type because they did not contain any of the search points.")]
[PreviousVersion("6.3", "BH.Engine.Environment.Compute.AssignSpaceTypeByPoint(System.Collections.Generic.List<BH.oM.Environment.Elements.Space>, System.Collections.Generic.List<BH.oM.Geometry.Point>, System.String, System.Boolean)")]
public static List<Space> AssignSpaceTypeByPoint(this List<Space> spaces, List<Point> searchPoints, SpaceType spaceType)
public static Output<List<Space>, List<Space>> AssignSpaceTypeByPoint(this List<Space> spaces, List<Point> searchPoints, SpaceType spaceType)
{
List<Space> returnSpaces = new List<Space>();
for (int x = 0; x < searchPoints.Count; x++)
Expand All @@ -59,7 +61,14 @@ public static List<Space> AssignSpaceTypeByPoint(this List<Space> spaces, List<P
update.SpaceType = spaceType;
returnSpaces.Add(update);
}
return returnSpaces;

List<Space> spacesNotModified = spaces.Where(x => !returnSpaces.Contains(x)).ToList();

return new Output<List<Space>, List<Space>>()
{
Item1 = returnSpaces,
Item2 = spacesNotModified,
};
}
}
}
Expand Down