我目前正在进行一个项目,以从存储在开放源码IfcBuilding中的IFC文件中获取所有细节,如IfcDistributionControlElement、BIMserver等。使用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发布于 2018-10-30 17:14:11
从IfcBuildingStorey实体的列表开始,您必须按照国际金融公司文件中的描述在空间层次结构中工作。请注意,您不一定有一个简单的IfcBuildingStorey和IfcSpace两层结构,但是聚合树可能包含最多三个层次结构的层和空间:
通过对象化聚合关系,您可以达到相应的下一个较低级别:
IfcSpatialStrutureElement.IsDecomposedByIfcRelAggregates.RelatedObjectsIfcObjectDefinition然后希望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.ContainsElementsIfcRelContainedInSpatialStructure.RelatedElementsIfcProduct再次在Java中:
void doSomethingWith(IfcSpace spatialStructure){
for(IfcRelContainedInSpatialStructure containment: spatialstructure.getContainsElements()){
for(IfcProduct product : containment.getRelatedElements()){
// do something with your product, e.g. fire detector
}
}
}https://stackoverflow.com/questions/53058287
复制相似问题