Skip to content

Commit

Permalink
gsagh-248 parameters/5_results dir clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikaLos committed Mar 27, 2023
1 parent ac48bd0 commit 1c4c2a2
Show file tree
Hide file tree
Showing 32 changed files with 1,616 additions and 1,528 deletions.
19 changes: 9 additions & 10 deletions GsaGH/Components/5_Results/BeamDispResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public BeamDisplacement() : base("Beam Displacements",
"BeamDisp",
"Element1D Translation and Rotation result values",
CategoryName.Name(),
SubCategoryName.Cat5()) {
Hidden = true;
}
SubCategoryName.Cat5()) => Hidden = true;
#endregion

#region Input and output
Expand Down Expand Up @@ -96,10 +94,11 @@ protected override void SolveInstance(IGH_DataAccess da) {
}

foreach (GH_ObjectWrapper ghTyp in ghTypes) {
if (ghTyp == null || ghTyp.Value == null) {
if (ghTyp?.Value == null) {
this.AddRuntimeWarning("Input is null");
return;
}

if (ghTyp.Value is GsaResultGoo goo) {
result = goo.Value;
}
Expand All @@ -118,8 +117,8 @@ protected override void SolveInstance(IGH_DataAccess da) {

// loop through all permutations (analysis case will just have one)
foreach (int perm in permutations) {
if (vals[perm - 1].xyzResults.Count == 0
& vals[perm - 1].xxyyzzResults.Count == 0) {
if (vals[perm - 1].XyzResults.Count == 0
& vals[perm - 1].XxyyzzResults.Count == 0) {
string acase = result.ToString().Replace('}', ' ').Replace('{', ' ');
this.AddRuntimeWarning("Case " + acase + " contains no Element1D results.");
continue;
Expand All @@ -128,7 +127,7 @@ protected override void SolveInstance(IGH_DataAccess da) {
{
switch (thread) {
case 0: {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].xyzResults) {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].XyzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) { continue; }
Expand All @@ -142,13 +141,13 @@ protected override void SolveInstance(IGH_DataAccess da) {
outTransX.AddRange(res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_lengthUnit))), path); // use ToUnit to capture changes in dropdown
outTransY.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_lengthUnit))), path);
outTransZ.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_lengthUnit))), path);
outTransXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.XYZ.ToUnit(_lengthUnit))), path);
outTransXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_lengthUnit))), path);
}
break;
}
case 1: {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].xxyyzzResults) {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].XxyyzzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) { continue; }
Expand All @@ -162,7 +161,7 @@ protected override void SolveInstance(IGH_DataAccess da) {
outRotX.AddRange(res.Select(x => new GH_UnitNumber(x.Value.X)), path); // always use [rad] units
outRotY.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Y)), path);
outRotZ.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Z)), path);
outRotXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.XYZ)), path);
outRotXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Xyz)), path);
}
break;
Expand Down
23 changes: 9 additions & 14 deletions GsaGH/Components/5_Results/BeamForceResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public BeamForces() : base("Beam Forces and Moments",
"BeamForces",
"Element1D Force and Moment result values",
CategoryName.Name(),
SubCategoryName.Cat5()) {
Hidden = true;
}
SubCategoryName.Cat5()) => Hidden = true;
#endregion

#region Input and output
Expand Down Expand Up @@ -98,8 +96,6 @@ protected override void SolveInstance(IGH_DataAccess da) {
return;
}

var results = new List<GsaResult>();

foreach (GH_ObjectWrapper ghTyp in ghTypes) {
switch (ghTyp?.Value) {
case null:
Expand All @@ -115,15 +111,13 @@ protected override void SolveInstance(IGH_DataAccess da) {

List<GsaResultsValues> vals = result.Element1DForceValues(elementlist, positionsCount, _forceUnit, _momentUnit);

List<int> permutations = result.SelectedPermutationIds == null
? new List<int>() { 1 }
: result.SelectedPermutationIds;
List<int> permutations = result.SelectedPermutationIds ?? new List<int>() { 1 };
if (permutations.Count == 1 && permutations[0] == -1)
permutations = Enumerable.Range(1, vals.Count).ToList();

foreach (int perm in permutations) {
if (vals[perm - 1].xyzResults.Count == 0
& vals[perm - 1].xxyyzzResults.Count == 0) {
if (vals[perm - 1].XyzResults.Count == 0
& vals[perm - 1].XxyyzzResults.Count == 0) {
string acase = result.ToString().Replace('}', ' ').Replace('{', ' ');
this.AddRuntimeWarning("Case " + acase + " contains no Element1D results.");
continue;
Expand All @@ -132,7 +126,7 @@ protected override void SolveInstance(IGH_DataAccess da) {
{
switch (thread) {
case 0: {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].xyzResults) {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].XyzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) { continue; }
Expand All @@ -146,12 +140,12 @@ protected override void SolveInstance(IGH_DataAccess da) {
outTransX.AddRange(res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_forceUnit))), path); // use ToUnit to capture changes in dropdown
outTransY.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_forceUnit))), path);
outTransZ.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_forceUnit))), path);
outTransXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.XYZ.ToUnit(_forceUnit))), path);
outTransXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_forceUnit))), path);
}
break;
}
case 1: {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].xxyyzzResults) {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].XxyyzzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) { continue; }
Expand All @@ -165,7 +159,7 @@ protected override void SolveInstance(IGH_DataAccess da) {
outRotX.AddRange(res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_momentUnit))), path); // always use [rad] units
outRotY.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_momentUnit))), path);
outRotZ.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_momentUnit))), path);
outRotXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.XYZ.ToUnit(_momentUnit))), path);
outRotXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_momentUnit))), path);
}
break;
}
Expand Down Expand Up @@ -217,6 +211,7 @@ public override void SetSelected(int i, int j) {
_momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), SelectedItems[i]);
break;
}

base.UpdateUI();
}
public override void UpdateUIFromSelectedItems() {
Expand Down
8 changes: 3 additions & 5 deletions GsaGH/Components/5_Results/BeamStrainEnergyResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public BeamStrainEnergy() : base("Beam Strain Energy Density",
"StrainEnergy",
"Element1D Strain Energy Density result values",
CategoryName.Name(),
SubCategoryName.Cat5()) {
Hidden = true;
}
SubCategoryName.Cat5()) => Hidden = true;
#endregion

#region Input and output
Expand Down Expand Up @@ -106,12 +104,12 @@ protected override void SolveInstance(IGH_DataAccess da) {
permutations = Enumerable.Range(1, vals.Count).ToList();

foreach (int perm in permutations) {
if (vals[perm - 1].xyzResults.Count == 0) {
if (vals[perm - 1].XyzResults.Count == 0) {
string acase = result.ToString().Replace('}', ' ').Replace('{', ' ');
this.AddRuntimeWarning("Case " + acase + " contains no Element1D results.");
continue;
}
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].xyzResults) {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in vals[perm - 1].XyzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) { continue; }
Expand Down
39 changes: 20 additions & 19 deletions GsaGH/Components/5_Results/Elem1dContourResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ protected override void SolveInstance(IGH_DataAccess da) {
var elems = new ConcurrentDictionary<int, Element>(result.Model.Model.Elements(elementlist));
var nodes = new ConcurrentDictionary<int, Node>(result.Model.Model.Nodes());

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults = res.xyzResults;
ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xxyyzzResults = res.xxyyzzResults;
ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults = res.XyzResults;
ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xxyyzzResults = res.XxyyzzResults;

Enum xyzunit = _lengthResultUnit;
Enum xxyyzzunit = AngleUnit.Radian;
Expand Down Expand Up @@ -278,10 +278,12 @@ protected override void SolveInstance(IGH_DataAccess da) {

break;
}

if (customMinMax != Interval.Unset) {
dmin = customMinMax.Min;
dmax = customMinMax.Max;
}

List<double> rounded = ResultHelper.SmartRounder(dmax, dmin);
dmax = rounded[0];
dmin = rounded[1];
Expand Down Expand Up @@ -349,8 +351,8 @@ protected override void SolveInstance(IGH_DataAccess da) {
endTranslation.Z = xyzResults[key][i + 1].Z.As(lengthUnit) * _defScale;
break;
case (DisplayValue.ResXyz):
t1 = xyzResults[key][i].XYZ.ToUnit(_lengthResultUnit);
t2 = xyzResults[key][i + 1].XYZ.ToUnit(_lengthResultUnit);
t1 = xyzResults[key][i].Xyz.ToUnit(_lengthResultUnit);
t2 = xyzResults[key][i + 1].Xyz.ToUnit(_lengthResultUnit);
startTranslation.X = xyzResults[key][i].X.As(lengthUnit) * _defScale;
startTranslation.Y = xyzResults[key][i].Y.As(lengthUnit) * _defScale;
startTranslation.Z = xyzResults[key][i].Z.As(lengthUnit) * _defScale;
Expand All @@ -371,8 +373,8 @@ protected override void SolveInstance(IGH_DataAccess da) {
t2 = xxyyzzResults[key][i + 1].Z.ToUnit(AngleUnit.Radian);
break;
case (DisplayValue.ResXxyyzz):
t1 = xxyyzzResults[key][i].XYZ.ToUnit(AngleUnit.Radian);
t2 = xxyyzzResults[key][i + 1].XYZ.ToUnit(AngleUnit.Radian);
t1 = xxyyzzResults[key][i].Xyz.ToUnit(AngleUnit.Radian);
t2 = xxyyzzResults[key][i + 1].Xyz.ToUnit(AngleUnit.Radian);
break;
}
start.Transform(Transform.Translation(startTranslation));
Expand All @@ -393,8 +395,8 @@ protected override void SolveInstance(IGH_DataAccess da) {
t2 = xyzResults[key][i + 1].Z.ToUnit(_forceUnit);
break;
case (DisplayValue.ResXyz):
t1 = xyzResults[key][i].XYZ.ToUnit(_forceUnit);
t2 = xyzResults[key][i + 1].XYZ.ToUnit(_forceUnit);
t1 = xyzResults[key][i].Xyz.ToUnit(_forceUnit);
t2 = xyzResults[key][i + 1].Xyz.ToUnit(_forceUnit);
break;
case (DisplayValue.Xx):
t1 = xxyyzzResults[key][i].X.ToUnit(_momentUnit);
Expand All @@ -409,8 +411,8 @@ protected override void SolveInstance(IGH_DataAccess da) {
t2 = xxyyzzResults[key][i + 1].Z.ToUnit(_momentUnit);
break;
case (DisplayValue.ResXxyyzz):
t1 = xxyyzzResults[key][i].XYZ.ToUnit(_momentUnit);
t2 = xxyyzzResults[key][i + 1].XYZ.ToUnit(_momentUnit);
t1 = xxyyzzResults[key][i].Xyz.ToUnit(_momentUnit);
t2 = xxyyzzResults[key][i + 1].Xyz.ToUnit(_momentUnit);
break;
}
break;
Expand Down Expand Up @@ -486,6 +488,7 @@ protected override void SolveInstance(IGH_DataAccess da) {
for (int x = 0; x < _legend.Width; x++)
_legend.SetPixel(x, _legend.Height - y - 1, gradientcolour);
}

switch (_mode) {
case FoldMode.Displacement when (int)_disp < 4: {
var displacement = new Length(t, _lengthResultUnit);
Expand Down Expand Up @@ -730,9 +733,7 @@ public override void SetSelected(int i, int j) {

base.UpdateUI();
}
public void SetVal(double value) {
_defScale = value;
}
public void SetVal(double value) => _defScale = value;
public void SetMaxMin(double max, double min) {
_maxValue = max;
_minValue = min;
Expand Down Expand Up @@ -856,14 +857,14 @@ protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown men

var gradient = new Grasshopper.Kernel.Special.GH_GradientControl();
gradient.CreateAttributes();
var extract = new ToolStripMenuItem("Extract Default Gradient", gradient.Icon_24x24, (s, e) => { CreateGradient(); });
var extract = new ToolStripMenuItem("Extract Default Gradient", gradient.Icon_24x24, (s, e) => CreateGradient());
menu.Items.Add(extract);

var lengthUnitsMenu = new ToolStripMenuItem("Displacement") {
Enabled = true
};
foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => { UpdateLength(unit); }) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateLength(unit)) {
Checked = unit == Length.GetAbbreviation(_lengthResultUnit),
Enabled = true,
};
Expand All @@ -874,7 +875,7 @@ protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown men
Enabled = true
};
foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Force)) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => { UpdateForce(unit); }) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateForce(unit)) {
Checked = unit == Force.GetAbbreviation(_forceUnit),
Enabled = true,
};
Expand All @@ -885,7 +886,7 @@ protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown men
Enabled = true
};
foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Moment)) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => { UpdateMoment(unit); }) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateMoment(unit)) {
Checked = unit == Moment.GetAbbreviation(_momentUnit),
Enabled = true
,
Expand All @@ -897,7 +898,7 @@ protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown men
Enabled = true
};
foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Energy)) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => { UpdateEnergy(unit); }) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateEnergy(unit)) {
Checked = unit == Energy.GetAbbreviation(_energyResultUnit),
Enabled = true,
};
Expand All @@ -911,7 +912,7 @@ protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown men
Enabled = true
};
foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => { UpdateModel(unit); }) {
var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateModel(unit)) {
Checked = unit == Length.GetAbbreviation(_lengthUnit),
Enabled = true,
};
Expand Down
Loading

0 comments on commit 1c4c2a2

Please sign in to comment.