Skip to content

Commit a3a2a3e

Browse files
committed
Merged PR 2514: Implemented final PartOf tests where filtering on predefined Type on Target r...
Implemented final PartOf tests where filtering on predefined Type on Target relation Made possible by extension to Essentials. Based on latest thinking of PDT inheritance at buildingSMART/IDS#240 (comment)
1 parent c36cbfd commit a3a2a3e

File tree

3 files changed

+49
-29
lines changed

3 files changed

+49
-29
lines changed

Xbim.IDS.Validator.Common/Xbim.IDS.Validator.Common.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<ItemGroup>
2020
<PackageReference Include="ids-lib" Version="1.0.56" />
2121
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
22-
<PackageReference Include="Xbim.Essentials" Version="6.0.414-develop" />
22+
<PackageReference Include="Xbim.Essentials" Version="6.0.438-develop" />
2323
<PackageReference Include="Xbim.InformationSpecifications" Version="0.3.38" />
2424
</ItemGroup>
2525

Xbim.IDS.Validator.Core.Tests/TestCases/PartOfTestCases.cs

+1-26
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ public PartOfTestCases(ITestOutputHelper output) : base(output)
2222

2323

2424

25-
// Unsupported tests
26-
{ "pass-an_aggregate_may_specify_the_predefined_type_of_the_whole_1_2.ids", new [] { XbimSchemaVersion.Unsupported } }, //
27-
{ "fail-an_aggregate_may_specify_the_predefined_type_of_the_whole_2_2.ids", new [] { XbimSchemaVersion.Unsupported } },
25+
// Unsupported tests: None
2826

2927
};
3028

@@ -44,18 +42,6 @@ public async Task ExpectedPasses(string idsFile, params XbimSchemaVersion[] sche
4442
}
4543

4644

47-
48-
[MemberData(nameof(GetUnsupportedPassTestCases))]
49-
[SkippableTheory]
50-
public async Task UnsupportedPasses(string idsFile)
51-
{
52-
var outcome = await VerifyIdsFile(idsFile);
53-
54-
Skip.If(outcome.Status != ValidationStatus.Pass, "Not yet supported");
55-
56-
outcome.Status.Should().Be(ValidationStatus.Pass);
57-
}
58-
5945

6046

6147

@@ -75,17 +61,6 @@ public async Task ExpectedFailures(string idsFile, params XbimSchemaVersion[] sc
7561

7662

7763

78-
[MemberData(nameof(GetUnsupportedFailTestCases))]
79-
[SkippableTheory]
80-
public async Task UnsupportedFailures(string idsFile)
81-
{
82-
var outcome = await VerifyIdsFile(idsFile);
83-
84-
85-
Skip.If(outcome.Status != ValidationStatus.Inconclusive, "Not yet supported");
86-
87-
outcome.Status.Should().Be(ValidationStatus.Fail);
88-
}
8964

9065
public static IEnumerable<object[]> GetFailureTestCases()
9166
{

Xbim.IDS.Validator.Core/Extensions/IfcRelationsExtensions.cs

+47-2
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,57 @@ private static bool MatchesPart(IIfcObjectDefinition obj, PartOfFacet facet)
131131
{
132132
throw new ArgumentNullException(nameof(obj));
133133
}
134-
// TODO: Limited support for Predefined Type only. Omits complex scenarios, Type Inheritance, Enums etc
134+
// Based on latest thinking at https://github.com/buildingSMART/IDS/pull/240#issuecomment-1929367078
135135
return (facet.EntityType?.IfcType?.IsSatisfiedBy(obj.GetType().Name, true) == true) &&
136-
(facet.EntityType?.PredefinedType == null || obj is IIfcObject p && facet.EntityType?.PredefinedType?.IsSatisfiedBy(p.ObjectType, true) == true)
136+
(facet.EntityType?.PredefinedType == null ||
137+
facet.EntityType?.PredefinedType?.IsSatisfiedBy(GetPredefinedType(obj), true) == true)
137138
;
138139
}
139140

141+
private static string? GetPredefinedType(IIfcObjectDefinition obj)
142+
{
143+
if(obj is IIfcObject o)
144+
{
145+
var definingType = o.IsTypedBy.FirstOrDefault()?.RelatingType;
146+
if(definingType != null)
147+
{
148+
return GetSubType(definingType);
149+
}
150+
else
151+
{
152+
// No type
153+
return GetSubType(o);
154+
}
155+
}
156+
else
157+
{
158+
return GetSubType(obj);
159+
}
160+
}
161+
162+
private static string? GetSubType(IIfcObjectDefinition definingType)
163+
{
164+
var pdt = definingType.GetPredefinedTypeValue();
165+
if (pdt == null || pdt == "USERDEFINED")
166+
{
167+
return GetObjectType((IIfcObjectDefinition?)definingType) ?? pdt;
168+
}
169+
return pdt;
170+
}
171+
172+
173+
private static string? GetObjectType(IIfcObjectDefinition entity)
174+
{
175+
if (entity is IIfcObject obj)
176+
return obj.ObjectType?.Value.ToString();
177+
else if (entity is IIfcElementType type)
178+
return type.ElementType?.Value.ToString();
179+
else if (entity is IIfcTypeProcess process)
180+
return process.ProcessType?.Value.ToString();
181+
else
182+
return null;
183+
}
184+
140185
private static IEnumerable<IIfcObjectDefinition> UnionAncestry(this IEnumerable<IIfcObjectDefinition> objs, PartOfRelation relation)
141186
{
142187
if (!objs.Any())

0 commit comments

Comments
 (0)