Skip to content

Structure_Engine: Add engine methods for retaining wall classes #3408

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
merged 7 commits into from
Sep 3, 2024
1 change: 1 addition & 0 deletions Analytical_Engine/Modify/SetOutlineElements1D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
[Input("edges", "A list of IElement1Ds which all should be of a type of Edge accepted by the Opening or Geometrical ICurve. \n" +
"ICurve will default the outlines properties.")]
[Output("opening", "The opening with updated Edges.")]
public static IOpening<TEdge> SetOutlineElements1D<TEdge>(this IOpening<TEdge> opening, IEnumerable<IElement1D> edges)

Check warning on line 48 in Analytical_Engine/Modify/SetOutlineElements1D.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Analytical_Engine/Modify/SetOutlineElements1D.cs#L48

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
where TEdge : IEdge
{
IOpening<TEdge> o = opening.ShallowClone();
Expand All @@ -61,7 +61,7 @@
[Input("edges", "A list of IElement1Ds which all should be of a type of Edge accepted by the IPanel or Geometrical ICurve. \n" +
"ICurve will default the outlines properties.")]
[Output("panel", "The IPanel with updated ExternalEdges.")]
public static IPanel<TEdge, TOpening> SetOutlineElements1D<TEdge, TOpening>(this IPanel<TEdge, TOpening> panel, IEnumerable<IElement1D> edges)

Check warning on line 64 in Analytical_Engine/Modify/SetOutlineElements1D.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Analytical_Engine/Modify/SetOutlineElements1D.cs#L64

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
where TEdge : IEdge
where TOpening : IOpening<TEdge>
{
Expand All @@ -73,11 +73,12 @@

/***************************************************/

[PreviousVersion("7.3", "BH.Engine.Structure.Modify.SetOutlineElements1D(BH.oM.Structure.Elements.PadFoundation, System.Collections.Generic.IEnumerable<BH.oM.Dimensional.IElement1D>)")]
[Description("Sets the Outline Element1Ds of an IRegion, i.e. the perimiter. Method required for all IElement2Ds.")]
[Input("region", "The IRegion to update the Perimeter of.")]
[Input("outlineElements", "A list of IElement1Ds which all should be Geometrical ICurves.")]
[Output("region", "The region with updated perimiter.")]
public static IRegion SetOutlineElements1D(this IRegion region, IEnumerable<IElement1D> outlineElements)

Check warning on line 81 in Analytical_Engine/Modify/SetOutlineElements1D.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Analytical_Engine/Modify/SetOutlineElements1D.cs#L81

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
if(region == null)
{
Expand Down
1 change: 1 addition & 0 deletions Analytical_Engine/Query/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public static Face Geometry(this IFace face)

/***************************************************/

[PreviousVersion("7.3", "BH.Engine.Structure.Query.Geometry(BH.oM.Structure.Elements.PadFoundation)")]
[Description("Gets the geometry of a IRegion as its Perimiter curve. Method required for automatic display in UI packages.")]
[Input("region", "IRegion to get the curve geometry from.")]
[Output("curve", "The geometry of the IRegion as its Perimiter curve.")]
Expand Down
14 changes: 3 additions & 11 deletions Analytical_Engine/Query/IsOutlineQuad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static partial class Query
/**** Public Methods ****/
/***************************************************/

[Description("Determines whether a panel's outline is a quadilateral.")]
[Description("Determines whether a Panel's outline is a quadilateral.")]
[Input("panel", "The IPanel to check if the outline is a quadilateral.")]
[Output("bool", "True for panels with a quadilateral outline or false for panels with a non-quadilateral outline.")]
[Output("bool", "True for Panels with a quadilateral outline or false for Panels with a non-quadilateral outline.")]
public static bool IsOutlineQuad<TEdge, TOpening>(this IPanel<TEdge, TOpening> panel)
where TEdge : IEdge
where TOpening : IOpening<TEdge>
Expand All @@ -50,15 +50,7 @@ public static bool IsOutlineQuad<TEdge, TOpening>(this IPanel<TEdge, TOpening> p
if (polycurve == null)
return false;

if (polycurve.SubParts().Any(x => !x.IIsLinear()))
return false;

List<Point> points = polycurve.DiscontinuityPoints();
if (points.Count != 4)
return false;

return points.IsCoplanar();

return polycurve.IsQuad();
}

/***************************************************/
Expand Down
60 changes: 3 additions & 57 deletions Analytical_Engine/Query/IsOutlineRectangular.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,70 +39,16 @@ public static partial class Query
/**** Public Methods ****/
/***************************************************/

[Description("Determines whether a panel's outline is a rectangular.")]
[Description("Determines whether a Panel's outline is a rectangular.")]
[Input("panel", "The IPanel to check if the outline is a rectangular.")]
[Output("bool", "True for panels with a rectangular outline or false for panels with a non rectangular outline.")]
[Output("bool", "True for Panels with a rectangular outline or false for Panels with a non rectangular outline.")]
public static bool IsOutlineRectangular<TEdge, TOpening>(this IPanel<TEdge, TOpening> panel)
where TEdge : IEdge
where TOpening : IOpening<TEdge>
{
PolyCurve polycurve = ExternalPolyCurve(panel);
if (polycurve == null)
return false;

if (polycurve.SubParts().Any(x => !x.IIsLinear()))
return false;

List<Point> points = polycurve.DiscontinuityPoints();
if (points.Count != 4)
return false;
if (!points.IsCoplanar())
return false;

List<Vector> vectors = VectorsBetweenPoints(points);

List<double> angles = AnglesBetweenVectors(vectors);

//Check the three angles are pi/2 degrees within tolerance
return (angles.Any(x => Math.Abs(Math.PI / 2 - x) > Tolerance.Angle)) ? false : true;
}

/***************************************************/
/**** Private Methods ****/
/***************************************************/

[Description("Computes the vectors between the provided list of points.")]
[Input("points", "The list of points.")]
[Output("vectors", "The vectors computed from the list of points.")]
private static List<Vector> VectorsBetweenPoints(this List<Point> points)
{
List<Vector> vectors = new List<Vector>();

for (int i = 0; i < points.Count; i++)
{
int next = (i + 1) % points.Count;
vectors.Add(points[next] - points[i]);
}

return vectors;
}

/***************************************************/

[Description("Gets the internal angle between sequential vectors.")]
[Input("vectors", "The vectors to find the internal angle between.")]
[Output("angles", "The internal angles between sequential vectors.")]
private static List<double> AnglesBetweenVectors(this List<Vector> vectors)
{

List<double> angles = new List<double>();
for (int i = 0; i < vectors.Count; i++)
{
int next = (i + 1) % vectors.Count;
angles.Add(vectors[i].Angle(vectors[next]));
}

return angles;
return polycurve.IsRectangular();
}

/***************************************************/
Expand Down
27 changes: 3 additions & 24 deletions Analytical_Engine/Query/IsOutlineSquare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,16 @@ public static partial class Query
/**** Public Methods ****/
/***************************************************/

[Description("Determines whether a panel's outline is a square.")]
[Description("Determines whether a Panel's outline is a square.")]
[Input("panel", "The IPanel to check if the outline is a square.")]
[Output("bool", "True for panels with a square outline or false for panels with a non square outline.")]
[Output("bool", "True for Panels with a square outline or false for Panels with a non square outline.")]
public static bool IsOutlineSquare<TEdge, TOpening>(this IPanel<TEdge, TOpening> panel)
where TEdge : IEdge
where TOpening : IOpening<TEdge>
{
PolyCurve polycurve = ExternalPolyCurve(panel);
if (polycurve == null)
return false;

if (polycurve.SubParts().Any(x => !x.IIsLinear()))
return false;

List<Point> points = polycurve.DiscontinuityPoints();
if (points.Count != 4)
return false;
if (!points.IsCoplanar())
return false;

List<Vector> vectors = VectorsBetweenPoints(points);

List<double> angles = AnglesBetweenVectors(vectors);

//Check the three angles are pi/2 degrees within tolerance
if (angles.Any(x => Math.Abs(Math.PI / 2 - x) > Tolerance.Angle))
return false;

//Check all lengths are the same within tolerance
double length = vectors.First().Length();
return vectors.Skip(0).All(x => (Math.Abs(x.Length() - length) < Tolerance.Distance)) ? true : false;
return polycurve.IsSquare();
}

/***************************************************/
Expand Down
15 changes: 3 additions & 12 deletions Analytical_Engine/Query/IsOutlineTrianglular.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,16 @@ public static partial class Query
/**** Public Methods ****/
/***************************************************/

[Description("Determines whether a panel's outline is triangular.")]
[Description("Determines whether a Panel's outline is triangular.")]
[Input("panel", "The IPanel to check if the outline is a triangular.")]
[Output("bool", "True for panels with a triangular outline or false for panels with a non-triangular outline.")]
[Output("bool", "True for Panels with a triangular outline or false for Panels with a non-triangular outline.")]
public static bool IsOutlineTriangular<TEdge, TOpening>(this IPanel<TEdge, TOpening> panel)
where TEdge : IEdge
where TOpening : IOpening<TEdge>
{
PolyCurve polycurve = ExternalPolyCurve(panel);
if (polycurve == null)
return false;

if (polycurve.SubParts().Any(x => !x.IIsLinear()))
return false;

List<Point> points = polycurve.DiscontinuityPoints();
if (points.Count != 3)
return false;

return true;
return polycurve.IsTriangular();

}

Expand Down
1 change: 1 addition & 0 deletions Analytical_Engine/Query/OutlineElements1D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static List<IElement1D> OutlineElements1D<TEdge, TOpening>(this IPanel<TE

/***************************************************/

[PreviousVersion("7.3", "BH.Engine.Structure.Query.OutlineElements1D(BH.oM.Structure.Elements.PadFoundation)")]
[Description("Gets the boundary from an IRegion defining the boundary of the element as the subparts of the perimiter curve. Method required for all IElement2Ds.")]
[Input("region", "The IRegion to get outline elements from.")]
[Output("elements", "Outline elements of the IRegion, i.e. the subparts of the Perimiter curve.")]
Expand Down
29 changes: 28 additions & 1 deletion Geometry_Engine/Query/IsQuad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
* 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.ComponentModel;
using BH.oM.Geometry;
using BH.oM.Base.Attributes;


namespace BH.Engine.Geometry
{
Expand All @@ -29,12 +35,33 @@ public static partial class Query
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Determines whether a Face is a quadilaterial.")]
[Input("face", "The Face to check if it is quadilaterial.")]
[Output("bool", "True for Faces that are quadilaterial or false for Faces that are non-quadilaterial.")]
public static bool IsQuad(this Face face)
{
return face.D != -1;
}

/***************************************************/
[Description("Determines whether a Polycurve is a quadilaterial.")]
[Input("polycurve", "The Polycurve to check if it is quadilaterial.")]
[Output("bool", "True for Polycurves that are quadilaterial or false for Polycurves that are non-quadilaterial.")]
public static bool IsQuad(this PolyCurve polycurve)
{
if (polycurve == null)
return false;

if (polycurve.SubParts().Any(x => !x.IIsLinear()))
return false;

List<Point> points = polycurve.DiscontinuityPoints();
if (points.Count != 4)
return false;

return points.IsCoplanar();
}

/***************************************************/
}
}
Expand Down
111 changes: 111 additions & 0 deletions Geometry_Engine/Query/IsRectangular.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2024, 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 BH.oM.Geometry;
using BH.oM.Base.Attributes;
using BH.Engine.Geometry;
using BH.Engine.Reflection;

using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;

namespace BH.Engine.Geometry
{
public static partial class Query
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Determines whether a Polycurve is a rectangular.")]
[Input("polycurve", "The Polycurve to check if it is rectangular.")]
[Output("bool", "True for Polycurves that are rectangular or false for Polycurves that are rectangular.")]
public static bool IsRectangular(this PolyCurve polycurve)
{
if (polycurve == null)
return false;

if (polycurve.SubParts().Any(x => !x.IIsLinear()))
return false;

List<Point> points = polycurve.DiscontinuityPoints();
if (points.Count != 4)
return false;
if (!points.IsCoplanar())
return false;

List<Vector> vectors = VectorsBetweenPoints(points);

List<double> angles = AnglesBetweenVectors(vectors);

//Check the three angles are pi/2 degrees within tolerance
return (angles.Any(x => Math.Abs(Math.PI / 2 - x) > Tolerance.Angle)) ? false : true;
}

/***************************************************/
/**** Private Methods ****/
/***************************************************/

[Description("Computes the vectors between the provided list of points.")]
[Input("points", "The list of points.")]
[Output("vectors", "The vectors computed from the list of points.")]
private static List<Vector> VectorsBetweenPoints(this List<Point> points)
{
List<Vector> vectors = new List<Vector>();

for (int i = 0; i < points.Count; i++)
{
int next = (i + 1) % points.Count;
vectors.Add(points[next] - points[i]);
}

return vectors;
}

/***************************************************/

[Description("Gets the internal angle between sequential vectors.")]
[Input("vectors", "The vectors to find the internal angle between.")]
[Output("angles", "The internal angles between sequential vectors.")]
private static List<double> AnglesBetweenVectors(this List<Vector> vectors)
{

List<double> angles = new List<double>();
for (int i = 0; i < vectors.Count; i++)
{
int next = (i + 1) % vectors.Count;
angles.Add(vectors[i].Angle(vectors[next]));
}

return angles;
}

/***************************************************/

}

}



Loading