Skip to content

Commit

Permalink
Add support for reading Edge supports (Constraint6DOF)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjamesnugent committed Sep 5, 2024
1 parent 1b871e3 commit 754129f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
12 changes: 6 additions & 6 deletions Lusas_Adapter/CRUD/Read/Elements/Edges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using BH.oM.Structure.Elements;
using BH.Engine.Adapter;
using Lusas.LPI;
using BH.oM.Structure.Constraints;

namespace BH.Adapter.Lusas
{
Expand Down Expand Up @@ -59,12 +60,15 @@ private List<Edge> ReadEdges(List<string> ids = null)
List<Node> nodesList = GetCachedOrRead<Node>();
Dictionary<string, Node> nodes = nodesList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

IEnumerable<Constraint6DOF> supportsList = GetCachedOrRead<Constraint6DOF>();
Dictionary<string, Constraint6DOF> supports = supportsList.ToDictionary(x => x.Name);

HashSet<string> groupNames = ReadTags();

for (int i = 0; i < lusasLines.Count(); i++)
{
IFLine lusasLine = (IFLine)lusasLines[i];
Edge edge = Adapters.Lusas.Convert.ToEdge(lusasLine, nodes, groupNames);
Edge edge = Adapters.Lusas.Convert.ToEdge(lusasLine, nodes, supports, groupNames);
edges.Add(edge);
}
}
Expand All @@ -75,8 +79,4 @@ private List<Edge> ReadEdges(List<string> ids = null)
/***************************************************/

}
}




}
21 changes: 13 additions & 8 deletions Lusas_Adapter/Convert/ToBHoM/Elements/ToEdge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
using System.Collections.Generic;
using BH.oM.Adapters.Lusas;
using BH.oM.Structure.Elements;
using BH.oM.Structure.Constraints;
using BH.oM.Geometry;
using Lusas.LPI;
using BH.Engine.Adapter;
using System.Linq;


namespace BH.Adapter.Adapters.Lusas
Expand All @@ -37,7 +39,7 @@ public static partial class Convert
/***************************************************/

public static Edge ToEdge(this IFLine lusasLine,
Dictionary<string, Node> nodes, HashSet<string> groupNames)
Dictionary<string, Node> nodes, Dictionary<string, Constraint6DOF> supports, HashSet<string> groupNames)
{
Node startNode = GetNode(lusasLine, 0, nodes);
Node endNode = GetNode(lusasLine, 1, nodes);
Expand All @@ -47,8 +49,16 @@ public static Edge ToEdge(this IFLine lusasLine,

HashSet<string> tags = new HashSet<string>(IsMemberOf(lusasLine, groupNames));

List<string> supportAssignments = GetAttributeAssignments(lusasLine, "Support");

Constraint6DOF barConstraint = null;
if (!(supportAssignments.Count() == 0))
{
supports.TryGetValue(supportAssignments[0], out barConstraint);
}

Line line = new Line { Start = startPoint, End = endPoint };
Edge edge = new Edge { Curve = line, Tags = tags };
Edge edge = new Edge { Curve = line, Tags = tags, Support = barConstraint };

string adapterID = lusasLine.getID().ToString();
edge.SetAdapterId(typeof(LusasId), adapterID);
Expand All @@ -59,9 +69,4 @@ public static Edge ToEdge(this IFLine lusasLine,
/***************************************************/

}
}





}

0 comments on commit 754129f

Please sign in to comment.