Closed daveime closed 7 years ago
If it's useful, this is what I understood from the spec with regards to the Project hierarchy downwards
IfcProject.IsDecomposedBy -> RelatedObjects -> IfcSite || IfcBuilding || IfcSpatialZone
IfcSite.IsDecomposedBy -> RelatedObjects -> IfcSite || IfcBuilding || IfcSpace
IfcBuilding.IsDecomposedBy -> RelatedObjects -> IfcBuilding || IfcBuildingStorey
IfcBuildingStorey.IsDecomposedBy -> RelatedObjects -> IfcBuildingStorey || IfcSpace
IfcSpace.IsDecomposedBy -> RelatedObjects -> IfcSpace
These are errors in IFC documentation. General spatial decomposition concept is clear in that:
The order of spatial structure elements being included in the concept for builing projects are from high to low level: IfcProject, IfcSite, IfcBuilding, IfcBuildingStorey, and IfcSpace with IfcSite, IfcBuildingStorey and IfcSpace being optional levels. Therefore an spatial structure element can only be part of an element at the same or higher level.
xBIM contains shortcuts for the common hierarchy IfcProject > IfcSite > IfcBuilding > IfcBuildingStorey > IfcSpace but there is actually nothing in the schema itself which would check for this kind of hierarchy (no where rules). So you should check for any type in decomposition hierarchy:
using System;
using System.Linq;
using Xbim.Ifc;
using Xbim.Ifc4.Interfaces;
namespace BasicExamples
{
class SpatialStructureExample
{
public static void Show()
{
const string file = "SampleHouse.ifc";
using (var model = IfcStore.Open(file))
{
var project = model.Instances.FirstOrDefault<IIfcProject>();
PrintHierarchy(project, 0);
}
}
private static void PrintHierarchy(IIfcObjectDefinition o, int level)
{
Console.WriteLine($"{GetIndent(level)}{o.Name} [{o.GetType().Name}]");
foreach (var item in o.IsDecomposedBy.SelectMany(r => r.RelatedObjects))
PrintHierarchy(item, level +1);
}
private static string GetIndent(int level)
{
var indent = "";
for (int i = 0; i < level; i++)
indent += " ";
return indent;
}
}
}
Okay cool. Thanks for the advice on this, I'll go with the IsDecomposedBy and RelatedObjects methods then.
It's such a shame when specifications can't even get right what they're specifying from one page to the next.
I note in the IfcSite spec
http://www.buildingsmart-tech.org/ifc/IFC4/Add1/html/schema/ifcproductextension/lexical/ifcsite.htm
In the Concept Usage, Spatial Decomposition section, is states that the IfcSite is supposed to expose the following "children".
IfcSite -> IsDecomposedBy -> RelatedObjects -> IfcSite || IfcBuilding || IfcSpace
But in the library, the XBim.Ifc4.Interfaces.IIfcSite doesn't seem to expose either Sites or Spaces collections in the same way it exposes the Buildings collection. Is this intentional, or an accidental omission, or did I just misunderstand the spec?
Also
The IfcBuilding spec doesn't mention having "children" of type IfcSpace http://www.buildingsmart-tech.org/ifc/IFC4/Add1/html/schema/ifcproductextension/lexical/ifcbuilding.htm
And the IfcSpace spec doesn't mention having "parents" of type IfcBuilding http://www.buildingsmart-tech.org/ifc/IFC4/Add1/html/schema/ifcproductextension/lexical/ifcspace.htm
And yet in the library, the Xbim.Ifc4.Interfaces.IIfcBuilding, a Spaces collection is exposed?
Sorry for being a pain, but I've only recently become involved with IFC due to a project I'm working on for a client. I just want to be sure all the helpful collections are covered as per the spec, otherwise I'll have to drop down to the two stage IsDecomposedBy and RelatedObjects method to be absolutely sure I'm covering all eventualities.