Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for GsaList (reduced scope) (SPEC-460, SPEC-494) #236

Open
wants to merge 42 commits into
base: dn/dev/2.14.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a83aeda
feat: add gwa parsing for GsaList records
dtnaughton Feb 8, 2023
a150a7e
test: add unit tests for GsaList record parse to gwa
dtnaughton Feb 8, 2023
e54869e
refactor: remove GSAList defintions property and references
dtnaughton Feb 8, 2023
140013e
refactor: remove unspecified GSAList type
dtnaughton Feb 8, 2023
e00b1bd
fix: remove reference to unspecified gsa list type
dtnaughton Feb 9, 2023
63f7066
feat: implements GSAList (speckleobj) to native
dtnaughton Feb 10, 2023
f883ea3
test: add tests for GSAList to native conversion
dtnaughton Feb 10, 2023
3378c93
fix: exposes general data property on constructor and updates gh schema
dtnaughton Feb 10, 2023
8b5f485
test: refactor gsa list test names
dtnaughton Feb 10, 2023
e21f1f2
Revert "refactor: remove GSAList defintions property and references"
jenessaman Apr 18, 2023
6c32f1e
Add DetachProperty attribute to definition property in GSAList class
jenessaman Apr 18, 2023
07f2d27
refactor: gsa list conversion
dtnaughton Apr 21, 2023
1313b29
fix: get definition for gsa node lists
dtnaughton Apr 24, 2023
2ff8fda
refactor: gsa list from gwa
dtnaughton Apr 24, 2023
a6c4022
add gsa list definition on convert to speckle
dtnaughton Apr 24, 2023
37df311
test: remove undefined test
dtnaughton Apr 24, 2023
2adef0d
test: refactor gsa list valid parameter test
dtnaughton Apr 24, 2023
c9a2e65
refactor: remove redundant (commented out) gsa list method
dtnaughton Apr 24, 2023
b501199
fix: convert gsa lists without model obj
dtnaughton Apr 25, 2023
256d377
fix formatting
dtnaughton Apr 25, 2023
b7bb63f
refactor gsa list to native to use existing method and update tests
dtnaughton Apr 25, 2023
6ff5f31
remove redundant gsa list loadcase check
dtnaughton Apr 25, 2023
9bd320f
set switch default for gsa listTypes to throw arg exception
dtnaughton Apr 26, 2023
347b286
add unspecified to gsa listType for gsa record
dtnaughton Apr 26, 2023
5e45188
add appId to gsa list in to speckle conversion
dtnaughton Apr 26, 2023
75a8413
convert gsaList to speckle with definition refs only
dtnaughton Apr 26, 2023
10254d8
add object and list type mismatch checks in gsaList constructor
dtnaughton Apr 26, 2023
0c2f282
use argument exception for gsa list mismatch
dtnaughton Apr 27, 2023
6a052b3
add logging for gsa list conversion
dtnaughton Apr 27, 2023
6d04ab9
remove support for GSAList of type case
dtnaughton May 16, 2023
4832a33
change exception for list types to speckle conversion
dtnaughton May 16, 2023
757d7ec
change exception for list types to native conversion
dtnaughton May 16, 2023
dd4696f
add test for gsa list conversion with invalid type
dtnaughton May 16, 2023
a1ddbec
fix: gwa parse errors will log as conversion errors
dtnaughton May 19, 2023
f94b1e5
add conversion error logging (to speckle) for unsupported list types
dtnaughton May 19, 2023
1b6fdfe
add schema and schema param info for GSAList
dtnaughton May 19, 2023
f90263f
log warning for gsaList definition limitations
dtnaughton May 19, 2023
1f7bed6
Merge branch 'jm/dev/standalone-report-scroll' into dn/dev/gsa-lists-…
dtnaughton May 19, 2023
5635394
fix log control on standalone
dtnaughton May 24, 2023
76fe1cb
update logging message list to speckle
dtnaughton May 24, 2023
7baa5cb
remove unnecessary usings in stream view standalone
dtnaughton May 25, 2023
df755bc
update schemabuildergen for gsa list
dtnaughton May 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion ConnectorGSA/ConnectorGSATests/SchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void GsaListSimple()

// Equal checks on first list only
Assert.Equal("sampleOne", gsaLists[0].Name);
Assert.Equal("MEMBER", gsaLists[0].Type);
Assert.Equal(ListType.Member, gsaLists[0].Type);
Assert.True(new List<int>() { 1, 2, 4, 5, 6, 7, 8 }.SequenceEqual(gsaLists[0].Definition));
}

Expand Down Expand Up @@ -3120,6 +3120,62 @@ public void GsaUserVehicleSimple()
}
}
#endregion

[Fact]
public void GsaListGwa_WithEmptyDefinition_ReturnsTrue()
{
var listGwas = new List<string>()
{
"LIST.1\t3\tmemb list\tMEMBER\t"
};

var parser = new GsaListParser();

Assert.True(parser.FromGwa(listGwas[0]));

var record = (GsaList)parser.Record;

Assert.Equal("memb list", record.Name);
Assert.Equal(ListType.Member, record.Type);
Assert.Equal(new List<int>(), record.Definition);
}

[Fact]
public void GsaList_WithValidParameters_CreatesValidGwa()
{
var gsaList = new GsaList();
gsaList.Index = 1;
gsaList.Name = "TestList";
gsaList.Type = ListType.Node;
gsaList.Definition = new List<int>() { 1, 3, 4, 5, 2, 20 };

var listParser = new GsaListParser(gsaList);

var isParsed = listParser.Gwa(out var gwas);

var expectedResult = $"LIST.1\t1\tTestList\tNODE\t1 3 4 5 2 20";

Assert.True(isParsed);
Assert.NotEmpty(gwas);
Assert.Equal(expectedResult, gwas[0]);
}

[Fact]
public void GsaList_WithEmptyName_DoesNotParse()
{
var gsaList = new GsaList();
gsaList.Index = 1;
gsaList.Type = ListType.Node;
gsaList.Definition = new List<int>() { 1, 3, 4, 5, 2, 20 };

var listParser = new GsaListParser(gsaList);

var isParsed = listParser.Gwa(out var gwas);

Assert.False(isParsed);
Assert.Empty(gwas);
}

#endregion

#region data_gen_fns
Expand Down
10 changes: 5 additions & 5 deletions ConnectorGSA/GSAProxy/Cache/GsaCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,18 @@ public bool GetNativesFilteredByList(out List<GsaRecord> gsaRecords, List<string
{
var precendentRecords = new List<GsaRecord>();

switch (listRecord.Type.ToUpper())
switch (listRecord.Type)
{
case "MEMBER":
case ListType.Member:
GetPrecedentNatives<GsaMemb>(listRecord.Definition, out precendentRecords);
break;
case "ELEMENT":
case ListType.Element:
GetPrecedentNatives<GsaEl>(listRecord.Definition, out precendentRecords);
break;
case "NODE":
case ListType.Node:
GetPrecedentNatives<GsaNode>(listRecord.Definition, out precendentRecords);
break;
case "CASE":
case ListType.Case:
GetPrecedentNatives<GsaLoadCase>(listRecord.Definition, out precendentRecords);
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions ConnectorGSA/GSAProxy/GsaProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ public bool GetGwaData(GSALayer layer, ProgressViewModel progress, out List<GsaR
}
else if (progress != null)
{
progress.Report.LogOperationError(new Exception(FormulateParsingErrorContext(parser.Record, schemaType.Name)));
progress.Report.LogConversionError(new Exception(FormulateParsingErrorContext(parser.Record, schemaType.Name)));
}
}
}
Expand Down Expand Up @@ -1249,7 +1249,7 @@ public bool GetGwaData(GSALayer layer, ProgressViewModel progress, out List<GsaR
}
else if (progress != null)
{
progress.Report.LogOperationError(new Exception(FormulateParsingErrorContext(parser.Record, schemaType.Name)));
progress.Report.LogConversionError(new Exception(FormulateParsingErrorContext(parser.Record, schemaType.Name)));
}
}
}
Expand Down Expand Up @@ -1370,7 +1370,7 @@ public bool GetGwaData(GSALayer layer, ProgressViewModel progress, out List<GsaR
}
else if (progress != null)
{
progress.Report.LogOperationError(new Exception(FormulateParsingErrorContext(parser.Record, schemaType.Name)));
progress.Report.LogConversionError(new Exception(FormulateParsingErrorContext(parser.Record, schemaType.Name)));
}
}
}
Expand Down
49 changes: 29 additions & 20 deletions ConnectorGSA/GSAProxy/GwaParsers/GeneralData/GsaListParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Speckle.GSA.API.GwaSchema;
using Speckle.GSA.API;
using Speckle.GSA.API.GwaSchema;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -20,24 +21,40 @@ public override bool FromGwa(string gwa)
return false;
}

var items = remainingItems;
// Ensure record.Type correctly set
FromGwaByFuncs(remainingItems, out remainingItems, AddName, (v) => v.TryParseStringValue(out record.Type));

if (items[1] == "MEMBER")
FromGwaByFuncs(items, out remainingItems, AddName, AddType, (v) => AddEntities(v, GSA.API.GSALayer.Design, out record.Definition));

else if (items[1] == "NODE") // Add nodes currently gets all nodes only.
FromGwaByFuncs(items, out remainingItems, AddName, AddType, (v) => AddNodes(v, out record.Definition));

// Element, Case
if (record.Type == ListType.Node)
{
FromGwaByFuncs(remainingItems, out remainingItems, (v) => AddNodes(v, out record.Definition));
}
else
FromGwaByFuncs(items, out remainingItems, AddName, AddType, (v) => AddEntities(v, GSA.API.GSALayer.Analysis, out record.Definition));
{
var gsaLayer = record.Type == ListType.Member ? GSALayer.Design : GSALayer.Analysis;
FromGwaByFuncs(remainingItems, out remainingItems, (v) => AddEntities(v, gsaLayer, out record.Definition));
}

return true;
// Record with null definition determined invalid. Record will still be valid and converted if definition is empty.
return record.Definition != null;
}

public override bool Gwa(out List<string> gwa, bool includeSet = false)
{
throw new NotImplementedException();
gwa = new List<string>();

if (!InitialiseGwa(includeSet, out var items) || string.IsNullOrEmpty(record.Name))
return false;

// LIST.1 | num | name | type | list (definition)
var allItemsAdded = AddItems(ref items, record.Name, record.Type.GetStringValue(), string.Join(" ", record.Definition));

if (!allItemsAdded)
return false;

if (Join(items, out var gwaLine))
gwa.Add(gwaLine);

return gwa.Count > 0;
}

#region From GWA
Expand All @@ -46,14 +63,6 @@ protected bool AddName(string v)
record.Name = (string.IsNullOrEmpty(v)) ? null : v;
return true;
}

protected bool AddType(string v)
{
record.Type = (string.IsNullOrEmpty(v)) ? null : v;
return true;
}

#endregion

}
}
14 changes: 14 additions & 0 deletions ConnectorGSA/Speckle.GSA.API/GwaSchema/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,4 +1056,18 @@ public enum UnitDimension
[StringValue("STRAIN")]
Strain
}

public enum ListType
{
[StringValue("NODE")]
Node,
[StringValue("ELEMENT")]
Element,
[StringValue("MEMBER")]
Member,
[StringValue("CASE")]
Case,
[StringValue("UNDEF")]
Unspecified
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Speckle.GSA.API.GwaSchema
public class GsaList : GsaRecord
{
public string Name { get => name; set { name = value; } }
public string Type;
public ListType Type;
public List<int> Definition;

public GsaList() : base()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,7 @@ static GSAListSchemaComponent() {
proxy.Exposure = internalExposure;
};
}
public GSAListSchemaComponent(): base("GSAList", "GSAList", "Creates a Speckle object for a GSA List", "Speckle 2 GSA", "General Data") { }
public GSAListSchemaComponent(): base("GSAList", "GSAList", "Creates a Speckle object for a GSA List (to be used for defining GSA lists and receiving into GSA only, not as input to other objects/components)", "Speckle 2 GSA", "General Data") { }

internal static string internalCategory { get; } = "Speckle 2 GSA";

Expand Down Expand Up @@ -4616,7 +4616,7 @@ public ModelSchemaComponent(): base("Model", "Model", "Creates a Speckle structu
: GH_Exposure.hidden;

public override void AddedToDocument(GH_Document document){
SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Analysis.Model.ctor(Objects.Structural.Analysis.ModelInfo,System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base])","Objects.Structural.Analysis.Model");
SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Analysis.Model.ctor(Objects.Structural.Analysis.ModelInfo,System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base],System.Collections.Generic.List`1[Speckle.Core.Models.Base])","Objects.Structural.Analysis.Model");
base.AddedToDocument(document);
}
}
Expand Down Expand Up @@ -6073,7 +6073,7 @@ static ResultSetAllSchemaComponent() {
: GH_Exposure.hidden;

public override void AddedToDocument(GH_Document document){
SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Results.ResultSetAll.ctor(Objects.Structural.Results.ResultSet1D,Objects.Structural.Results.ResultSet2D,Objects.Structural.Results.ResultSet3D,Objects.Structural.Results.ResultGlobal,Objects.Structural.Results.ResultSetNode)","Objects.Structural.Results.ResultSetAll");
SelectedConstructor = CSOUtils.FindConstructor("Objects.Structural.Results.ResultSetAll.ctor(Objects.Structural.Results.ResultSet1D,Objects.Structural.Results.ResultSet2D,Objects.Structural.Results.ResultSet3D,Objects.Structural.Results.ResultSetGlobal,Objects.Structural.Results.ResultSetNode)","Objects.Structural.Results.ResultSetAll");
base.AddedToDocument(document);
}
}
Expand Down
Loading