/***************************************************/ private bool CreateCollection(IEnumerable <Bar> bars) { if (bars != null) { CreateTags(bars); if (bars.Any(x => x.Fragments.Contains(typeof(MeshSettings1D)))) { var barGroups = bars.GroupBy(m => new { m.FEAType, m.Release?.Name }); BHoMObjectNameComparer comparer = new BHoMObjectNameComparer(); ReduceRuntime(true); foreach (var barGroup in barGroups) { List <MeshSettings1D> distinctMeshes = barGroup.Select(x => x.FindFragment <MeshSettings1D>()) .Distinct <MeshSettings1D>(comparer) .ToList(); foreach (MeshSettings1D mesh in distinctMeshes) { CreateMeshSettings1D(mesh, barGroup.First().FEAType, barGroup.First().Release); } foreach (Bar bar in barGroup) { bar.AddFragment(distinctMeshes.First(x => comparer.Equals(x, bar.FindFragment <MeshSettings1D>())), true); 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); }
/***************************************************/ private bool CreateCollection(IEnumerable <Panel> panels) { if (panels != null) { CreateTags(panels); List <Panel> validPanels = new List <Panel>(); foreach (Panel panel in panels) { if (panel.ExternalEdges.Count > 0) { 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)) { for (int i = 0; i < panel.ExternalEdges.Count; i++) { if (!CheckPropertyError(panel, p => panel.ExternalEdges[i]) && Engine.Adapters.Lusas.Query.InvalidEdge(panel.ExternalEdges[i])) { break; } if (i == panel.ExternalEdges.Count - 1) { validPanels.Add(panel); } } } else { Engine.Base.Compute.RecordError("The geometry defining the Panel is not Planar, and therefore the Panel will not be created."); } } else { Engine.Base.Compute.RecordError("One or more of the External Edges of the Panel are invalid."); } } else { Engine.Base.Compute.RecordError("One of more of the External Edges of the Panel or Curves defining the External Edges are null."); } } } } else { Engine.Base.Compute.RecordError($"An object of type {panel.GetType().Name} could not be created due to a property of type {typeof(Edge).Name} being null. Please check your input data!"); } } if (validPanels.Any(x => x.Fragments.Contains(typeof(MeshSettings2D)))) { BHoMObjectNameComparer comparer = new BHoMObjectNameComparer(); List <MeshSettings2D> distinctMeshes = panels.Select(x => x.FindFragment <MeshSettings2D>()) .Distinct <MeshSettings2D>(comparer) .ToList(); foreach (MeshSettings2D mesh in distinctMeshes) { CreateMeshSettings2D(mesh); } foreach (Panel validPanel in validPanels) { 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); }