ifc - 如何从 IFC 模型中获取分层空间结构和包含的产品?
问题描述
我目前正在开展一个项目,以从存储在 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
解决方案
从IfcBuildingStorey
实体列表开始,您必须按照IFC 文档中的说明逐步完成空间层次结构。请注意,您不一定具有 和 的简单两级结构IfcBuildingStorey
,IfcSpace
但聚合树最多可以包含三个层次结构级别的楼层和空间:
- 层/空间组(compositiontype COMPLEX)由
- 层/空间元素(compositionType ELEMENT)组成
- 楼层/空间部分(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
}
}
}
推荐阅读
- java - 我们可以从 linux Shell Script 或 Crontab 调用 Java Method 吗?
- java - Spring MVC 测试缺少来自 MockMvc 示例的导入
- splunk-query - 在 splunk 中搜索唯一 IP
- docker - Kubernetes:将 pod STDOUT、STDERR 和 pod 终止日志重定向到 PVC 文件
- java - 动态(以编程方式)创建视图时,视图在卡片视图中重叠
- spring-boot - 无法从 spring 控制器打印 JSP,但结果是在控制台中打印
- java - 上下文:组件扫描在 junit 中不起作用
- php - 如何使用codeigniter同时创建多个excel文件
- javascript - 创建矩形后如何动态附加文本
- sql - 计算一列中的行但在不同的日期