From 0afbe30a2b3a7f43ce51da86d4cf0d79e66b34dd Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Fri, 14 Jun 2024 09:05:59 +0100 Subject: [PATCH] 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)]