本篇介绍如何从文件中检索空间结构。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的空间层次结构的更多相关文章

  1. xBIM 基础15 IFC导出Excel报表

    系列目录    [已更新最新开发文章,点击查看详细]  IFC导出Excel空间报表文件 本篇将向您展示从IFC文件读取数据所需的一些概念.它使用IFC4接口,适用于IFC2x3和IFC4型号.要创建 ...

  2. xBIM 多个IFC文件合并

    目录 xBIM 应用与学习 (一) xBIM 应用与学习 (二) xBIM 基本的模型操作 xBIM 日志操作 XBIM 3D 墙壁案例 xBIM 格式之间转换 xBIM 使用Linq 来优化查询 x ...

  3. [.net 面向对象编程基础] (16) 接口

    [.net 面向对象编程基础] (16) 接口 关于“接口”一词,跟我们平常看到的电脑的硬件“接口”意义上是差不多的.拿一台电脑来说,我们从外面,可以看到他的USB接口,COM接口等,那么这些接口的目 ...

  4. 十六. Python基础(16)--内置函数-2

    十六. Python基础(16)--内置函数-2 1 ● 内置函数format() Convert a value to a "formatted" representation. ...

  5. Java基础16:Java多线程基础最全总结

    Java基础16:Java多线程基础最全总结 Java中的线程 Java之父对线程的定义是: 线程是一个独立执行的调用序列,同一个进程的线程在同一时刻共享一些系统资源(比如文件句柄等)也能访问同一个进 ...

  6. xBIM 基础10 WeXplorer 浏览器检查

    系列目录    [已更新最新开发文章,点击查看详细]  在上一篇 <xBIM基础 09 WeXplorer 基本应用> 已经提到,查看器不会在所有浏览器的所有设备上运行.为了操作效率和简单 ...

  7. Flask基础(16)-->WTForms表单创建和简单验证

    Flask基础(16)-->WTForms表单创建和简单验证 前言:使用Flask_WTF需要配置参数SECRET_KEYCSRF_ENABLED是为了CSRF(跨站请求伪造)保护.SECRET ...

  8. 基础图像处理之混合空间增强——(Java:拉普拉斯锐化、Sobel边缘检测、均值滤波、伽马变换)

    相信看过冈萨雷斯第三版数字图像处理的童鞋都知道,里面涉及到了很多的基础图像处理的算法,今天,就专门借用其中一个混合空间增强的案例,来将常见的几种图像处理算法集合起来,看能发生什么样的化学反应 首先,通 ...

  9. xBIM 基础02 快速入门

    系列目录    [已更新最新开发文章,点击查看详细]  一.新建项目 Visual Studio 新建项目.项目创建完成后 Nuget ,项目添加 Xbim.Essentials,那么如果项目需要几何 ...

随机推荐

  1. UESTC--1264--人民币的构造(数学规律)

    人民币的构造 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu Submit Status D ...

  2. [十二省联考2019] 异或粽子 解题报告 (可持久化Trie+堆)

    interlinkage: https://www.luogu.org/problemnew/show/P5283 description: solution: 显然有$O(n^2)$的做法,前缀和优 ...

  3. gdal集成kml库的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 最近要读取kml文件,具体就是把kml文件当作一个矢量文件来读取.我发现gdal是支持集成kml库的.不过集成这个km ...

  4. Javascript常用字符串判断函数

    [代码] 字符串,函数,Javascript,脚本100 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...

  5. Linux中删除特殊符号文件名文件

    Linux 系统下的文件名长度最多可到256个字符.通常情况下,文件名的字符包括:字母.数字.“.”(点).“_”(下划线)和“-”(连字符). Linux 允许在文件名中使用除上述符号之外的其它符号 ...

  6. 堆————数据流的第k个大的元素

    解题思路 一般地,堆和堆排序——解决 "贪心算法及其类似问题" 的利器. # 思路:我们可以用一个小根堆来做,并且限制堆的大小为k,初始化时把nums的每个数都push到堆中,如果 ...

  7. Java 应用运维

    作者:http://blogread.cn/it/article/4918?f=wb 出处:http://blogread.cn/it/article/4918?f=wb Java应用运维    出处 ...

  8. HDU 5776 sum( 鸽巢定理简单题 )

    链接:传送门 题意:给一个长为 n 的串,问是否有子串的和是 m 的倍数. 思路:典型鸽巢定理的应用,但是这里 n,m 的大小关系是不确定的,如果 n >= m 根据定理可以很简单的判定是一定有 ...

  9. crm 系统项目(二) admin 后台操作表格

    crm 系统项目(二) admin 后台操作表格 1. app下创建 templates  运行的时候 先找全局的templates——> 按照app的注册顺序找templates中的文件 2. ...

  10. js应用中的小细节-时间戳的转换和input输入框有效数字

    1 input输入框内value值保留有效数字,js自带的方法.toFixed(),但是直接使用会报错,因为不论输入框内输入汉字.字母还是数字,类型都是string.解决的办法是将其转换为number ...