From 16c355aa4731040f71014c371854e1ab6ad9122b Mon Sep 17 00:00:00 2001 From: Kristjan Nielsen Date: Fri, 6 Oct 2023 16:12:05 +0200 Subject: [PATCH] recalculate boundingbox when ModelUnit changes --- GsaGH/Components/0_Model/GetModelGeometry.cs | 28 +++++++++++--------- GsaGH/Parameters/0_Model/GsaModel.cs | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/GsaGH/Components/0_Model/GetModelGeometry.cs b/GsaGH/Components/0_Model/GetModelGeometry.cs index 6bdaa67df..5a522a3a4 100644 --- a/GsaGH/Components/0_Model/GetModelGeometry.cs +++ b/GsaGH/Components/0_Model/GetModelGeometry.cs @@ -64,6 +64,7 @@ private enum FoldMode { private FoldMode _mode = FoldMode.List; private ConcurrentBag _supportNodes; private bool _showSupports = true; + private SolveResults _results; public GetModelGeometry() : base("Get Model Geometry", "GetGeo", "Get nodes, elements and members from GSA model", CategoryName.Name(), @@ -416,7 +417,6 @@ protected override void SolveInstance(IGH_DataAccess data) { if (InPreSolve) { GsaModelGoo modelGoo = null; data.GetData(0, ref modelGoo); - _boundingBox = modelGoo.Value.BoundingBox; bool nodeFilterHasInput = false; bool elementFilterHasInput = false; @@ -468,7 +468,7 @@ protected override void SolveInstance(IGH_DataAccess data) { if (!GetSolveResults(data, out SolveResults results)) { GsaModelGoo modelGoo = null; data.GetData(0, ref modelGoo); - + GsaListGoo nodeListGoo = null; string nodeList = "all"; if (data.GetData(1, ref nodeListGoo)) { @@ -679,7 +679,7 @@ protected override void SolveInstance(IGH_DataAccess data) { } private SolveResults Compute(GsaModel model, string nodeList, string elemList, string memList) { - var results = new SolveResults(); + _results = new SolveResults(); var steps = new List { 0, 1, 2, }; @@ -688,30 +688,32 @@ private SolveResults Compute(GsaModel model, string nodeList, string elemList, s model.ModelUnit = _lengthUnit; } + _boundingBox = model.BoundingBox; + try { Parallel.ForEach(steps, i => { switch (i) { case 0: - results.Nodes = Nodes.GetNodes( + _results.Nodes = Nodes.GetNodes( nodeList.ToLower() == "all" ? model.ApiNodes : model.Model.Nodes(nodeList), model.ModelUnit, model.ApiAxis); - results.DisplaySupports - = new ConcurrentBag(results.Nodes.Where(n => n.Value.IsSupport)); + _results.DisplaySupports + = new ConcurrentBag(_results.Nodes.Where(n => n.Value.IsSupport)); break; case 1: var elements = new Elements(model, elemList); - results.Elem1ds = elements.Element1ds; - results.Elem2ds = elements.Element2ds; - results.Elem3ds = elements.Element3ds; + _results.Elem1ds = elements.Element1ds; + _results.Elem2ds = elements.Element2ds; + _results.Elem3ds = elements.Element3ds; break; case 2: var members = new Members(model, memList, this); - results.Mem1ds = members.Member1ds; - results.Mem2ds = members.Member2ds; - results.Mem3ds = members.Member3ds; + _results.Mem1ds = members.Member1ds; + _results.Mem2ds = members.Member2ds; + _results.Mem3ds = members.Member3ds; break; } }); @@ -719,7 +721,7 @@ private SolveResults Compute(GsaModel model, string nodeList, string elemList, s this.AddRuntimeWarning(e.InnerException?.Message); } - return results; + return _results; } internal void GraftModeClicked(object sender, EventArgs e) { diff --git a/GsaGH/Parameters/0_Model/GsaModel.cs b/GsaGH/Parameters/0_Model/GsaModel.cs index e61c1b55a..ffb3cfae6 100644 --- a/GsaGH/Parameters/0_Model/GsaModel.cs +++ b/GsaGH/Parameters/0_Model/GsaModel.cs @@ -37,6 +37,7 @@ public LengthUnit ModelUnit { set { _lengthUnit = value; Units.LengthLarge = UnitMapping.GetApiUnit(_lengthUnit); + _boundingBox = BoundingBox.Empty; _analysisLayerPreview = null; _designLayerPreview = null; }