Skip to content

Commit

Permalink
GsaGH-387 recalculate boundingbox when ModelUnit changes (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpne authored Oct 6, 2023
2 parents 80a217a + b35d6ca commit 45e44f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
28 changes: 15 additions & 13 deletions GsaGH/Components/0_Model/GetModelGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private enum FoldMode {
private FoldMode _mode = FoldMode.List;
private ConcurrentBag<GsaNodeGoo> _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(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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<int> {
0, 1, 2,
};
Expand All @@ -688,38 +688,40 @@ 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<GsaNodeGoo>(results.Nodes.Where(n => n.Value.IsSupport));
_results.DisplaySupports
= new ConcurrentBag<GsaNodeGoo>(_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;
}
});
} catch (Exception e) {
this.AddRuntimeWarning(e.InnerException?.Message);
}

return results;
return _results;
}

internal void GraftModeClicked(object sender, EventArgs e) {
Expand Down
1 change: 1 addition & 0 deletions GsaGH/Parameters/0_Model/GsaModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public LengthUnit ModelUnit {
set {
_lengthUnit = value;
Units.LengthLarge = UnitMapping.GetApiUnit(_lengthUnit);
_boundingBox = BoundingBox.Empty;
_analysisLayerPreview = null;
_designLayerPreview = null;
}
Expand Down

0 comments on commit 45e44f9

Please sign in to comment.