博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
xBIM 基础16 IFC的空间层次结构
阅读量:4341 次
发布时间:2019-06-07

本文共 4345 字,大约阅读时间需要 14 分钟。

系列目录     

本篇介绍如何从文件中检索空间结构。IFC中的空间结构表示层次结构的嵌套结构,表示项目,站点,建筑物,楼层和空间。如果您查看 您会发现建筑物可以包含楼层以及其他建筑物,楼层可以包含空间以及其他楼层等。此类关系也使用建模, 但如果要查找特定空间结构中包含的元素,则将其建模为  因此它取决于您要查找的内容。下面的示例演示如何使用上述两种关系搜索和遍历数据以获得完整的层次结构。

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
(); PrintHierarchy(project, 0); } } 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 +1); } private static string GetIndent(int level) { var indent = ""; for (int i = 0; i < level; i++) indent += " "; return indent; } }}

输出结果如下:

Project Number [IfcProject]  Default [IfcSite]     [IfcBuilding]      Ground Floor [IfcBuildingStorey]          ->Basic Wall:Wall-Ext_102Bwk-75Ins-100LBlk-12P:285330 [IfcWall]          ->Basic Wall:Wall-Ext_102Bwk-75Ins-100LBlk-12P:285395 [IfcWall]          ->Basic Wall:Wall-Ext_102Bwk-75Ins-100LBlk-12P:285459 [IfcWall]          ->Curtain Wall:Curtain_Wall-Exterior_Glazing:285582 [IfcCurtainWall]          ->Curtain Wall:Curtain_Wall-Exterior_Glazing:285684 [IfcCurtainWall]          ->Basic Wall:Wall-Partn_12P-70MStd-12P:285792 [IfcWallStandardCase]          ->Basic Wall:Wall-Partn_12P-70MStd-12P:285846 [IfcWallStandardCase]          ->Doors_ExtDbl_Flush:1810x2110mm:285860 [IfcDoor]          ->Doors_IntSgl:810x2110mm:285959 [IfcDoor]          ->Doors_IntSgl:810x2110mm:285996 [IfcDoor]          ->Windows_Sgl_Plain:1810x1210mm:286105 [IfcWindow]          ->Windows_Sgl_Plain:1810x1210mm:286188 [IfcWindow]          ->Windows_Sgl_Plain:1810x1210mm:286238 [IfcWindow]          ->Compound Ceiling:Plain:286319 [IfcCovering]          ->Compound Ceiling:Plain:286329 [IfcCovering]          ->Compound Ceiling:Plain:286337 [IfcCovering]          ->Floor:Floor-Grnd-Susp_65Scr-80Ins-100Blk-75PC:286349 [IfcSlab]          ->Windows_Sgl_Plain:1810x1210mm:287567 [IfcWindow]        1 - Living room [IfcSpace]            ->Furniture_Table_Dining_w-Chairs_Rectangular:2000x1000x750mm_w-6_Seats:289768 [IfcFurniture]            ->Chair - Dining:Chair - Dining:289769 [IfcFurniture]            ->Chair - Dining:Chair - Dining:289770 [IfcFurniture]            ->Chair - Dining:Chair - Dining:289771 [IfcFurniture]            ->Chair - Dining:Chair - Dining:289772 [IfcFurniture]            ->Chair - Dining:Chair - Dining:290097 [IfcFurniture]            ->Chair - Dining:Chair - Dining:290098 [IfcFurniture]            ->Furniture_Couch_Viper:2290x950x340mm:290852 [IfcFurniture]            ->Furniture_Chair_Viper:1120x940x350mm:291916 [IfcFurniture]            ->Furniture_Chair_Viper:1120x940x350mm:292127 [IfcFurniture]            ->Furniture_Table_Coffee_1:1200x550x450mm:293046 [IfcFurniture]            ->Furniture_Piano:1370x600x1170mm:293961 [IfcFurniture]        2 - Bedroom [IfcSpace]            ->Furniture_Desk:1525x762mm:287689 [IfcFurniture]            ->Furniture_Bed_1:1525x2007x355mm-Queen:295878 [IfcFurniture]        3 - Entrance hall [IfcSpace]      Roof [IfcBuildingStorey]          ->Basic Roof:Roof_Flat-4Felt-150Ins-50Scr-150Conc-12Plr:286419 [IfcRoof]          ->Floor:Simple floor:295048 [IfcSlab]        4 - Roof [IfcSpace]
 
系列目录     

转载于:https://www.cnblogs.com/SavionZhang/p/10983394.html

你可能感兴趣的文章
gethostbyname与sockaddr_in的完美组合
查看>>
kibana的query string syntax 笔记
查看>>
旋转变换(一)旋转矩阵
查看>>
thinkphp3.2.3 bug集锦
查看>>
[BZOJ 4010] 菜肴制作
查看>>
C# 创建 读取 更新 XML文件
查看>>
KD树
查看>>
VsVim - Shortcut Key (快捷键)
查看>>
HDU5447 Good Numbers
查看>>
08.CXF发布WebService(Java项目)
查看>>
java-集合框架
查看>>
RTMP
查看>>
求一个数的整数次方
查看>>
点云PCL中小细节
查看>>
铁路信号基础
查看>>
RobotFramework自动化2-自定义关键字
查看>>
[置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了
查看>>
BABOK - 需求分析(Requirements Analysis)概述
查看>>
第43条:掌握GCD及操作队列的使用时机
查看>>
Windows autoKeras的下载与安装连接
查看>>