0

我目前正在开展一个项目,以从存储在 Opensource BIMserver 中的 IFC 文件中获取所有详细信息,例如 IfcBuilding、IfcDistributionControlElement 等。使用 Java 客户端库,我设法获取了楼层列表并打印了它们的名称。

List<IfcBuildingStorey> storeys = model.getAllWithSubTypes(IfcBuildingStorey.class));
for (IfcBuildingStorey storey : storeys) {
    System.out.println(storey.getName());
}

电流输出:

Level 1
Level 2
Level 3
Level 4

我想要的是每一层,例如第 2 层,获取位于该层的所有房间,然后以分层方式在这些房间内获取 IfcProduct 类型的所有实体,例如火灾探测器。

预期输出:

Level 2
  Room 1: entity 1, entity 2, entity 3, entity 4
  Room 2: entity 1, entity 2, entity 3, entity 4
  Room 3: entity 1, entity 2, entity 3, entity 4
4

1 回答 1

1

IfcBuildingStorey实体列表开始,您必须按照IFC 文档中的说明逐步完成空间层次结构。请注意,您不一定具有 和 的简单两级结构IfcBuildingStoreyIfcSpace但聚合树最多可以包含三个层次结构级别的楼层和空间:

  1. 层/空间组(compositiontype COMPLEX)由
  2. 层/空间元素(compositionType ELEMENT)组成
  3. 楼层/空间部分(compositionType PARTIAL)。

您通过对象化的聚合关系到达各自的下一个较低级别:

  • IfcSpatialStrutureElement.IsDecomposedBy
  • IfcRelAggregates.RelatedObjects
  • IfcObjectDefinition

然后希望IfcObjectDefinition实例是一个空间结构(应该是,但你永远不知道)。

在 Java 中,这可能如下所示:

void traverseSpatialStructure(IfcSpatialStructureElement parent){
  for (IfcRelAggregates aggregation: parent.getIsDecomposedBy()){
    for (IfcObjectDefinition child: aggregation.getRelatedObjects()){
      doSomeThingWith(child); // e.g. print name
      assert child instanceof IfcSpatialStructureElement;
      traverseSpatialStructure((IfcSpatialStructureElement) child);
    }
  }
}

最后,一旦你达到这个IfcSpace级别,使用空间包含关系来获取空间中包含的每个产品:

  • IfcSpatialStructureElement.ContainsElements
  • IfcRelContainedInSpatialStructure.RelatedElements
  • IfcProduct

再次在 Java 中:

void doSomethingWith(IfcSpace spatialStructure){
  for(IfcRelContainedInSpatialStructure containment: spatialstructure.getContainsElements()){
    for(IfcProduct product : containment.getRelatedElements()){
      // do something with your product, e.g. fire detector
    }
  }
}
于 2018-10-30T17:14:11.753 回答