private static Floor ToFloor(this IfcSlab slab, IEnumerable <IfcOpeningElement> openings) { var transform = new Transform(); transform.Concatenate(slab.ObjectPlacement.ToTransform()); // Check if the slab is contained in a building storey foreach (var cis in slab.ContainedInStructure) { transform.Concatenate(cis.RelatingStructure.ObjectPlacement.ToTransform()); } var repItems = slab.Representation.Representations.SelectMany(r => r.Items); if (!repItems.Any()) { throw new Exception("The provided IfcSlab does not have any representations."); } var solid = slab.RepresentationsOfType <IfcExtrudedAreaSolid>().FirstOrDefault(); if (solid == null) { return(null); // throw new Exception("No IfcExtrudedAreaSolid could be found in the provided IfcSlab."); } var floorType = new FloorType($"{Guid.NewGuid().ToString()}_floor_type", new List <MaterialLayer> { new MaterialLayer(new Material("slab", Colors.Green), (IfcLengthMeasure)solid.Depth) }); var outline = (Polygon)solid.SweptArea.ToICurve(); var solidTransform = solid.Position.ToTransform(); var floor = new Floor(new Profile(outline), solidTransform, solid.ExtrudedDirection.ToVector3(), floorType, 0, transform); floor.Name = slab.Name; return(floor); }
internal static Floor ToFloor(this IfcSlab slab, IEnumerable <IfcOpeningElement> openings) { var transform = new Transform(); transform.Concatenate(slab.ObjectPlacement.ToTransform()); // Console.WriteLine($"IfcSlab transform:\n{transform}\n"); // Check if the slab is contained in a building storey foreach (var cis in slab.ContainedInStructure) { transform.Concatenate(cis.RelatingStructure.ObjectPlacement.ToTransform()); } var repItems = slab.Representation.Representations.SelectMany(r => r.Items); if (!repItems.Any()) { throw new Exception("The provided IfcSlab does not have any representations."); } var solid = slab.RepresentationsOfType <IfcExtrudedAreaSolid>().FirstOrDefault(); if (solid == null) { return(null); } var outline = (Polygon)solid.SweptArea.ToCurve(); var solidTransform = solid.Position.ToTransform(); solidTransform.Concatenate(transform); var floor = new Floor(new Profile(outline), (IfcLengthMeasure)solid.Depth, solidTransform, BuiltInMaterials.Concrete, null, false, IfcGuid.FromIfcGUID(slab.GlobalId)); floor.Openings.AddRange(openings.Select(o => o.ToOpening())); return(floor); }