Skip to content

Commit

Permalink
Merge branch 'task/GSAGH-197-remove-graveyard' of https://github.com/…
Browse files Browse the repository at this point in the history
…arup-group/GSA-Grasshopper into task/GSAGH-197-remove-graveyard
  • Loading branch information
Kristjan Nielsen committed Oct 13, 2023
2 parents 060374d + 760daa2 commit b5a8c9a
Show file tree
Hide file tree
Showing 305 changed files with 8,963 additions and 5,630 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,6 @@ dist/*
/IntegrationTests/obj
/UnitTestGsaGH/bin/x64/Debug
/DocsGeneration/bin
/GsaGHTests/TestHelpers/DawnCache
/GsaGHTests/TestHelpers/GPUCache
*.lok
Binary file modified ExampleFiles/Components/Elem1dResults.gh
Binary file not shown.
Binary file modified ExampleFiles/Components/Elem2dResults.gh
Binary file not shown.
Binary file modified ExampleFiles/GsaGH_Example6_3dBoxes.gh
Binary file not shown.
Binary file modified ExampleFiles/Parameters/1_Properties/SectionModifierTests.gh
Binary file not shown.
Binary file not shown.
Binary file modified ExampleFiles/Parameters/ParametersCast.gh
Binary file not shown.
13 changes: 0 additions & 13 deletions GsaGH/Components/0_Model/CreateGridLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Drawing;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using GsaAPI;
using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;
Expand Down Expand Up @@ -52,12 +51,6 @@ protected override void SolveInstance(IGH_DataAccess da) {
// project onto WorldXY
line.FromZ = 0;
line.ToZ = 0;
if (line.Length == 0) {
string message = "Invalid input geometry, projected line has zero length.";
this.AddRuntimeWarning(message);
return;
}

gridLine = new GsaGridLine(line, label);
} else if (ghArc.CastFrom(curve)) {
Arc arc = ghArc.Value;
Expand All @@ -68,12 +61,6 @@ protected override void SolveInstance(IGH_DataAccess da) {
midPoint.Z = 0;
Point3d endPoint = arc.EndPoint;
endPoint.Z = 0;
if (arc.Length == 0) {
string message = "Invalid input geometry, projected arc has zero length.";
this.AddRuntimeWarning(message);
return;
}

gridLine = new GsaGridLine(arc, label);
} else {
string message = "Invalid input geometry, curve needs to be a straight line or a circular arc.";
Expand Down
35 changes: 20 additions & 15 deletions GsaGH/Components/0_Model/CreateModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System.Windows.Forms;
using GH_IO.Serialization;
using Grasshopper.Kernel;
using GsaGH.Helpers.Export;
using GsaGH.Components.GraveyardComp;
using GsaGH.Helpers;
using GsaGH.Helpers.Assembly;
using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;
Expand Down Expand Up @@ -153,20 +155,23 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
protected override void SolveInternal(IGH_DataAccess da) {
// Collect inputs
(List<GsaModel> models, List<GsaList> lists, List<GsaGridLine> gridLines) =
GetInputsForModelAssembly.GetModelsAndLists(this, da, 0, true);
(List<GsaMaterial> materials, List<GsaSection> sections, List<GsaProperty2d> prop2Ds,
List<GsaProperty3d> prop3Ds) = GetInputsForModelAssembly.GetProperties(this, da, 1, true);
InputsForModelAssembly.GetModelsAndLists(this, da, 0, true);
(List<GsaMaterial> materials, List<GsaSection> sections, List<GsaProperty2d> prop2Ds,
List<GsaProperty3d> prop3Ds) = InputsForModelAssembly.GetProperties(this, da, 1, true);
(List<GsaNode> nodes, List<GsaElement1d> elem1ds, List<GsaElement2d> elem2ds,
List<GsaElement3d> elem3ds, List<GsaMember1d> mem1ds, List<GsaMember2d> mem2ds,
List<GsaMember3d> mem3ds) = GetInputsForModelAssembly.GetGeometry(this, da, 2, true);
List<GsaMember3d> mem3ds) = InputsForModelAssembly.GetGeometry(this, da, 2, true);
(List<IGsaLoad> loads, List<GsaGridPlaneSurface> gridPlaneSurfaces, List<GsaLoadCase> loadCases)
= GetInputsForModelAssembly.GetLoading(this, da, 3, true);
= InputsForModelAssembly.GetLoading(this, da, 3, true);
(List<GsaAnalysisTask> analysisTasks, List<GsaCombinationCase> combinationCases)
= GetInputsForModelAssembly.GetAnalysis(this, da, 4, true);

if (models is null & lists is null & gridLines is null & nodes is null & elem1ds is null
& elem2ds is null & mem1ds is null & mem2ds is null & mem3ds is null & materials is null
& sections is null & prop2Ds is null & loads is null & gridPlaneSurfaces is null) {
= InputsForModelAssembly.GetAnalysis(this, da, 4, true);

if (models is null & lists is null & gridLines is null & nodes is null
& elem1ds is null & elem2ds is null & elem3ds is null
& mem1ds is null & mem2ds is null & mem3ds is null
& materials is null & sections is null & prop2Ds is null
& loads is null & loadCases is null & gridPlaneSurfaces is null
& analysisTasks is null & combinationCases is null) {
this.AddRuntimeWarning("Input parameters failed to collect data");
return;
}
Expand All @@ -181,10 +186,10 @@ protected override void SolveInternal(IGH_DataAccess da) {
}
}
// Assemble model
model.Model = Assembler.AssembleModel(
model, lists, gridLines, nodes, elem1ds, elem2ds, elem3ds, mem1ds, mem2ds, mem3ds,
materials, sections, prop2Ds, prop3Ds, loads, gridPlaneSurfaces, loadCases,
analysisTasks, combinationCases, _lengthUnit, ToleranceMenu.Tolerance, _reMesh, this);
var assembly = new ModelAssembly(model, lists, gridLines, nodes, elem1ds, elem2ds, elem3ds,
mem1ds, mem2ds, mem3ds, materials, sections, prop2Ds, prop3Ds, loads, gridPlaneSurfaces,
loadCases, analysisTasks, combinationCases, _lengthUnit, ToleranceMenu.Tolerance, _reMesh, this);
model.Model = assembly.GetModel();

ToleranceMenu.UpdateMessage(this, _lengthUnit);

Expand Down
3 changes: 1 addition & 2 deletions GsaGH/Components/0_Model/GetModelAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using Grasshopper.Kernel;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.Import;
using GsaGH.Parameters;
using GsaGH.Properties;
using OasysGH;
Expand Down Expand Up @@ -46,7 +45,7 @@ protected override void SolveInstance(IGH_DataAccess da) {
da.GetData(0, ref modelGoo);

Tuple<List<GsaAnalysisTaskGoo>, List<GsaAnalysisCaseGoo>> tuple
= Analyses.GetAnalysisTasksAndCombinations(modelGoo.Value);
= modelGoo.Value.GetAnalysisTasksAndCombinations();
var combinationCaseGoos = modelGoo.Value.Model.CombinationCases().Select(keyValuePair
=> new GsaCombinationCaseGoo(new GsaCombinationCase(keyValuePair))).ToList();

Expand Down
111 changes: 19 additions & 92 deletions GsaGH/Components/0_Model/GetModelGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,17 @@
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.Graphics;
using GsaGH.Helpers.Import;
using GsaGH.Parameters;
using GsaGH.Properties;
using Newtonsoft.Json;
using OasysGH;
using OasysGH.Components;
using OasysGH.Parameters;
using OasysGH.UI;
using OasysGH.Units;
using OasysGH.Units.Helpers;
using OasysUnits;
using OasysUnits.Serialization.JsonNet;
using Rhino.Commands;
using Rhino.Display;
using Rhino.Geometry;
using LengthUnit = OasysUnits.Units.LengthUnit;
Expand Down Expand Up @@ -59,23 +54,17 @@ private enum FoldMode {
public bool _isInitialised;
public List<string> _selectedItems;
public List<string> _spacerDescriptions;
public bool AlwaysExpireDownStream;
public Dictionary<int, List<string>> ExistingOutputsSerialized
= new Dictionary<int, List<string>>();
protected override Bitmap Icon => Resources.GetModelGeometry;
private static readonly OasysUnitsIQuantityJsonConverter converter
= new OasysUnitsIQuantityJsonConverter();
private BoundingBox _boundingBox;
private List<Mesh> _cachedDisplayMeshWithoutParent;
private List<Mesh> _cachedDisplayMeshWithParent;
private List<Mesh> _cachedDisplayNgonMeshWithoutParent;
private List<Mesh> _cachedDisplayNgonMeshWithParent;
private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry;
private FoldMode _mode = FoldMode.List;
private Dictionary<int, bool> _outputIsExpired = new Dictionary<int, bool>();
private Dictionary<int, List<bool>> _outputsAreExpired = new Dictionary<int, List<bool>>();
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 @@ -195,7 +184,6 @@ public override void DrawViewportWires(IGH_PreviewArgs args) {

if (node.Value.SupportPreview != null) {
if (!Attributes.Selected) {

if (node.Value.SupportPreview.SupportSymbol != null) {
args.Display.DrawBrepShaded(node.Value.SupportPreview.SupportSymbol, Colours.SupportSymbol);
}
Expand Down Expand Up @@ -240,35 +228,6 @@ public void InitialiseDropdowns() {
_isInitialised = true;
}

public void OutputChanged<T>(T data, int outputIndex, int index) where T : IGH_Goo {
if (!ExistingOutputsSerialized.ContainsKey(outputIndex)) {
ExistingOutputsSerialized.Add(outputIndex, new List<string>());
_outputsAreExpired.Add(outputIndex, new List<bool>());
}

string text;
if (data.GetType() == typeof(GH_UnitNumber)) {
text = JsonConvert.SerializeObject(((GH_UnitNumber)(object)data).Value, converter);
} else {
object value = data.ScriptVariable();
try {
text = JsonConvert.SerializeObject(value);
} catch (Exception) {
text = data.GetHashCode().ToString();
}
}

if (ExistingOutputsSerialized[outputIndex].Count == index) {
ExistingOutputsSerialized[outputIndex].Add(text);
_outputsAreExpired[outputIndex].Add(true);
} else if (ExistingOutputsSerialized[outputIndex][index] != text) {
ExistingOutputsSerialized[outputIndex][index] = text;
_outputsAreExpired[outputIndex][index] = true;
} else {
_outputsAreExpired[outputIndex][index] = false;
}
}

public override bool Read(GH_IReader reader) {
_mode = (FoldMode)reader.GetInt32("Mode");
ReadDropDownComponents(ref reader, ref _dropDownItems, ref _selectedItems,
Expand Down Expand Up @@ -415,24 +374,6 @@ protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown men
Menu_AppendItem(menu, "List", ListModeClicked, true, _mode == FoldMode.List);
}

protected override void ExpireDownStreamObjects() {
if (AlwaysExpireDownStream) {
base.ExpireDownStreamObjects();
return;
}

SetExpireDownStream();
if (_outputIsExpired.Count > 0) {
for (int i = 0; i < Params.Output.Count; i++) {
if (_outputIsExpired[i]) {
Params.Output[i].ExpireSolution(false);
}
}
} else {
base.ExpireDownStreamObjects();
}
}

protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager.AddParameter(new GsaModelParameter(), "GSA Model", "GSA",
"GSA model containing some geometry", GH_ParamAccess.item);
Expand Down Expand Up @@ -472,11 +413,10 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
"3D Members (Design Layer) from GSA Model imported to selected unit", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess data) {
protected override void SolveInternal(IGH_DataAccess data) {
if (InPreSolve) {
GsaModelGoo modelGoo = null;
data.GetData(0, ref modelGoo);
_boundingBox = modelGoo.Value.BoundingBox;

bool nodeFilterHasInput = false;
bool elementFilterHasInput = false;
Expand All @@ -489,7 +429,7 @@ protected override void SolveInstance(IGH_DataAccess data) {
return;
}

nodeList = nodeListGoo.Value.Definition;
nodeList = Inputs.GetNodeListDefinition(this, data, 1, modelGoo.Value);
nodeFilterHasInput = true;
}

Expand Down Expand Up @@ -528,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 @@ -739,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 @@ -748,41 +688,43 @@ 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;
}

private void GraftModeClicked(object sender, EventArgs e) {
internal void GraftModeClicked(object sender, EventArgs e) {
if (_mode == FoldMode.Graft) {
return;
}
Expand All @@ -796,7 +738,7 @@ private void GraftModeClicked(object sender, EventArgs e) {
ExpireSolution(true);
}

private void ListModeClicked(object sender, EventArgs e) {
internal void ListModeClicked(object sender, EventArgs e) {
if (_mode == FoldMode.List) {
return;
}
Expand All @@ -810,21 +752,6 @@ private void ListModeClicked(object sender, EventArgs e) {
ExpireSolution(true);
}

private void SetExpireDownStream() {
if (_outputsAreExpired == null || _outputsAreExpired.Count <= 0) {
return;
}

_outputIsExpired = new Dictionary<int, bool>();
for (int i = 0; i < Params.Output.Count; i++) {
if (_outputsAreExpired.ContainsKey(i)) {
_outputIsExpired.Add(i, _outputsAreExpired[i].Any(c => c));
} else {
_outputIsExpired.Add(i, true);
}
}
}

private void UpdateHiddenOutputs(bool nodeFilter, bool elementFilter, bool memberFilter) {
if (!nodeFilter && !elementFilter && !memberFilter) {
// set default display options
Expand Down
3 changes: 1 addition & 2 deletions GsaGH/Components/0_Model/GetModelGridLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using Grasshopper.Kernel;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.Import;
using GsaGH.Parameters;
using GsaGH.Properties;
using OasysGH;
Expand Down Expand Up @@ -35,7 +34,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
protected override void SolveInstance(IGH_DataAccess da) {
GsaModelGoo modelGoo = null;
da.GetData(0, ref modelGoo);
List<GsaGridLine> gridLines = GridLines.GetGridLines(modelGoo.Value);
List<GsaGridLine> gridLines = modelGoo.Value.GetGridLines();
da.SetDataList(0, gridLines.Select(x => new GsaGridLineGoo(x)));
}
}
Expand Down
3 changes: 1 addition & 2 deletions GsaGH/Components/0_Model/GetModelLists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using Grasshopper.Kernel;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.Import;
using GsaGH.Parameters;
using GsaGH.Properties;
using OasysGH;
Expand Down Expand Up @@ -40,7 +39,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
protected override void SolveInstance(IGH_DataAccess da) {
GsaModelGoo modelGoo = null;
da.GetData(0, ref modelGoo);
List<GsaList> lists = Lists.GetLists(modelGoo.Value);
List<GsaList> lists = modelGoo.Value.GetLists();
da.SetDataList(0, lists.Select(x => new GsaListGoo(x)));
}
}
Expand Down
Loading

0 comments on commit b5a8c9a

Please sign in to comment.