Skip to content

Commit 21ea1c4

Browse files
author
Fraser Greenroyd
authored
7.1 Deployment (#399)
2 parents ab1ea55 + 91f5cdd commit 21ea1c4

File tree

163 files changed

+999
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+999
-294
lines changed

Lusas_Adapter/AdapterActions/Execute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Buildings and Habitats object Model (BHoM)
3-
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
3+
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
44
*
55
* Each contributor holds copyright over their respective contributions.
66
* The project versioning (Git) records all such contribution source information.
@@ -41,6 +41,8 @@ public partial class LusasV19Adapter
4141
public partial class LusasV191Adapter
4242
#elif Debug200 || Release200
4343
public partial class LusasV200Adapter
44+
#elif Debug210 || Release210
45+
public partial class LusasV210Adapter
4446
#else
4547
public partial class LusasV17Adapter
4648
#endif
@@ -298,3 +300,4 @@ private bool Analyse(IEnumerable<object> cases = null)
298300
}
299301

300302

303+

Lusas_Adapter/CRUD/Create/Create.cs

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Buildings and Habitats object Model (BHoM)
3-
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
3+
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
44
*
55
* Each contributor holds copyright over their respective contributions.
66
* The project versioning (Git) records all such contribution source information.
@@ -20,26 +20,25 @@
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.Reflection;
25+
using System.IO;
26+
using System.Diagnostics;
2327
using BH.Engine.Geometry;
2428
using BH.Engine.Adapters.Lusas.Object_Comparer.Equality_Comparer;
2529
using BH.oM.Adapter;
26-
using BH.oM.Adapters.Lusas;
2730
using BH.oM.Structure.Elements;
2831
using BH.oM.Geometry;
2932
using BH.oM.Structure.Constraints;
3033
using BH.oM.Structure.SectionProperties;
3134
using BH.oM.Structure.SurfaceProperties;
3235
using BH.oM.Structure.Loads;
3336
using BH.oM.Structure.MaterialFragments;
34-
using BH.Engine.Adapter;
3537
using Lusas.LPI;
3638
using System.Collections.Generic;
3739
using System.Linq;
3840
using BH.Engine.Base.Objects;
39-
using System;
40-
using System.Reflection;
4141
using BH.Engine.Base;
42-
using BH.Engine.Spatial;
4342
using BH.oM.Adapters.Lusas.Fragments;
4443

4544
namespace BH.Adapter.Lusas
@@ -52,6 +51,8 @@ public partial class LusasV19Adapter
5251
public partial class LusasV191Adapter
5352
#elif Debug200 || Release200
5453
public partial class LusasV200Adapter
54+
#elif Debug210 || Release210
55+
public partial class LusasV210Adapter
5556
#else
5657
public partial class LusasV17Adapter
5758
#endif
@@ -81,6 +82,10 @@ protected override bool ICreate<T>(IEnumerable<T> objects, ActionConfig actionCo
8182
{
8283
success = CreateCollection(objects as IEnumerable<Edge>);
8384
}
85+
else if (objects.First() is Opening)
86+
{
87+
success = CreateCollection(objects as IEnumerable<Opening>);
88+
}
8489
else if (objects.First() is Point)
8590
{
8691
success = CreateCollection(objects as IEnumerable<Point>);
@@ -175,15 +180,13 @@ private bool CreateCollection(IEnumerable<Node> nodes)
175180
{
176181
CreateTags(nodes);
177182

178-
ReduceRuntime(true);
179-
180183
foreach (Node node in nodes)
181184
{
182185
IFPoint lusasPoint = CreatePoint(node);
183186
}
184187

185-
ReduceRuntime(false);
186188
}
189+
187190
return true;
188191
}
189192

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

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

202-
ReduceRuntime(true);
203-
204205
foreach (Point point in lusasPoints)
205206
{
206207
IFPoint lusasPoint = CreatePoint(point);
207208
}
208-
209-
ReduceRuntime(false);
210209
}
210+
211211
return true;
212212
}
213213

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

226226
BHoMObjectNameComparer comparer = new BHoMObjectNameComparer();
227227

228-
ReduceRuntime(true);
229-
230228
foreach (var barGroup in barGroups)
231229
{
232230
List<MeshSettings1D> distinctMeshes = barGroup.Select(x => x.FindFragment<MeshSettings1D>())
@@ -244,23 +242,19 @@ private bool CreateCollection(IEnumerable<Bar> bars)
244242
IFLine lusasLine = CreateLine(bar);
245243
}
246244
}
247-
ReduceRuntime(false);
245+
248246
d_LusasData.resetMesh();
249247
d_LusasData.updateMesh();
250248
}
251249
else
252250
{
253-
ReduceRuntime(true);
254-
255251
foreach (Bar bar in bars)
256252
{
257253
IFLine lusasLine = CreateLine(bar);
258254
}
259-
260-
ReduceRuntime(false);
261-
262255
}
263256
}
257+
264258
return true;
265259
}
266260

@@ -281,12 +275,10 @@ private bool CreateCollection(IEnumerable<Panel> panels)
281275
if (CheckPropertyError(panel, p => p.ExternalEdges))
282276
if (CheckPropertyError(panel.ExternalEdges, e => e.Select(x => x.Curve)))
283277
if (panel.ExternalEdges.All(x => x != null) && panel.ExternalEdges.Select(x => x.Curve).All(y => y != null))
284-
{
285-
if (panel.Openings.Count > 0)
286-
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.");
278+
{
287279
if (panel.ExternalEdges.All(x => !Engine.Adapters.Lusas.Query.InvalidEdge(x)))
288280
{
289-
if (Engine.Spatial.Query.IsPlanar(panel, false, Tolerance.MacroDistance))
281+
if (Engine.Spatial.Query.IsPlanar(panel, true, m_mergeTolerance))
290282
{
291283
for (int i = 0; i < panel.ExternalEdges.Count; i++)
292284
{
@@ -324,15 +316,13 @@ private bool CreateCollection(IEnumerable<Panel> panels)
324316
validPanel.AddFragment(distinctMeshes.First(x => comparer.Equals(x, (validPanel.FindFragment<MeshSettings2D>()))), true);
325317
}
326318

327-
ReduceRuntime(true);
328-
329319
IFSurface lusasSurface = null;
330320

331321
foreach (Panel validPanel in validPanels)
332322
lusasSurface = CreateSurface(validPanel);
333323

334-
ReduceRuntime(false);
335324
}
325+
336326
return true;
337327
}
338328

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

363-
ReduceRuntime(true);
364-
365353
foreach (Point point in pointsToPush)
366354
{
367355
IFPoint lusasPoint = CreatePoint(point);
368356
}
369357

370-
ReduceRuntime(false);
371-
372358
List<Point> points = ReadPoints();
373359

374360
List<IFPoint> lusasPoints = ReadLusasPoints();
375361

376362
CreateTags(distinctEdges);
377363

378-
ReduceRuntime(true);
379-
380364
foreach (Edge edge in distinctEdges)
381365
{
382366
IFPoint startPoint = lusasPoints[points.FindIndex(
@@ -385,8 +369,54 @@ private bool CreateCollection(IEnumerable<Edge> edges)
385369
m => m.Equals(edge.Curve.IEndPoint().ClosestPoint(points)))];
386370
IFLine lusasLine = CreateEdge(edge, startPoint, endPoint);
387371
}
372+
}
373+
374+
return true;
375+
}
376+
377+
/***************************************************/
378+
379+
private bool CreateCollection(IEnumerable<Opening> openings)
380+
{
381+
if (openings != null)
382+
{
383+
CreateTags(openings);
384+
385+
List<Opening> validOpenings = new List<Opening>();
386+
387+
foreach (Opening opening in openings)
388+
{
389+
if (CheckPropertyError(opening, p => p.Edges))
390+
if (CheckPropertyError(opening.Edges, e => e.Select(x => x.Curve)))
391+
{
392+
if (opening.Edges.All(x => !Engine.Adapters.Lusas.Query.InvalidEdge(x)))
393+
{
394+
if (Engine.Spatial.Query.IsPlanar(opening, false, m_mergeTolerance)) //Check if this works.
395+
{
396+
for (int i = 0; i < opening.Edges.Count; i++)
397+
{
398+
if (!CheckPropertyError(opening, p => opening.Edges[i]) && Engine.Adapters.Lusas.Query.InvalidEdge(opening.Edges[i]))
399+
break;
400+
401+
if (i == opening.Edges.Count - 1)
402+
validOpenings.Add(opening);
403+
}
404+
}
405+
else
406+
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.");
407+
}
408+
else
409+
Engine.Base.Compute.RecordError("One or more of the Internal Edges of the Panel are invalid, and therefore the Opening will not be created.");
410+
}
411+
else
412+
Engine.Base.Compute.RecordError("One of more of the Internal Edges of the Panel or Curves defining the Opening are null.");
413+
}
414+
415+
416+
IFSurface lusasSurface = null;
388417

389-
ReduceRuntime(false);
418+
foreach (Opening validOpening in validOpenings)
419+
lusasSurface = CreateSurface(validOpening);
390420
}
391421
return true;
392422
}
@@ -401,7 +431,6 @@ private bool CreateCollection(IEnumerable<ISectionProperty> sectionProperties)
401431
{
402432
IFAttribute lusasGeometricLine = CreateGeometricLine(sectionProperty);
403433
}
404-
405434
}
406435

407436
return true;
@@ -734,9 +763,4 @@ private bool CreateCollection(IEnumerable<MeshSettings2D> meshSettings2Ds)
734763
/***************************************************/
735764

736765
}
737-
}
738-
739-
740-
741-
742-
766+
}

Lusas_Adapter/CRUD/Create/Elements/Edge.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Buildings and Habitats object Model (BHoM)
3-
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
3+
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
44
*
55
* Each contributor holds copyright over their respective contributions.
66
* The project versioning (Git) records all such contribution source information.
@@ -36,6 +36,8 @@ public partial class LusasV19Adapter
3636
public partial class LusasV191Adapter
3737
#elif Debug200 || Release200
3838
public partial class LusasV200Adapter
39+
#elif Debug210 || Release210
40+
public partial class LusasV210Adapter
3941
#else
4042
public partial class LusasV17Adapter
4143
#endif
@@ -73,3 +75,4 @@ private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint)
7375

7476

7577

78+

Lusas_Adapter/CRUD/Create/Elements/Line.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Buildings and Habitats object Model (BHoM)
3-
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
3+
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
44
*
55
* Each contributor holds copyright over their respective contributions.
66
* The project versioning (Git) records all such contribution source information.
@@ -42,6 +42,8 @@ public partial class LusasV19Adapter
4242
public partial class LusasV191Adapter
4343
#elif Debug200 || Release200
4444
public partial class LusasV200Adapter
45+
#elif Debug210 || Release210
46+
public partial class LusasV210Adapter
4547
#else
4648
public partial class LusasV17Adapter
4749
#endif
@@ -52,8 +54,8 @@ public partial class LusasV17Adapter
5254

5355
private IFLine CreateLine(Bar bar)
5456
{
55-
if (!CheckPropertyError(bar, b => b.StartNode, true) || !CheckPropertyError(bar, b => b.EndNode, true) ||
56-
!CheckPropertyError(bar, b => b.StartNode.Position, true) || !CheckPropertyError(bar, b => b.EndNode.Position, true))
57+
if (!CheckPropertyError(bar, b => b.Start, true) || !CheckPropertyError(bar, b => b.End, true) ||
58+
!CheckPropertyError(bar, b => b.Start.Position, true) || !CheckPropertyError(bar, b => b.End.Position, true))
5759
{
5860
return null;
5961
}
@@ -66,17 +68,17 @@ private IFLine CreateLine(Bar bar)
6668
return null;
6769
}
6870

69-
string startNodeId = GetAdapterId<string>(bar.StartNode);
70-
string endNodeId = GetAdapterId<string>(bar.EndNode);
71+
string startNodeId = GetAdapterId<string>(bar.Start);
72+
string endNodeId = GetAdapterId<string>(bar.End);
7173

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

78-
IFPoint startPoint = d_LusasData.getPointByNumber(bar.StartNode.AdapterId<int>(typeof(LusasId)));
79-
IFPoint endPoint = d_LusasData.getPointByNumber(bar.EndNode.AdapterId<int>(typeof(LusasId)));
80+
IFPoint startPoint = d_LusasData.getPointByNumber(bar.Start.AdapterId<int>(typeof(LusasId)));
81+
IFPoint endPoint = d_LusasData.getPointByNumber(bar.End.AdapterId<int>(typeof(LusasId)));
8082
IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint);
8183

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

159161

160162

163+

Lusas_Adapter/CRUD/Create/Elements/Point.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Buildings and Habitats object Model (BHoM)
3-
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
3+
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
44
*
55
* Each contributor holds copyright over their respective contributions.
66
* The project versioning (Git) records all such contribution source information.
@@ -37,6 +37,8 @@ public partial class LusasV19Adapter
3737
public partial class LusasV191Adapter
3838
#elif Debug200 || Release200
3939
public partial class LusasV200Adapter
40+
#elif Debug210 || Release210
41+
public partial class LusasV210Adapter
4042
#else
4143
public partial class LusasV17Adapter
4244
#endif
@@ -97,3 +99,4 @@ private IFPoint CreatePoint(Point point)
9799

98100

99101

102+

0 commit comments

Comments
 (0)