xBIM 基础16 IFC的空间层次结构
本篇介绍如何从文件中检索空间结构。IFC中的空间结构表示层次结构的嵌套结构,表示项目,站点,建筑物,楼层和空间。如果您查看IFC文档, 您会发现建筑物可以包含楼层以及其他建筑物,楼层可以包含空间以及其他楼层等。此类关系也使用IfcRelAggregates建模, 但如果要查找特定空间结构中包含的元素,则将其建模为 IfcRelContainedInSpatialStructure, 因此它取决于您要查找的内容。下面的示例演示如何使用上述两种关系搜索和遍历数据以获得完整的层次结构。
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, );
}
} private static void PrintHierarchy(IIfcObjectDefinition o, int level)
{
Console.WriteLine(string.Format("{0}{1} [{2}]", GetIndent(level), o.Name, o.GetType().Name)); // 只有空间元素可以包含建筑元素
var spatialElement = o as IIfcSpatialStructureElement;
if (spatialElement != null)
{
// 使用 IfcRelContainedInSpatialElement 获取包含的元素
var containedElements = spatialElement.ContainsElements.SelectMany(rel => rel.RelatedElements);
foreach (var element in containedElements)
Console.WriteLine(string.Format("{0} ->{1} [{2}]", GetIndent(level), element.Name, element.GetType().Name));
} // 使用 IfcRelAggregares 获取空间结构元素的空间分解
foreach (var item in o.IsDecomposedBy.SelectMany(r => r.RelatedObjects))
PrintHierarchy(item, level +);
} private static string GetIndent(int level)
{
var indent = "";
for (int i = ; i < level; i++)
indent += " ";
return indent;
}
}
}
输出结果如下:
Project Number [IfcProject]
Default [IfcSite]
[IfcBuilding]
Ground Floor [IfcBuildingStorey]
->Basic Wall:Wall-Ext_102Bwk-75Ins-100LBlk-12P: [IfcWall]
->Basic Wall:Wall-Ext_102Bwk-75Ins-100LBlk-12P: [IfcWall]
->Basic Wall:Wall-Ext_102Bwk-75Ins-100LBlk-12P: [IfcWall]
->Curtain Wall:Curtain_Wall-Exterior_Glazing: [IfcCurtainWall]
->Curtain Wall:Curtain_Wall-Exterior_Glazing: [IfcCurtainWall]
->Basic Wall:Wall-Partn_12P-70MStd-12P: [IfcWallStandardCase]
->Basic Wall:Wall-Partn_12P-70MStd-12P: [IfcWallStandardCase]
->Doors_ExtDbl_Flush:1810x2110mm: [IfcDoor]
->Doors_IntSgl:810x2110mm: [IfcDoor]
->Doors_IntSgl:810x2110mm: [IfcDoor]
->Windows_Sgl_Plain:1810x1210mm: [IfcWindow]
->Windows_Sgl_Plain:1810x1210mm: [IfcWindow]
->Windows_Sgl_Plain:1810x1210mm: [IfcWindow]
->Compound Ceiling:Plain: [IfcCovering]
->Compound Ceiling:Plain: [IfcCovering]
->Compound Ceiling:Plain: [IfcCovering]
->Floor:Floor-Grnd-Susp_65Scr-80Ins-100Blk-75PC: [IfcSlab]
->Windows_Sgl_Plain:1810x1210mm: [IfcWindow]
- Living room [IfcSpace]
->Furniture_Table_Dining_w-Chairs_Rectangular:2000x1000x750mm_w-6_Seats: [IfcFurniture]
->Chair - Dining:Chair - Dining: [IfcFurniture]
->Chair - Dining:Chair - Dining: [IfcFurniture]
->Chair - Dining:Chair - Dining: [IfcFurniture]
->Chair - Dining:Chair - Dining: [IfcFurniture]
->Chair - Dining:Chair - Dining: [IfcFurniture]
->Chair - Dining:Chair - Dining: [IfcFurniture]
->Furniture_Couch_Viper:2290x950x340mm: [IfcFurniture]
->Furniture_Chair_Viper:1120x940x350mm: [IfcFurniture]
->Furniture_Chair_Viper:1120x940x350mm: [IfcFurniture]
->Furniture_Table_Coffee_1:1200x550x450mm: [IfcFurniture]
->Furniture_Piano:1370x600x1170mm: [IfcFurniture]
- Bedroom [IfcSpace]
->Furniture_Desk:1525x762mm: [IfcFurniture]
->Furniture_Bed_1:1525x2007x355mm-Queen: [IfcFurniture]
- Entrance hall [IfcSpace]
Roof [IfcBuildingStorey]
->Basic Roof:Roof_Flat-4Felt-150Ins-50Scr-150Conc-12Plr: [IfcRoof]
->Floor:Simple floor: [IfcSlab]
- Roof [IfcSpace]
xBIM 基础16 IFC的空间层次结构的更多相关文章
- xBIM 基础15 IFC导出Excel报表
系列目录 [已更新最新开发文章,点击查看详细] IFC导出Excel空间报表文件 本篇将向您展示从IFC文件读取数据所需的一些概念.它使用IFC4接口,适用于IFC2x3和IFC4型号.要创建 ...
- xBIM 多个IFC文件合并
目录 xBIM 应用与学习 (一) xBIM 应用与学习 (二) xBIM 基本的模型操作 xBIM 日志操作 XBIM 3D 墙壁案例 xBIM 格式之间转换 xBIM 使用Linq 来优化查询 x ...
- [.net 面向对象编程基础] (16) 接口
[.net 面向对象编程基础] (16) 接口 关于“接口”一词,跟我们平常看到的电脑的硬件“接口”意义上是差不多的.拿一台电脑来说,我们从外面,可以看到他的USB接口,COM接口等,那么这些接口的目 ...
- 十六. Python基础(16)--内置函数-2
十六. Python基础(16)--内置函数-2 1 ● 内置函数format() Convert a value to a "formatted" representation. ...
- Java基础16:Java多线程基础最全总结
Java基础16:Java多线程基础最全总结 Java中的线程 Java之父对线程的定义是: 线程是一个独立执行的调用序列,同一个进程的线程在同一时刻共享一些系统资源(比如文件句柄等)也能访问同一个进 ...
- xBIM 基础10 WeXplorer 浏览器检查
系列目录 [已更新最新开发文章,点击查看详细] 在上一篇 <xBIM基础 09 WeXplorer 基本应用> 已经提到,查看器不会在所有浏览器的所有设备上运行.为了操作效率和简单 ...
- Flask基础(16)-->WTForms表单创建和简单验证
Flask基础(16)-->WTForms表单创建和简单验证 前言:使用Flask_WTF需要配置参数SECRET_KEYCSRF_ENABLED是为了CSRF(跨站请求伪造)保护.SECRET ...
- 基础图像处理之混合空间增强——(Java:拉普拉斯锐化、Sobel边缘检测、均值滤波、伽马变换)
相信看过冈萨雷斯第三版数字图像处理的童鞋都知道,里面涉及到了很多的基础图像处理的算法,今天,就专门借用其中一个混合空间增强的案例,来将常见的几种图像处理算法集合起来,看能发生什么样的化学反应 首先,通 ...
- xBIM 基础02 快速入门
系列目录 [已更新最新开发文章,点击查看详细] 一.新建项目 Visual Studio 新建项目.项目创建完成后 Nuget ,项目添加 Xbim.Essentials,那么如果项目需要几何 ...
随机推荐
- chrome设置书签默认显示
实用的设置! 这样已设置,就可以方便的查看一些常用的书签了!
- 转:Java修改Excel单元格的数据及格式
https://blog.csdn.net/aking21alinjuju/article/details/6001153?locationNum=2 继前两节的Java读取.写入Excel后,本期将 ...
- MySql悲观锁总结与实践
mysql(for update)悲观锁总结与实践 https://blog.csdn.net/zmx729618/article/details/52701972 悲观锁,正如其名,它指的是对数据被 ...
- python2 与 python3 语法区别--转
原文地址:http://old.sebug.net/paper/books/dive-into-python3/porting-code-to-python-3-with-2to3.html 使用2t ...
- Java NIO(七)管道
Java NIO 管道是两个线程之间的单向数据连接.Pipe有一个source通道和sink通道(内部类).数据会被写到sink通道,从source通道读取. 给一张Pipe通道的原理图: 创建管道: ...
- Android 强制软键盘关闭
在Android开发过程中,有时候我们会有强制关闭软键盘的需求.比如说:现在有一个文本编辑框(testEt)和一个按钮(testBtn),我们现在点击文本编辑框testEd,这时会弹出软键盘,然后我们 ...
- Book 动态规划
虽然之前学过一点点,但是还是不会------现在好好跟着白书1.4节学一下—————— (1)数字三角形 d(i,j) = max(d(i+1,j),d(i+1,j+1)) + a[i][j] hdu ...
- NSRunloop总结
NSRunloop是一个消息处理机制:是一个循环. 系统通过消息队列和runloop与进程(线程)通信. runloop是一个机制和体系结构. 它包含以下几个方面: 1.事件源管理: 2.事件的检索与 ...
- 3D立体方块旋转图册
代码可直接复制使用看效果 这个文章参考了Lazy.Cat的文章:https://www.cnblogs.com/Lazy-Cat/p/9750244.html,大家也可以去看看,他讲的还是比较详细的. ...
- 电子邮件的三个协议: SMTP、IMAP、POP3
个人总结: 读完这篇文章需要10分钟 讲解了跟电子邮件有关的三个协议: SMTP(simple message transfer protocol 简单信息传输协议 IMAP (internet me ...