Skip to content

Commit 6c2f2b8

Browse files
Structure_Engine: Add engine methods for retaining wall classes (#3408)
2 parents b65d15a + 666c2d5 commit 6c2f2b8

23 files changed

+743
-178
lines changed

Analytical_Engine/Modify/SetOutlineElements1D.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public static IPanel<TEdge, TOpening> SetOutlineElements1D<TEdge, TOpening>(this
7373

7474
/***************************************************/
7575

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

Analytical_Engine/Query/Geometry.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public static Face Geometry(this IFace face)
184184

185185
/***************************************************/
186186

187+
[PreviousVersion("7.3", "BH.Engine.Structure.Query.Geometry(BH.oM.Structure.Elements.PadFoundation)")]
187188
[Description("Gets the geometry of a IRegion as its Perimiter curve. Method required for automatic display in UI packages.")]
188189
[Input("region", "IRegion to get the curve geometry from.")]
189190
[Output("curve", "The geometry of the IRegion as its Perimiter curve.")]

Analytical_Engine/Query/IsOutlineQuad.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public static partial class Query
3939
/**** Public Methods ****/
4040
/***************************************************/
4141

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

53-
if (polycurve.SubParts().Any(x => !x.IIsLinear()))
54-
return false;
55-
56-
List<Point> points = polycurve.DiscontinuityPoints();
57-
if (points.Count != 4)
58-
return false;
59-
60-
return points.IsCoplanar();
61-
53+
return polycurve.IsQuad();
6254
}
6355

6456
/***************************************************/

Analytical_Engine/Query/IsOutlineRectangular.cs

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,70 +39,16 @@ public static partial class Query
3939
/**** Public Methods ****/
4040
/***************************************************/
4141

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

53-
if (polycurve.SubParts().Any(x => !x.IIsLinear()))
54-
return false;
55-
56-
List<Point> points = polycurve.DiscontinuityPoints();
57-
if (points.Count != 4)
58-
return false;
59-
if (!points.IsCoplanar())
60-
return false;
61-
62-
List<Vector> vectors = VectorsBetweenPoints(points);
63-
64-
List<double> angles = AnglesBetweenVectors(vectors);
65-
66-
//Check the three angles are pi/2 degrees within tolerance
67-
return (angles.Any(x => Math.Abs(Math.PI / 2 - x) > Tolerance.Angle)) ? false : true;
68-
}
69-
70-
/***************************************************/
71-
/**** Private Methods ****/
72-
/***************************************************/
73-
74-
[Description("Computes the vectors between the provided list of points.")]
75-
[Input("points", "The list of points.")]
76-
[Output("vectors", "The vectors computed from the list of points.")]
77-
private static List<Vector> VectorsBetweenPoints(this List<Point> points)
78-
{
79-
List<Vector> vectors = new List<Vector>();
80-
81-
for (int i = 0; i < points.Count; i++)
82-
{
83-
int next = (i + 1) % points.Count;
84-
vectors.Add(points[next] - points[i]);
85-
}
86-
87-
return vectors;
88-
}
89-
90-
/***************************************************/
91-
92-
[Description("Gets the internal angle between sequential vectors.")]
93-
[Input("vectors", "The vectors to find the internal angle between.")]
94-
[Output("angles", "The internal angles between sequential vectors.")]
95-
private static List<double> AnglesBetweenVectors(this List<Vector> vectors)
96-
{
97-
98-
List<double> angles = new List<double>();
99-
for (int i = 0; i < vectors.Count; i++)
100-
{
101-
int next = (i + 1) % vectors.Count;
102-
angles.Add(vectors[i].Angle(vectors[next]));
103-
}
104-
105-
return angles;
51+
return polycurve.IsRectangular();
10652
}
10753

10854
/***************************************************/

Analytical_Engine/Query/IsOutlineSquare.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,16 @@ public static partial class Query
4040
/**** Public Methods ****/
4141
/***************************************************/
4242

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

54-
if (polycurve.SubParts().Any(x => !x.IIsLinear()))
55-
return false;
56-
57-
List<Point> points = polycurve.DiscontinuityPoints();
58-
if (points.Count != 4)
59-
return false;
60-
if (!points.IsCoplanar())
61-
return false;
62-
63-
List<Vector> vectors = VectorsBetweenPoints(points);
64-
65-
List<double> angles = AnglesBetweenVectors(vectors);
66-
67-
//Check the three angles are pi/2 degrees within tolerance
68-
if (angles.Any(x => Math.Abs(Math.PI / 2 - x) > Tolerance.Angle))
69-
return false;
70-
71-
//Check all lengths are the same within tolerance
72-
double length = vectors.First().Length();
73-
return vectors.Skip(0).All(x => (Math.Abs(x.Length() - length) < Tolerance.Distance)) ? true : false;
52+
return polycurve.IsSquare();
7453
}
7554

7655
/***************************************************/

Analytical_Engine/Query/IsOutlineTrianglular.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,16 @@ public static partial class Query
3939
/**** Public Methods ****/
4040
/***************************************************/
4141

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

53-
if (polycurve.SubParts().Any(x => !x.IIsLinear()))
54-
return false;
55-
56-
List<Point> points = polycurve.DiscontinuityPoints();
57-
if (points.Count != 3)
58-
return false;
59-
60-
return true;
51+
return polycurve.IsTriangular();
6152

6253
}
6354

Analytical_Engine/Query/OutlineElements1D.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static List<IElement1D> OutlineElements1D<TEdge, TOpening>(this IPanel<TE
6262

6363
/***************************************************/
6464

65+
[PreviousVersion("7.3", "BH.Engine.Structure.Query.OutlineElements1D(BH.oM.Structure.Elements.PadFoundation)")]
6566
[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.")]
6667
[Input("region", "The IRegion to get outline elements from.")]
6768
[Output("elements", "Outline elements of the IRegion, i.e. the subparts of the Perimiter curve.")]

Geometry_Engine/Query/IsQuad.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
2121
*/
2222

23+
using System;
24+
using System.Collections.Generic;
25+
using System.Linq;
26+
using System.ComponentModel;
2327
using BH.oM.Geometry;
28+
using BH.oM.Base.Attributes;
29+
2430

2531
namespace BH.Engine.Geometry
2632
{
@@ -29,12 +35,33 @@ public static partial class Query
2935
/***************************************************/
3036
/**** Public Methods ****/
3137
/***************************************************/
32-
38+
[Description("Determines whether a Face is a quadilaterial.")]
39+
[Input("face", "The Face to check if it is quadilaterial.")]
40+
[Output("bool", "True for Faces that are quadilaterial or false for Faces that are non-quadilaterial.")]
3341
public static bool IsQuad(this Face face)
3442
{
3543
return face.D != -1;
3644
}
3745

46+
/***************************************************/
47+
[Description("Determines whether a Polycurve is a quadilaterial.")]
48+
[Input("polycurve", "The Polycurve to check if it is quadilaterial.")]
49+
[Output("bool", "True for Polycurves that are quadilaterial or false for Polycurves that are non-quadilaterial.")]
50+
public static bool IsQuad(this PolyCurve polycurve)
51+
{
52+
if (polycurve == null)
53+
return false;
54+
55+
if (polycurve.SubParts().Any(x => !x.IIsLinear()))
56+
return false;
57+
58+
List<Point> points = polycurve.DiscontinuityPoints();
59+
if (points.Count != 4)
60+
return false;
61+
62+
return points.IsCoplanar();
63+
}
64+
3865
/***************************************************/
3966
}
4067
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* This file is part of the Buildings and Habitats object Model (BHoM)
3+
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
4+
*
5+
* Each contributor holds copyright over their respective contributions.
6+
* The project versioning (Git) records all such contribution source information.
7+
*
8+
*
9+
* The BHoM is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as published by
11+
* the Free Software Foundation, either version 3.0 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* The BHoM is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public License
20+
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
21+
*/
22+
23+
using BH.oM.Geometry;
24+
using BH.oM.Base.Attributes;
25+
using BH.Engine.Geometry;
26+
using BH.Engine.Reflection;
27+
28+
using System;
29+
using System.Collections.Generic;
30+
using System.Linq;
31+
using System.ComponentModel;
32+
33+
namespace BH.Engine.Geometry
34+
{
35+
public static partial class Query
36+
{
37+
/***************************************************/
38+
/**** Public Methods ****/
39+
/***************************************************/
40+
41+
[Description("Determines whether a Polycurve is a rectangular.")]
42+
[Input("polycurve", "The Polycurve to check if it is rectangular.")]
43+
[Output("bool", "True for Polycurves that are rectangular or false for Polycurves that are rectangular.")]
44+
public static bool IsRectangular(this PolyCurve polycurve)
45+
{
46+
if (polycurve == null)
47+
return false;
48+
49+
if (polycurve.SubParts().Any(x => !x.IIsLinear()))
50+
return false;
51+
52+
List<Point> points = polycurve.DiscontinuityPoints();
53+
if (points.Count != 4)
54+
return false;
55+
if (!points.IsCoplanar())
56+
return false;
57+
58+
List<Vector> vectors = VectorsBetweenPoints(points);
59+
60+
List<double> angles = AnglesBetweenVectors(vectors);
61+
62+
//Check the three angles are pi/2 degrees within tolerance
63+
return (angles.Any(x => Math.Abs(Math.PI / 2 - x) > Tolerance.Angle)) ? false : true;
64+
}
65+
66+
/***************************************************/
67+
/**** Private Methods ****/
68+
/***************************************************/
69+
70+
[Description("Computes the vectors between the provided list of points.")]
71+
[Input("points", "The list of points.")]
72+
[Output("vectors", "The vectors computed from the list of points.")]
73+
private static List<Vector> VectorsBetweenPoints(this List<Point> points)
74+
{
75+
List<Vector> vectors = new List<Vector>();
76+
77+
for (int i = 0; i < points.Count; i++)
78+
{
79+
int next = (i + 1) % points.Count;
80+
vectors.Add(points[next] - points[i]);
81+
}
82+
83+
return vectors;
84+
}
85+
86+
/***************************************************/
87+
88+
[Description("Gets the internal angle between sequential vectors.")]
89+
[Input("vectors", "The vectors to find the internal angle between.")]
90+
[Output("angles", "The internal angles between sequential vectors.")]
91+
private static List<double> AnglesBetweenVectors(this List<Vector> vectors)
92+
{
93+
94+
List<double> angles = new List<double>();
95+
for (int i = 0; i < vectors.Count; i++)
96+
{
97+
int next = (i + 1) % vectors.Count;
98+
angles.Add(vectors[i].Angle(vectors[next]));
99+
}
100+
101+
return angles;
102+
}
103+
104+
/***************************************************/
105+
106+
}
107+
108+
}
109+
110+
111+

0 commit comments

Comments
 (0)