From 0afbe30a2b3a7f43ce51da86d4cf0d79e66b34dd Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Fri, 14 Jun 2024 09:05:59 +0100 Subject: [PATCH 1/4] Fix for #37 We were ignoring the schema param being passed in --- ids-lib/IfcSchema/SchemaInfo.cs | 12 ++++++------ ids-tool.tests/IfcSchemaTests.cs | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ids-lib/IfcSchema/SchemaInfo.cs b/ids-lib/IfcSchema/SchemaInfo.cs index 9afb9c0..81767f5 100644 --- a/ids-lib/IfcSchema/SchemaInfo.cs +++ b/ids-lib/IfcSchema/SchemaInfo.cs @@ -552,24 +552,24 @@ public static IEnumerable GetConcreteClassesFrom(string topClass, IfcSch { if (schemaVersions.IsSingleSchema()) { - var schema = GetSchemas(IfcSchemaVersions.IfcAllVersions).First(); + var schema = GetSchemas(schemaVersions).First(); if (schema is null) return Enumerable.Empty(); var top = schema[topClass]; if (top is null) return Enumerable.Empty(); - return top.MatchingConcreteClasses.Select(x=>x.Name); - } + return top.MatchingConcreteClasses.Select(x=>x.Name); + } - var schemas = GetSchemas(IfcSchemaVersions.IfcAllVersions); + var schemas = GetSchemas(IfcSchemaVersions.IfcAllVersions); List ret = new(); - foreach (var schema in schemas) + foreach (var schema in schemas) { var top = schema[topClass]; if (top is null) continue; ret = ret.Union(top.MatchingConcreteClasses.Select(x => x.Name)).ToList(); - } + } return ret; } diff --git a/ids-tool.tests/IfcSchemaTests.cs b/ids-tool.tests/IfcSchemaTests.cs index 406ba60..c12c932 100644 --- a/ids-tool.tests/IfcSchemaTests.cs +++ b/ids-tool.tests/IfcSchemaTests.cs @@ -109,7 +109,20 @@ public void CanGetConcreteSubclasses() } - [Theory] + [Fact] + public void CanGetConcreteSubclassesForSpecificSchema() + { + // IFCCABLECARRIERSEGMENT is new in IFC4 + var elements = SchemaInfo.GetConcreteClassesFrom("IFCCABLECARRIERSEGMENT", IfcSchemaVersions.Ifc4); + elements.Should().NotBeNull(); + elements.Should().HaveCount(1); + + elements = SchemaInfo.GetConcreteClassesFrom("IFCFACILITYPART", IfcSchemaVersions.Ifc4x3); + elements.Should().Contain("IfcRailwayPart"); + elements.Should().HaveCount(5); + } + + [Theory] [InlineData("IFCOBJECTDEFINITION", 194,366)] [InlineData("IFCWALL",2, 3)] [InlineData("IFCNOTEXISTING",-1, -1)] From 07053ab55982d6bc3ef8f7d3b90022d291c62b51 Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Mon, 5 Aug 2024 19:19:20 +0100 Subject: [PATCH 2/4] Fix for #39 where Type sub-classes not being offered as valid for a Pset unless explicitly referenced --- ids-lib/IfcSchema/SchemaInfo.cs | 9 +++++++ ids-tool.tests/IfcSchemaTests.cs | 16 +++++++++++ .../Issue 39 - IfcTypeObjects allowed.ids | 27 +++++++++++++++++++ ids-tool.tests/IssueTests.cs | 9 ++++++- ids-tool.tests/ids-tool.tests.csproj | 3 +++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids diff --git a/ids-lib/IfcSchema/SchemaInfo.cs b/ids-lib/IfcSchema/SchemaInfo.cs index 9afb9c0..ad8b361 100644 --- a/ids-lib/IfcSchema/SchemaInfo.cs +++ b/ids-lib/IfcSchema/SchemaInfo.cs @@ -302,7 +302,16 @@ internal static IEnumerable PossibleTypesForPropertySets(IfcSchemaVersio { var tp = schema[item]; if (tp is not null && tp.RelationTypeClasses is not null) + { typeObjects.AddRange(tp.RelationTypeClasses); + // RelationTypeClasses only includes immediate ancestores, so we need to include all subClasses of any TypeObjects + // as these also are valid for the propertySet + var subTypes = tp.RelationTypeClasses.SelectMany(typ => schema[typ]!.SubClasses.Select(s => s.Name)).Distinct(); + if(subTypes.Any()) + { + typeObjects.AddRange(subTypes); + } + } } if (typeObjects.Any()) thisPsetTypes = thisPsetTypes.ToList().Concat(typeObjects.Distinct()).ToList(); diff --git a/ids-tool.tests/IfcSchemaTests.cs b/ids-tool.tests/IfcSchemaTests.cs index 406ba60..bda84af 100644 --- a/ids-tool.tests/IfcSchemaTests.cs +++ b/ids-tool.tests/IfcSchemaTests.cs @@ -216,5 +216,21 @@ public void OnlyTopLevelClassesShouldRemoveAllSubClasses() } + [Fact] + public void AllSubClassesOfTypesAreIncludedAsPossibleTypesForPropertySets() + { + var psets = new[] { "Pset_ManufacturerTypeInformation" }; + var classes = SchemaInfo.PossibleTypesForPropertySets(IfcSchemaVersions.Ifc2x3, psets).Select(e=> e.ToUpperInvariant()); + + // Sanity checking + classes.Should().Contain("IFCWALL"); + classes.Should().Contain("IFCWALLTYPE"); + classes.Should().Contain("IFCDISTRIBUTIONCONTROLELEMENT"); + + // Bug - IFC2x3 Type Subtypes were not being returned: Issue #39 + classes.Should().Contain("IFCACTUATORTYPE"); + classes.Should().Contain("IFCAIRTERMINALTYPE"); + } + } diff --git a/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids b/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids new file mode 100644 index 0000000..5e245e2 --- /dev/null +++ b/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids @@ -0,0 +1,27 @@ + + + Can select IfcTypeObjects that don't have equivalent IfcObject in IFC2x3 + + + + + + + IFCDISTRIBUTIONCONTROLELEMENTTYPE + + + + + + + Pset_ManufacturerTypeInformation + + + ModelLabel + + + + + + \ No newline at end of file diff --git a/ids-tool.tests/IssueTests.cs b/ids-tool.tests/IssueTests.cs index dcec63e..e278d14 100644 --- a/ids-tool.tests/IssueTests.cs +++ b/ids-tool.tests/IssueTests.cs @@ -59,5 +59,12 @@ public void Issue_30_ShouldReturnError() var f = new FileInfo("IssueFiles/Issue 30 - should return error.ids"); LoggerAndAuditHelpers.FullAudit(f, XunitOutputHelper, IdsLib.Audit.Status.IdsContentError, 2); } - } + + [Fact] + public void Issue_39_SubClassesOfObjectTypesAllowPsets() + { + var f = new FileInfo("IssueFiles/Issue 39 - IfcTypeObjects allowed.ids"); + LoggerAndAuditHelpers.FullAudit(f, XunitOutputHelper, IdsLib.Audit.Status.Ok); + } + } } diff --git a/ids-tool.tests/ids-tool.tests.csproj b/ids-tool.tests/ids-tool.tests.csproj index 7c5a040..5ceabfc 100644 --- a/ids-tool.tests/ids-tool.tests.csproj +++ b/ids-tool.tests/ids-tool.tests.csproj @@ -168,6 +168,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 5ac1e0e553245e59cb522cd106a1a96a72f05ed4 Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Mon, 5 Aug 2024 19:29:12 +0100 Subject: [PATCH 3/4] Bumped versions to 1.0.77 --- ids-lib/LibraryInformation.cs | 2 +- ids-lib/ids-lib.csproj | 2 +- ids-tool/ids-tool.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ids-lib/LibraryInformation.cs b/ids-lib/LibraryInformation.cs index 97cbdfa..b8b4bd6 100644 --- a/ids-lib/LibraryInformation.cs +++ b/ids-lib/LibraryInformation.cs @@ -26,5 +26,5 @@ public static class LibraryInformation /// /// Static field with hardcoded DLL version number. /// - public static string AssemblyVersion => "1.0.76"; + public static string AssemblyVersion => "1.0.77"; } diff --git a/ids-lib/ids-lib.csproj b/ids-lib/ids-lib.csproj index 070c18b..2ba6419 100644 --- a/ids-lib/ids-lib.csproj +++ b/ids-lib/ids-lib.csproj @@ -20,7 +20,7 @@ First implementation. README.md - 1.0.76 + 1.0.77 $(AssemblyVersion) $(AssemblyVersion) true diff --git a/ids-tool/ids-tool.csproj b/ids-tool/ids-tool.csproj index 67b492e..53609e8 100644 --- a/ids-tool/ids-tool.csproj +++ b/ids-tool/ids-tool.csproj @@ -16,7 +16,7 @@ icon.png IDS, buildingSmart - 1.0.76 + 1.0.77 $(AssemblyVersion) $(AssemblyVersion) https://github.com/buildingSMART/IDS-Audit-tool.git From 209d730343eaa68b996c49d5a5abffaeba10bafa Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Tue, 6 Aug 2024 11:31:27 +0100 Subject: [PATCH 4/4] FIxed test to actually break. Fixed typo --- ids-lib/IfcSchema/SchemaInfo.cs | 2 +- .../IssueFiles/Issue 39 - IfcTypeObjects allowed.ids | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ids-lib/IfcSchema/SchemaInfo.cs b/ids-lib/IfcSchema/SchemaInfo.cs index ad8b361..799ea6e 100644 --- a/ids-lib/IfcSchema/SchemaInfo.cs +++ b/ids-lib/IfcSchema/SchemaInfo.cs @@ -304,7 +304,7 @@ internal static IEnumerable PossibleTypesForPropertySets(IfcSchemaVersio if (tp is not null && tp.RelationTypeClasses is not null) { typeObjects.AddRange(tp.RelationTypeClasses); - // RelationTypeClasses only includes immediate ancestores, so we need to include all subClasses of any TypeObjects + // RelationTypeClasses only includes immediate ancestors, so we need to include all subClasses of any TypeObjects // as these also are valid for the propertySet var subTypes = tp.RelationTypeClasses.SelectMany(typ => schema[typ]!.SubClasses.Select(s => s.Name)).Distinct(); if(subTypes.Any()) diff --git a/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids b/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids index 5e245e2..9740fea 100644 --- a/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids +++ b/ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids @@ -4,11 +4,11 @@ + description="Issue is that there's no IFCACTUATOR instance in IFC2x3 so we get a false 'Inconsistent Clauses' 201 error, since subClasses were not being considered"> - IFCDISTRIBUTIONCONTROLELEMENTTYPE + IFCACTUATORTYPE