Skip to content

Structure_Engine: Rename StartNode/EndNode to Start/End #3236

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 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions Analytical_Engine/Convert/Graph/ToRelation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,17 @@ public static IRelation ToRelation<TNode>(this ILink<TNode> link)
{
Relation relation = new Relation()
{
Source = link.StartNode.BHoM_Guid,
Target = link.EndNode.BHoM_Guid,
Source = link.Start.BHoM_Guid,
Target = link.End.BHoM_Guid,
Curve = (ICurve)link.IGeometry(),
};

Graph subgraph = new Graph();
subgraph.Entities.Add(link.StartNode.BHoM_Guid, link.StartNode);
subgraph.Entities.Add(link.EndNode.BHoM_Guid, link.EndNode);
subgraph.Entities.Add(link.Start.BHoM_Guid, link.Start);
subgraph.Entities.Add(link.End.BHoM_Guid, link.End);
subgraph.Entities.Add(link.BHoM_Guid, link);
subgraph.Relations.Add(new Relation() { Source = link.StartNode.BHoM_Guid, Target = link.BHoM_Guid });
subgraph.Relations.Add(new Relation() { Source = link.BHoM_Guid, Target = link.StartNode.BHoM_Guid });
subgraph.Relations.Add(new Relation() { Source = link.Start.BHoM_Guid, Target = link.BHoM_Guid });
subgraph.Relations.Add(new Relation() { Source = link.BHoM_Guid, Target = link.Start.BHoM_Guid });
relation.Subgraph = subgraph;

return relation;
Expand Down
12 changes: 6 additions & 6 deletions Analytical_Engine/Modify/SetElements0D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ public static ILink<TNode> SetElements0D<TNode>(this ILink<TNode> link, List<IEl
if (newElements0D[0] is Point)
{
//clone.StartNode = new TNode() { Position = newElements0D[0] as Point };
clone.StartNode = Activator.CreateInstance<TNode>();
clone.StartNode.Position = newElements0D[0] as Point;
clone.Start = Activator.CreateInstance<TNode>();
clone.Start.Position = newElements0D[0] as Point;
}
else
clone.StartNode = (TNode)newElements0D[0];
clone.Start = (TNode)newElements0D[0];

// Default the ILink end if the input is an Point
if (newElements0D[1] is Point)
{
//clone.EndNode = new TNode() { Position = newElements0D[1] as Point };
clone.EndNode = Activator.CreateInstance<TNode>();
clone.EndNode.Position = newElements0D[1] as Point;
clone.End = Activator.CreateInstance<TNode>();
clone.End.Position = newElements0D[1] as Point;
}
else
clone.EndNode = (TNode)newElements0D[1];
clone.End = (TNode)newElements0D[1];

return clone;
}
Expand Down
4 changes: 2 additions & 2 deletions Analytical_Engine/Modify/SetGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public static ILink<TNode> SetGeometry<TNode>(this ILink<TNode> link, ICurve cur
}

ILink<TNode> clone = link.ShallowClone();
clone.StartNode = (TNode)clone.StartNode.SetGeometry(curve.IStartPoint());
clone.EndNode = (TNode)clone.EndNode.SetGeometry(curve.IEndPoint());
clone.Start = (TNode)clone.Start.SetGeometry(curve.IStartPoint());
clone.End = (TNode)clone.End.SetGeometry(curve.IEndPoint());
return clone;
}

Expand Down
2 changes: 1 addition & 1 deletion Analytical_Engine/Query/Elements0D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static partial class Query
public static List<IElement0D> Elements0D<TNode>(this ILink<TNode> link)
where TNode : INode
{
return new List<IElement0D> { link.StartNode, link.EndNode };
return new List<IElement0D> { link.Start, link.End };
}

/******************************************/
Expand Down
2 changes: 1 addition & 1 deletion Analytical_Engine/Query/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static Point Geometry(this INode node)
public static Line Geometry<TNode>(this ILink<TNode> link)
where TNode : INode
{
return new Line { Start = link?.StartNode?.Position, End = link?.EndNode?.Position };
return new Line { Start = link?.Start?.Position, End = link?.End?.Position };
}

/***************************************************/
Expand Down
4 changes: 2 additions & 2 deletions Structure_Engine/Compute/MapTaperedProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ private static List<TaperedProfile> MapTaperedProfile(List<Bar> bars, TaperedPro
//For each bar interpolate the profiles as necessary and create a TaperedProfile
foreach (Bar bar in bars)
{
double startPosition = centreline.ParameterAtPoint(bar.StartNode.Position);
double endPosition = centreline.ParameterAtPoint(bar.EndNode.Position);
double startPosition = centreline.ParameterAtPoint(bar.Start.Position);
double endPosition = centreline.ParameterAtPoint(bar.End.Position);
double newLength = endPosition - startPosition;

List<double> positions = new List<double>(originalPositions);
Expand Down
4 changes: 2 additions & 2 deletions Structure_Engine/Create/Elements/Bar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static Bar Bar(Line line, ISectionProperty sectionProperty = null, double
return line.IsNull() ? null : new Bar
{
Name = name,
StartNode = (Node)line.Start,
EndNode = (Node)line.End,
Start = (Node)line.Start,
End = (Node)line.End,
SectionProperty = sectionProperty,
Release = release == null ? BarReleaseFixFix() : release,
FEAType = feaType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static List<BarVaryingDistributedLoad> BarVaryingDistributedLoadDistanceB
private static Dictionary<double, List<Bar>> GroupBarsByLength(this IEnumerable<Bar> bars, double tolerance)
{
//Check that bars have valid geometry
bars = bars.Where(x => x != null && x.StartNode != null && x.EndNode != null && x.StartNode.Position != null && x.EndNode.Position != null);
bars = bars.Where(x => x != null && x.Start != null && x.End != null && x.Start.Position != null && x.End.Position != null);

Dictionary<double, List<Bar>> dict = new Dictionary<double, List<Bar>>();
foreach (var group in bars.GroupBy(x => (int)Math.Round(x.Length() / tolerance)))
Expand Down
6 changes: 3 additions & 3 deletions Structure_Engine/Modify/Flip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public static Bar Flip(this Bar bar)

Bar flipped = bar.ShallowClone();

Node tempNode = flipped.StartNode;
flipped.StartNode = flipped.EndNode;
flipped.EndNode = tempNode;
Node tempNode = flipped.Start;
flipped.Start = flipped.End;
flipped.End = tempNode;

return flipped;
}
Expand Down
8 changes: 4 additions & 4 deletions Structure_Engine/Modify/SetElements0D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ public static Bar SetElements0D(this Bar bar, List<IElement0D> newElements0D)
// Default the Bars end if the input is an Point
if (newElements0D[0] is Point)
{
clone.StartNode = new Node { Position = newElements0D[0] as Point };
clone.Start = new Node { Position = newElements0D[0] as Point };
if (clone.Release != null)
clone.Release.StartRelease = Create.FixConstraint6DOF();
}
else
clone.StartNode = newElements0D[0] as Node;
clone.Start = newElements0D[0] as Node;

// Default the Bars end if the input is an Point
if (newElements0D[1] is Point)
{
clone.EndNode = new Node { Position = newElements0D[1] as Point };
clone.End = new Node { Position = newElements0D[1] as Point };
if (clone.Release != null)
clone.Release.EndRelease = Create.FixConstraint6DOF();
}
else
clone.EndNode = newElements0D[1] as Node;
clone.End = newElements0D[1] as Node;

return clone;
}
Expand Down
10 changes: 5 additions & 5 deletions Structure_Engine/Modify/Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static Bar Transform(this Bar bar, TransformMatrix transform, double tole
return null;
}

if (bar.StartNode?.Position == null || bar.EndNode?.Position == null)
if (bar.Start?.Position == null || bar.End?.Position == null)
{
BH.Engine.Base.Compute.RecordWarning("The bar could not be transformed because at least one of its nodes (or their location) is null.");
return bar;
Expand All @@ -91,12 +91,12 @@ public static Bar Transform(this Bar bar, TransformMatrix transform, double tole
}

Bar result = bar.ShallowClone();
result.StartNode = result.StartNode.Transform(transform, tolerance);
result.EndNode = result.EndNode.Transform(transform, tolerance);
result.Start = result.Start.Transform(transform, tolerance);
result.End = result.End.Transform(transform, tolerance);

Vector normalBefore = new Line { Start = bar.StartNode.Position, End = bar.EndNode.Position }.ElementNormal(bar.OrientationAngle);
Vector normalBefore = new Line { Start = bar.Start.Position, End = bar.End.Position }.ElementNormal(bar.OrientationAngle);
Vector normalAfter = normalBefore.Transform(transform);
result.OrientationAngle = normalAfter.OrientationAngleLinear(new Line { Start = result.StartNode.Position, End = result.EndNode.Position });
result.OrientationAngle = normalAfter.OrientationAngleLinear(new Line { Start = result.Start.Position, End = result.End.Position });

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public bool Equals(Bar bar1, Bar bar2)
if (Object.ReferenceEquals(bar1, null) || Object.ReferenceEquals(bar2, null))
return false;

if (m_nodeComparer.Equals(bar1.StartNode, bar2.StartNode))
if (m_nodeComparer.Equals(bar1.Start, bar2.Start))
{
return m_nodeComparer.Equals(bar1.EndNode, bar2.EndNode);
return m_nodeComparer.Equals(bar1.End, bar2.End);
}
else if (m_nodeComparer.Equals(bar1.StartNode, bar2.EndNode))
else if (m_nodeComparer.Equals(bar1.Start, bar2.End))
{
return m_nodeComparer.Equals(bar1.EndNode, bar2.StartNode);
return m_nodeComparer.Equals(bar1.End, bar2.Start);
}

return false;
Expand All @@ -77,7 +77,7 @@ public int GetHashCode(Bar bar)
//Check whether the object is null
if (Object.ReferenceEquals(bar, null)) return 0;

return m_nodeComparer.GetHashCode(bar.StartNode) ^ m_nodeComparer.GetHashCode(bar.EndNode);
return m_nodeComparer.GetHashCode(bar.Start) ^ m_nodeComparer.GetHashCode(bar.End);
}


Expand Down
2 changes: 1 addition & 1 deletion Structure_Engine/Query/BarSectionTranformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static TransformMatrix BarSectionTranformation(this Bar bar)
if (bar.IsNull())
return null;

Vector trans = bar.StartNode.Position - Point.Origin;
Vector trans = bar.Start.Position - Point.Origin;

Vector gX = Vector.XAxis;
Vector gY = Vector.YAxis;
Expand Down
2 changes: 1 addition & 1 deletion Structure_Engine/Query/Centreline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static partial class Query
[Output("centreLine", "The centreline of the Bar.")]
public static Line Centreline(this Bar bar)
{
return bar.IsNull() ? null : new Line { Start = bar.StartNode.Position, End = bar.EndNode.Position };
return bar.IsNull() ? null : new Line { Start = bar.Start.Position, End = bar.End.Position };
}

/***************************************************/
Expand Down
2 changes: 1 addition & 1 deletion Structure_Engine/Query/CoordinateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static Cartesian CoordinateSystem(this Bar bar)
{
Vector tan = bar?.Tangent(true);
Vector ax = bar?.Normal()?.CrossProduct(tan);
return tan != null && ax != null ? Engine.Geometry.Create.CartesianCoordinateSystem(bar.StartNode.Position, tan, ax) : null;
return tan != null && ax != null ? Engine.Geometry.Create.CartesianCoordinateSystem(bar.Start.Position, tan, ax) : null;
}

/***************************************************/
Expand Down
4 changes: 2 additions & 2 deletions Structure_Engine/Query/DeformedShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ public static List<Mesh> DeformedShape(List<FEMesh> meshes, List<MeshResult> mes

private static Polyline DeformedShapeCentreLine(Bar bar, List<BarDisplacement> deformations, double scaleFactor = 1.0)
{
Vector tan = (bar.EndNode.Position - bar.StartNode.Position);
Vector tan = (bar.End.Position - bar.Start.Position);
List<Point> pts = new List<Point>();

foreach (BarDisplacement defo in deformations)
{
Vector disp = new Vector { X = defo.UX * scaleFactor, Y = defo.UY * scaleFactor, Z = defo.UZ * scaleFactor };
Point pt = bar.StartNode.Position + tan * defo.Position + disp;
Point pt = bar.Start.Position + tan * defo.Position + disp;
pts.Add(pt);
}

Expand Down
4 changes: 2 additions & 2 deletions Structure_Engine/Query/DistributedPoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public static List<Point> DistributedPoints(this Bar bar, int divisions, double
Vector tan;
if (startLength == 0 && endLength == 0)
{
startPos = bar.StartNode.Position;
startPos = bar.Start.Position;
tan = bar.Tangent() / (double)divisions;
}
else
{
double length = bar.Length();
tan = bar.Tangent() / length;
startPos = bar.StartNode.Position + tan * startLength;
startPos = bar.Start.Position + tan * startLength;

tan *= (length - endLength - startLength) / (double)divisions;
}
Expand Down
2 changes: 1 addition & 1 deletion Structure_Engine/Query/IsNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static bool IsNull(this Bar bar, string msg = "", [CallerMemberName] stri
ErrorMessage(methodName, "Bar", msg);
return true;
}
else if (bar.StartNode.IsNull("The Node (StartNode) is owned by a Bar.", methodName) || bar.EndNode.IsNull("The Node (EndNode) is owned by a Bar.", methodName))
else if (bar.Start.IsNull("The Node (StartNode) is owned by a Bar.", methodName) || bar.End.IsNull("The Node (EndNode) is owned by a Bar.", methodName))
return true;

return false;
Expand Down
8 changes: 4 additions & 4 deletions Structure_Engine/Query/OppositeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public static Node OppositeNode(this Bar bar, Node node)
if (bar.IsNull() || node.IsNull())
return null;

if (bar.EndNode.BHoM_Guid == node.BHoM_Guid)
return bar.StartNode;
else if (bar.StartNode.BHoM_Guid == node.BHoM_Guid)
return bar.EndNode;
if (bar.End.BHoM_Guid == node.BHoM_Guid)
return bar.Start;
else if (bar.Start.BHoM_Guid == node.BHoM_Guid)
return bar.End;
else
{
Base.Compute.RecordError("The Bar does not contain the provided Node.");
Expand Down
2 changes: 1 addition & 1 deletion Structure_Engine/Query/PlotBarForce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static List<ICurve> PlotBarForce(Bar bar, List<BarForce> forces, double

scaleFactor /= 1000;

List<Point> basePoints = forces.Select(x => bar.StartNode.Position + tan * x.Position).ToList();
List<Point> basePoints = forces.Select(x => bar.Start.Position + tan * x.Position).ToList();

List<ICurve> plots = new List<ICurve>();

Expand Down
2 changes: 1 addition & 1 deletion Structure_Engine/Query/Tangent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static partial class Query
[Output("tan", "The tangent Vector of the Bar.")]
public static Vector Tangent(this Bar bar, bool normalise = false)
{
Vector tan = bar.IsNull() ? null : bar.EndNode.Position - bar.StartNode.Position;
Vector tan = bar.IsNull() ? null : bar.End.Position - bar.Start.Position;
return normalise ? tan?.Normalise() : tan;
}

Expand Down
4 changes: 2 additions & 2 deletions Structure_Engine/Query/Visualize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static List<ICurve> Visualize(this BarPointLoad barPointForce, double sca
{
Basis orientation;
Vector[] loads = BarForceVectors(bar, forceVec, momentVec, barPointForce.Axis, barPointForce.Projected, out orientation);
Point point = bar.StartNode.Position;
Point point = bar.Start.Position;
Vector tan = bar.Tangent(true);
point += tan * barPointForce.DistanceFromA;

Expand Down Expand Up @@ -753,7 +753,7 @@ private static Vector[] BarForceVectors(Bar bar, Vector globalForce, Vector glob
orientation = null;
if (isProjected)
{
Point startPos = bar.StartNode.Position;
Point startPos = bar.Start.Position;
Vector tan = bar.Tangent();

Vector tanUnit = tan.Normalise();
Expand Down