Skip to content

Migrate Convert methods to Adapter, change Engine.Lusas namespace to Adapters.Lusas, add formatting to all documents and implement local versioning #240

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 12 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions Lusas_Adapter/CRUD/Create/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.Engine.Geometry;
using BH.Engine.Lusas.Object_Comparer.Equality_Comparer;
using BH.Engine.Adapters.Lusas.Object_Comparer.Equality_Comparer;
using BH.oM.Adapter;
using BH.oM.Adapters.Lusas;
using BH.oM.Structure.Elements;
Expand Down Expand Up @@ -169,7 +169,7 @@ private bool CreateCollection(IEnumerable<Node> nodes)
private bool CreateCollection(IEnumerable<Point> points)
{

List<Point> distinctPoints = Engine.Lusas.Query.GetDistinctPoints(points);
List<Point> distinctPoints = Engine.Adapters.Lusas.Query.GetDistinctPoints(points);

List<Point> existingPoints = ReadPoints();

Expand Down Expand Up @@ -268,12 +268,12 @@ private bool CreateCollection(IEnumerable<Panel> panels)

List<Edge> PanelEdges = new List<Edge>();

foreach (Panel Panel in panels)
foreach (Panel Panel in panels)
{
PanelEdges.AddRange(Panel.ExternalEdges);
}

List<Edge> distinctEdges = Engine.Lusas.Query.GetDistinctEdges(PanelEdges);
List<Edge> distinctEdges = Engine.Adapters.Lusas.Query.GetDistinctEdges(PanelEdges);

List<Point> midPoints = new List<Point>();

Expand Down Expand Up @@ -311,15 +311,15 @@ private bool CreateCollection(IEnumerable<Edge> edges)
{
List<Point> allPoints = new List<Point>();

List<Edge> distinctEdges = Engine.Lusas.Query.GetDistinctEdges(edges);
List<Edge> distinctEdges = Engine.Adapters.Lusas.Query.GetDistinctEdges(edges);

foreach (Edge edge in distinctEdges)
{
allPoints.Add(edge.Curve.IStartPoint());
allPoints.Add(edge.Curve.IEndPoint());
}

List<Point> distinctPoints = Engine.Lusas.Query.GetDistinctPoints(allPoints);
List<Point> distinctPoints = Engine.Adapters.Lusas.Query.GetDistinctPoints(allPoints);

List<Point> existingPoints = ReadPoints();
List<Point> pointsToPush = distinctPoints.Except(
Expand All @@ -339,7 +339,7 @@ private bool CreateCollection(IEnumerable<Edge> edges)

foreach (IFPoint point in lusasPoints)
{
bhomPoints.Add(Engine.Lusas.Convert.ToPoint(point));
bhomPoints.Add(Adapter.Adapters.Lusas.Convert.ToPoint(point));
}

CreateTags(distinctEdges);
Expand Down
7 changes: 6 additions & 1 deletion Lusas_Adapter/CRUD/Create/Elements/Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint)
{
IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint);
Expand All @@ -46,8 +50,9 @@ private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint)

return lusasLine;
}
}

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

}
}

14 changes: 11 additions & 3 deletions Lusas_Adapter/CRUD/Create/Elements/Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFLine CreateLine(Bar bar, IFMeshLine mesh)
{
if (
Expand Down Expand Up @@ -68,7 +72,7 @@ private IFLine CreateLine(Bar bar, IFMeshLine mesh)

IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", materialName);

if(bar.SectionProperty.Material is IOrthotropic)
if (bar.SectionProperty.Material is IOrthotropic)
{
Engine.Reflection.Compute.RecordWarning($"Orthotropic Material {bar.SectionProperty.Material.Name} cannot be assigned to Bar {bar.CustomData[AdapterIdName]}, " +
$"orthotropic can only be applied to 2D and 3D elements in Lusas.");
Expand Down Expand Up @@ -105,6 +109,8 @@ private IFLine CreateLine(Bar bar, IFMeshLine mesh)

}

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

private IFLine CreateLine(Bar bar, IFPoint startPoint, IFPoint endPoint)
{
if (
Expand Down Expand Up @@ -163,6 +169,8 @@ private IFLine CreateLine(Bar bar, IFPoint startPoint, IFPoint endPoint)
return lusasLine;
}

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

private IFLine CreateLine(ICurve iCurve, IFPoint startPoint, IFPoint endPoint)
{
Node startNode = Engine.Structure.Create.Node(
Expand All @@ -185,9 +193,9 @@ private IFLine CreateLine(ICurve iCurve, IFPoint startPoint, IFPoint endPoint)
IFLine lusasLine = CreateLine(bhomBar, startPoint, endPoint);
return lusasLine;
}
}


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

}
}

14 changes: 11 additions & 3 deletions Lusas_Adapter/CRUD/Create/Elements/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFPoint CreatePoint(Node node)
{
IFPoint lusasPoint;
Expand All @@ -53,15 +57,17 @@ private IFPoint CreatePoint(Node node)
return lusasPoint;
}

public IFPoint CreatePoint(Point point)
/***************************************************/

private IFPoint CreatePoint(Point point)
{
Node newNode = Engine.Structure.Create.Node(new Point { X = point.X, Y = point.Y, Z = point.Z });

int adapterID;
if (newNode.CustomData.ContainsKey(AdapterIdName))
adapterID= System.Convert.ToInt32(newNode.CustomData[AdapterIdName]);
adapterID = System.Convert.ToInt32(newNode.CustomData[AdapterIdName]);
else
adapterID= System.Convert.ToInt32(NextFreeId(newNode.GetType()));
adapterID = System.Convert.ToInt32(NextFreeId(newNode.GetType()));

newNode.CustomData[AdapterIdName] = adapterID;

Expand All @@ -70,6 +76,8 @@ public IFPoint CreatePoint(Point point)
return newPoint;
}

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

}
}

12 changes: 9 additions & 3 deletions Lusas_Adapter/CRUD/Create/Elements/Surface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFSurface CreateSurface(Panel panel, IFLine[] lusasLines)
{
IFSurface lusasSurface;
Expand All @@ -45,9 +49,9 @@ private IFSurface CreateSurface(Panel panel, IFLine[] lusasLines)
AssignObjectSet(lusasSurface, panel.Tags);
}

if(!(panel.Property == null))
if (!(panel.Property == null))
{
string geometricSurfaceName = "G" +
string geometricSurfaceName = "G" +
panel.Property.CustomData[AdapterIdName] + "/" + panel.Property.Name;

IFAttribute lusasGeometricSurface = d_LusasData.getAttribute(
Expand All @@ -56,7 +60,7 @@ private IFSurface CreateSurface(Panel panel, IFLine[] lusasLines)
lusasGeometricSurface.assignTo(lusasSurface);
if (!(panel.Property.Material == null))
{
string materialName = "M" + panel.Property.Material.CustomData[AdapterIdName] +
string materialName = "M" + panel.Property.Material.CustomData[AdapterIdName] +
"/" + panel.Property.Material.Name;

IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", materialName);
Expand All @@ -67,5 +71,7 @@ private IFSurface CreateSurface(Panel panel, IFLine[] lusasLines)
return lusasSurface;
}

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

}
}
11 changes: 9 additions & 2 deletions Lusas_Adapter/CRUD/Create/Loads/BarDistributedLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@
using System.Linq;
using BH.oM.Structure.Loads;
using Lusas.LPI;
using BH.Engine.Lusas;
using BH.Engine.Adapters.Lusas;

namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private List<IFLoadingBeamDistributed> CreateBarDistributedLoad(
BarVaryingDistributedLoad bhomBarDistributedLoad, object[] lusasLines)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(bhomBarDistributedLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(bhomBarDistributedLoad.Name))
{
return null;
}
Expand Down Expand Up @@ -163,5 +167,8 @@ private List<IFLoadingBeamDistributed> CreateBarDistributedLoad(
}
return lusasBarDistributedLoads;
}

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

}
}
9 changes: 8 additions & 1 deletion Lusas_Adapter/CRUD/Create/Loads/BarPointLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFLoadingBeamPoint CreateBarPointLoad(BarPointLoad bhomBarPointLoad, object[] lusasLines)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(bhomBarPointLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(bhomBarPointLoad.Name))
{
return null;
}
Expand Down Expand Up @@ -67,5 +71,8 @@ private IFLoadingBeamPoint CreateBarPointLoad(BarPointLoad bhomBarPointLoad, obj

return lusasBarPointLoad;
}

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

}
}
9 changes: 8 additions & 1 deletion Lusas_Adapter/CRUD/Create/Loads/ConcentratedLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFLoadingConcentrated CreateConcentratedLoad(PointLoad pointLoad, object[] lusasPoints)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(pointLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(pointLoad.Name))
{
return null;
}
Expand Down Expand Up @@ -59,6 +63,9 @@ private IFLoadingConcentrated CreateConcentratedLoad(PointLoad pointLoad, object

return lusasPointLoad;
}

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

}
}

35 changes: 26 additions & 9 deletions Lusas_Adapter/CRUD/Create/Loads/DistributedLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ namespace BH.Adapter.Lusas
{
public partial class LusasAdapter
{
/***************************************************/
/**** Private Methods ****/
/***************************************************/

private IFLoadingGlobalDistributed CreateGlobalDistributedLine(BarUniformlyDistributedLoad distributedLoad, object[] lusasLines)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
{
return null;
}
Expand All @@ -45,9 +49,11 @@ private IFLoadingGlobalDistributed CreateGlobalDistributedLine(BarUniformlyDistr
return lusasGlobalDistributed;
}

public IFLoadingGlobalDistributed CreateGlobalDistributedLoadSurface(AreaUniformlyDistributedLoad distributedLoad, object[] lusasSurfaces)
/***************************************************/

private IFLoadingGlobalDistributed CreateGlobalDistributedLoadSurface(AreaUniformlyDistributedLoad distributedLoad, object[] lusasSurfaces)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
{
return null;
}
Expand All @@ -63,9 +69,11 @@ public IFLoadingGlobalDistributed CreateGlobalDistributedLoadSurface(AreaUniform
return lusasGlobalDistributed;
}

public IFLoadingLocalDistributed CreateLocalDistributedLine(BarUniformlyDistributedLoad distributedLoad, object[] lusasLines)
/***************************************************/

private IFLoadingLocalDistributed CreateLocalDistributedLine(BarUniformlyDistributedLoad distributedLoad, object[] lusasLines)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
{
return null;
}
Expand All @@ -81,9 +89,11 @@ public IFLoadingLocalDistributed CreateLocalDistributedLine(BarUniformlyDistribu
return lusasLocalDistributed;
}

public IFLoadingLocalDistributed CreateLocalDistributedSurface(AreaUniformlyDistributedLoad distributedLoad, object[] lusasSurfaces)
/***************************************************/

private IFLoadingLocalDistributed CreateLocalDistributedSurface(AreaUniformlyDistributedLoad distributedLoad, object[] lusasSurfaces)
{
if (!Engine.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(distributedLoad.Name))
{
return null;
}
Expand All @@ -99,7 +109,9 @@ public IFLoadingLocalDistributed CreateLocalDistributedSurface(AreaUniformlyDist
return lusasLocalDistributed;
}

public IFLoadingGlobalDistributed CreateGlobalDistributed(string lusasName,
/***************************************************/

private IFLoadingGlobalDistributed CreateGlobalDistributed(string lusasName,
string type, IFLoadcase assignedLoadcase, Vector force, Vector moment, object[] lusasGeometry)
{

Expand Down Expand Up @@ -132,7 +144,9 @@ public IFLoadingGlobalDistributed CreateGlobalDistributed(string lusasName,
return lusasGlobalDistributed;
}

public IFLoadingLocalDistributed CreateLocalDistributed(string lusasName,
/***************************************************/

private IFLoadingLocalDistributed CreateLocalDistributed(string lusasName,
string type, IFLoadcase assignedLoadcase, Vector force, object[] lusasGeometry)
{

Expand All @@ -155,5 +169,8 @@ public IFLoadingLocalDistributed CreateLocalDistributed(string lusasName,

return lusasLocalDistributed;
}

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

}
}
Loading