protected override CobieZone Mapping(IIfcZone ifcZone, CobieZone target) { base.Mapping(ifcZone, target); if (!target.Categories.Any() || target.Categories.Contains(Helper.UnknownCategory)) { if (!string.IsNullOrWhiteSpace(ifcZone.ObjectType)) { target.Categories.Clear(); var category = StringToCategory.GetOrCreate(ifcZone.ObjectType); target.Categories.Add(category); } } //get spaces in zones var spaces = Helper.GetSpaces(ifcZone); var ifcSpaces = spaces as IList <IIfcSpace> ?? spaces.ToList(); if (ifcSpaces.Any()) { foreach (var space in ifcSpaces) { CobieSpace cSpace; if (ElementToSpace.GetOrCreateTargetObject(space.EntityLabel, out cSpace)) { ElementToSpace.AddMapping(space, cSpace); } target.Spaces.Add(cSpace); } } //TODO: Space Issues return(target); }
protected override CobieFloor Mapping(IIfcSpatialElement ifcSpatialStructureElement, CobieFloor target) { base.Mapping(ifcSpatialStructureElement, target); IEnumerable <IIfcSpatialElement> spaces = null; var site = ifcSpatialStructureElement as IIfcSite; var building = ifcSpatialStructureElement as IIfcBuilding; var storey = ifcSpatialStructureElement as IIfcBuildingStorey; var spaceElement = ifcSpatialStructureElement as IIfcSpace; if (site != null) { target.Categories.Add(StringToCategory.GetOrCreate("Site")); //upgrade code below to use extension method GetSpaces() if (site.IsDecomposedBy != null) { var decomp = site.IsDecomposedBy; var objs = decomp.SelectMany(s => s.RelatedObjects); spaces = objs.OfType <IIfcSpace>(); } } else if (building != null) { target.Categories.Add(StringToCategory.GetOrCreate("Building")); spaces = building.Spaces; } else if (storey != null) { target.Categories.Add(StringToCategory.GetOrCreate("Floor")); if (storey.Elevation.HasValue) { target.Elevation = storey.Elevation.Value; } spaces = storey.Spaces; } else if (spaceElement != null) { target.Categories.Add(StringToCategory.GetOrCreate("Space")); spaces = spaceElement.Spaces; } Helper.TrySetSimpleValue <float>("FloorHeightValue", ifcSpatialStructureElement, f => target.Height = f); //Add spaces var ifcSpatialStructureElements = spaces != null?spaces.ToList() : new List <IIfcSpatialElement>(); ifcSpatialStructureElements.Add(ifcSpatialStructureElement); foreach (var element in ifcSpatialStructureElements) { CobieSpace space; if (!SpatialStructureToSpace.GetOrCreateTargetObject(element.EntityLabel, out space)) { continue; } space = SpatialStructureToSpace.AddMapping(element, space); space.Floor = target; } //TODO: Floor Issues return(target); }
protected override CobieFloor Mapping(IIfcSpatialElement ifcSpatialStructureElement, CobieFloor target) { base.Mapping(ifcSpatialStructureElement, target); IEnumerable <IIfcSpatialElement> spaces = null; var site = ifcSpatialStructureElement as IIfcSite; var building = ifcSpatialStructureElement as IIfcBuilding; var storey = ifcSpatialStructureElement as IIfcBuildingStorey; var spaceElement = ifcSpatialStructureElement as IIfcSpace; if (site != null) { target.Categories.Add(StringToCategory.GetOrCreate("Site")); //upgrade code below to use extension method GetSpaces() if (site.IsDecomposedBy != null) { var decomp = site.IsDecomposedBy; var objs = decomp.SelectMany(s => s.RelatedObjects); spaces = objs.OfType <IIfcSpace>(); } } else if (building != null) { target.Categories.Add(StringToCategory.GetOrCreate("Building")); spaces = building.Spaces; } else if (storey != null) { target.Categories.Add(StringToCategory.GetOrCreate("Floor")); if (storey.Elevation.HasValue) { target.Elevation = storey.Elevation.Value; } spaces = storey.Spaces; } else if (spaceElement != null) { target.Categories.Add(StringToCategory.GetOrCreate("Space")); spaces = spaceElement.Spaces; } Helper.TrySetSimpleValue <float>("FloorHeightValue", ifcSpatialStructureElement, f => target.Height = f); //Add spaces var ifcSpatialStructureElements = spaces != null?spaces.ToList() : new List <IIfcSpatialElement>(); // Previously used to create 'PlaceholderSpaces' but has been removed from CObieExpress. // https://github.com/xBimTeam/XbimExchange/commit/1ef25829a1a8d39a76f70010bedf06f1418954ad //ifcSpatialStructureElements.Add(ifcSpatialStructureElement); foreach (var element in ifcSpatialStructureElements) { CobieSpace space; if (!SpatialStructureToSpace.GetOrCreateTargetObject(element.EntityLabel, out space)) { continue; } space = SpatialStructureToSpace.AddMapping(element, space); space.Floor = target; } //TODO: Floor Issues return(target); }