Skip to content

Commit 1a5b696

Browse files
authored
Merge pull request #38 from andyward/fix/issue37-ifc4schemas
Allow Classes to be enumerated for IFC4, IFC4.3 specific schemas. Fix for #37
2 parents 1fda66a + 0afbe30 commit 1a5b696

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

ids-lib/IfcSchema/SchemaInfo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,24 +552,24 @@ public static IEnumerable<string> GetConcreteClassesFrom(string topClass, IfcSch
552552
{
553553
if (schemaVersions.IsSingleSchema())
554554
{
555-
var schema = GetSchemas(IfcSchemaVersions.IfcAllVersions).First();
555+
var schema = GetSchemas(schemaVersions).First();
556556
if (schema is null)
557557
return Enumerable.Empty<string>();
558558
var top = schema[topClass];
559559
if (top is null)
560560
return Enumerable.Empty<string>();
561-
return top.MatchingConcreteClasses.Select(x=>x.Name);
562-
}
561+
return top.MatchingConcreteClasses.Select(x=>x.Name);
562+
}
563563

564-
var schemas = GetSchemas(IfcSchemaVersions.IfcAllVersions);
564+
var schemas = GetSchemas(IfcSchemaVersions.IfcAllVersions);
565565
List<string> ret = new();
566-
foreach (var schema in schemas)
566+
foreach (var schema in schemas)
567567
{
568568
var top = schema[topClass];
569569
if (top is null)
570570
continue;
571571
ret = ret.Union(top.MatchingConcreteClasses.Select(x => x.Name)).ToList();
572-
}
572+
}
573573
return ret;
574574
}
575575

ids-tool.tests/IfcSchemaTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,20 @@ public void CanGetConcreteSubclasses()
109109

110110
}
111111

112-
[Theory]
112+
[Fact]
113+
public void CanGetConcreteSubclassesForSpecificSchema()
114+
{
115+
// IFCCABLECARRIERSEGMENT is new in IFC4
116+
var elements = SchemaInfo.GetConcreteClassesFrom("IFCCABLECARRIERSEGMENT", IfcSchemaVersions.Ifc4);
117+
elements.Should().NotBeNull();
118+
elements.Should().HaveCount(1);
119+
120+
elements = SchemaInfo.GetConcreteClassesFrom("IFCFACILITYPART", IfcSchemaVersions.Ifc4x3);
121+
elements.Should().Contain("IfcRailwayPart");
122+
elements.Should().HaveCount(5);
123+
}
124+
125+
[Theory]
113126
[InlineData("IFCOBJECTDEFINITION", 194,366)]
114127
[InlineData("IFCWALL",2, 3)]
115128
[InlineData("IFCNOTEXISTING",-1, -1)]

0 commit comments

Comments
 (0)