Skip to content

Commit

Permalink
7.1 Deployment (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Greenroyd authored Mar 27, 2024
2 parents ab1ea55 + 91f5cdd commit 21ea1c4
Show file tree
Hide file tree
Showing 163 changed files with 999 additions and 294 deletions.
5 changes: 4 additions & 1 deletion Lusas_Adapter/AdapterActions/Execute.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -41,6 +41,8 @@ public partial class LusasV19Adapter
public partial class LusasV191Adapter
#elif Debug200 || Release200
public partial class LusasV200Adapter
#elif Debug210 || Release210
public partial class LusasV210Adapter
#else
public partial class LusasV17Adapter
#endif
Expand Down Expand Up @@ -298,3 +300,4 @@ private bool Analyse(IEnumerable<object> cases = null)
}



108 changes: 66 additions & 42 deletions Lusas_Adapter/CRUD/Create/Create.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand All @@ -20,26 +20,25 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System;
using System.Reflection;
using System.IO;
using System.Diagnostics;
using BH.Engine.Geometry;
using BH.Engine.Adapters.Lusas.Object_Comparer.Equality_Comparer;
using BH.oM.Adapter;
using BH.oM.Adapters.Lusas;
using BH.oM.Structure.Elements;
using BH.oM.Geometry;
using BH.oM.Structure.Constraints;
using BH.oM.Structure.SectionProperties;
using BH.oM.Structure.SurfaceProperties;
using BH.oM.Structure.Loads;
using BH.oM.Structure.MaterialFragments;
using BH.Engine.Adapter;
using Lusas.LPI;
using System.Collections.Generic;
using System.Linq;
using BH.Engine.Base.Objects;
using System;
using System.Reflection;
using BH.Engine.Base;
using BH.Engine.Spatial;
using BH.oM.Adapters.Lusas.Fragments;

namespace BH.Adapter.Lusas
Expand All @@ -52,6 +51,8 @@ public partial class LusasV19Adapter
public partial class LusasV191Adapter
#elif Debug200 || Release200
public partial class LusasV200Adapter
#elif Debug210 || Release210
public partial class LusasV210Adapter
#else
public partial class LusasV17Adapter
#endif
Expand Down Expand Up @@ -81,6 +82,10 @@ protected override bool ICreate<T>(IEnumerable<T> objects, ActionConfig actionCo
{
success = CreateCollection(objects as IEnumerable<Edge>);
}
else if (objects.First() is Opening)
{
success = CreateCollection(objects as IEnumerable<Opening>);
}
else if (objects.First() is Point)
{
success = CreateCollection(objects as IEnumerable<Point>);
Expand Down Expand Up @@ -175,15 +180,13 @@ private bool CreateCollection(IEnumerable<Node> nodes)
{
CreateTags(nodes);

ReduceRuntime(true);

foreach (Node node in nodes)
{
IFPoint lusasPoint = CreatePoint(node);
}

ReduceRuntime(false);
}

return true;
}

Expand All @@ -199,15 +202,12 @@ private bool CreateCollection(IEnumerable<Point> points)

List<Point> lusasPoints = distinctPoints.Except(existingPoints).ToList();

ReduceRuntime(true);

foreach (Point point in lusasPoints)
{
IFPoint lusasPoint = CreatePoint(point);
}

ReduceRuntime(false);
}

return true;
}

Expand All @@ -225,8 +225,6 @@ private bool CreateCollection(IEnumerable<Bar> bars)

BHoMObjectNameComparer comparer = new BHoMObjectNameComparer();

ReduceRuntime(true);

foreach (var barGroup in barGroups)
{
List<MeshSettings1D> distinctMeshes = barGroup.Select(x => x.FindFragment<MeshSettings1D>())
Expand All @@ -244,23 +242,19 @@ private bool CreateCollection(IEnumerable<Bar> bars)
IFLine lusasLine = CreateLine(bar);
}
}
ReduceRuntime(false);

d_LusasData.resetMesh();
d_LusasData.updateMesh();
}
else
{
ReduceRuntime(true);

foreach (Bar bar in bars)
{
IFLine lusasLine = CreateLine(bar);
}

ReduceRuntime(false);

}
}

return true;
}

Expand All @@ -281,12 +275,10 @@ private bool CreateCollection(IEnumerable<Panel> panels)
if (CheckPropertyError(panel, p => p.ExternalEdges))
if (CheckPropertyError(panel.ExternalEdges, e => e.Select(x => x.Curve)))
if (panel.ExternalEdges.All(x => x != null) && panel.ExternalEdges.Select(x => x.Curve).All(y => y != null))
{
if (panel.Openings.Count > 0)
Engine.Base.Compute.RecordWarning("Lusas_Toolkit does not support Panels with Openings. The Panel will be pushed if valid, the Openings will not be pushed.");
{
if (panel.ExternalEdges.All(x => !Engine.Adapters.Lusas.Query.InvalidEdge(x)))
{
if (Engine.Spatial.Query.IsPlanar(panel, false, Tolerance.MacroDistance))
if (Engine.Spatial.Query.IsPlanar(panel, true, m_mergeTolerance))
{
for (int i = 0; i < panel.ExternalEdges.Count; i++)
{
Expand Down Expand Up @@ -324,15 +316,13 @@ private bool CreateCollection(IEnumerable<Panel> panels)
validPanel.AddFragment(distinctMeshes.First(x => comparer.Equals(x, (validPanel.FindFragment<MeshSettings2D>()))), true);
}

ReduceRuntime(true);

IFSurface lusasSurface = null;

foreach (Panel validPanel in validPanels)
lusasSurface = CreateSurface(validPanel);

ReduceRuntime(false);
}

return true;
}

Expand Down Expand Up @@ -360,23 +350,17 @@ private bool CreateCollection(IEnumerable<Edge> edges)
List<Point> existingPoints = ReadPoints();
List<Point> pointsToPush = distinctPoints.Except(existingPoints, new PointDistanceComparer()).ToList();

ReduceRuntime(true);

foreach (Point point in pointsToPush)
{
IFPoint lusasPoint = CreatePoint(point);
}

ReduceRuntime(false);

List<Point> points = ReadPoints();

List<IFPoint> lusasPoints = ReadLusasPoints();

CreateTags(distinctEdges);

ReduceRuntime(true);

foreach (Edge edge in distinctEdges)
{
IFPoint startPoint = lusasPoints[points.FindIndex(
Expand All @@ -385,8 +369,54 @@ private bool CreateCollection(IEnumerable<Edge> edges)
m => m.Equals(edge.Curve.IEndPoint().ClosestPoint(points)))];
IFLine lusasLine = CreateEdge(edge, startPoint, endPoint);
}
}

return true;
}

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

private bool CreateCollection(IEnumerable<Opening> openings)
{
if (openings != null)
{
CreateTags(openings);

List<Opening> validOpenings = new List<Opening>();

foreach (Opening opening in openings)
{
if (CheckPropertyError(opening, p => p.Edges))
if (CheckPropertyError(opening.Edges, e => e.Select(x => x.Curve)))
{
if (opening.Edges.All(x => !Engine.Adapters.Lusas.Query.InvalidEdge(x)))
{
if (Engine.Spatial.Query.IsPlanar(opening, false, m_mergeTolerance)) //Check if this works.
{
for (int i = 0; i < opening.Edges.Count; i++)
{
if (!CheckPropertyError(opening, p => opening.Edges[i]) && Engine.Adapters.Lusas.Query.InvalidEdge(opening.Edges[i]))
break;

if (i == opening.Edges.Count - 1)
validOpenings.Add(opening);
}
}
else
Engine.Base.Compute.RecordError("The geometry defining one of the Openings of the Panel is not Planar, and therefore the Opening will not be created.");
}
else
Engine.Base.Compute.RecordError("One or more of the Internal Edges of the Panel are invalid, and therefore the Opening will not be created.");
}
else
Engine.Base.Compute.RecordError("One of more of the Internal Edges of the Panel or Curves defining the Opening are null.");
}


IFSurface lusasSurface = null;

ReduceRuntime(false);
foreach (Opening validOpening in validOpenings)
lusasSurface = CreateSurface(validOpening);
}
return true;
}
Expand All @@ -401,7 +431,6 @@ private bool CreateCollection(IEnumerable<ISectionProperty> sectionProperties)
{
IFAttribute lusasGeometricLine = CreateGeometricLine(sectionProperty);
}

}

return true;
Expand Down Expand Up @@ -734,9 +763,4 @@ private bool CreateCollection(IEnumerable<MeshSettings2D> meshSettings2Ds)
/***************************************************/

}
}





}
5 changes: 4 additions & 1 deletion Lusas_Adapter/CRUD/Create/Elements/Edge.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -36,6 +36,8 @@ public partial class LusasV19Adapter
public partial class LusasV191Adapter
#elif Debug200 || Release200
public partial class LusasV200Adapter
#elif Debug210 || Release210
public partial class LusasV210Adapter
#else
public partial class LusasV17Adapter
#endif
Expand Down Expand Up @@ -73,3 +75,4 @@ private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint)




17 changes: 10 additions & 7 deletions Lusas_Adapter/CRUD/Create/Elements/Line.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -42,6 +42,8 @@ public partial class LusasV19Adapter
public partial class LusasV191Adapter
#elif Debug200 || Release200
public partial class LusasV200Adapter
#elif Debug210 || Release210
public partial class LusasV210Adapter
#else
public partial class LusasV17Adapter
#endif
Expand All @@ -52,8 +54,8 @@ public partial class LusasV17Adapter

private IFLine CreateLine(Bar bar)
{
if (!CheckPropertyError(bar, b => b.StartNode, true) || !CheckPropertyError(bar, b => b.EndNode, true) ||
!CheckPropertyError(bar, b => b.StartNode.Position, true) || !CheckPropertyError(bar, b => b.EndNode.Position, true))
if (!CheckPropertyError(bar, b => b.Start, true) || !CheckPropertyError(bar, b => b.End, true) ||
!CheckPropertyError(bar, b => b.Start.Position, true) || !CheckPropertyError(bar, b => b.End.Position, true))
{
return null;
}
Expand All @@ -66,17 +68,17 @@ private IFLine CreateLine(Bar bar)
return null;
}

string startNodeId = GetAdapterId<string>(bar.StartNode);
string endNodeId = GetAdapterId<string>(bar.EndNode);
string startNodeId = GetAdapterId<string>(bar.Start);
string endNodeId = GetAdapterId<string>(bar.End);

if (string.IsNullOrEmpty(startNodeId) || string.IsNullOrEmpty(endNodeId))
{
Engine.Base.Compute.RecordError("Could not find the ids for at least one end node for at least one Bar. Bar not created.");
return null;
}

IFPoint startPoint = d_LusasData.getPointByNumber(bar.StartNode.AdapterId<int>(typeof(LusasId)));
IFPoint endPoint = d_LusasData.getPointByNumber(bar.EndNode.AdapterId<int>(typeof(LusasId)));
IFPoint startPoint = d_LusasData.getPointByNumber(bar.Start.AdapterId<int>(typeof(LusasId)));
IFPoint endPoint = d_LusasData.getPointByNumber(bar.End.AdapterId<int>(typeof(LusasId)));
IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint);

long adapterIdName = lusasLine.getID();
Expand Down Expand Up @@ -158,3 +160,4 @@ private IFLine CreateLine(Bar bar)




5 changes: 4 additions & 1 deletion Lusas_Adapter/CRUD/Create/Elements/Point.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -37,6 +37,8 @@ public partial class LusasV19Adapter
public partial class LusasV191Adapter
#elif Debug200 || Release200
public partial class LusasV200Adapter
#elif Debug210 || Release210
public partial class LusasV210Adapter
#else
public partial class LusasV17Adapter
#endif
Expand Down Expand Up @@ -97,3 +99,4 @@ private IFPoint CreatePoint(Point point)




Loading

0 comments on commit 21ea1c4

Please sign in to comment.