Ejemplo n.º 1
0
        /// <summary>
        ///   Creates new body representation it as "Body", "Brep".
        /// </summary>
        /// <param name = "context">Geometry context</param>
        /// <returns>New empty set of representation items</returns>
        public static IfcShapeRepresentation GetNewSweptSolidShapeRepresentation(this IfcProduct prod,
                                                                                 IfcRepresentationContext
                                                                                 context)
        {
            var model = (prod as IPersistEntity).Model;

            if (model == null)
            {
                model = prod.Model;
            }
            var definitionShape = prod.Representation as IfcProductDefinitionShape;

            if (definitionShape == null)
            {
                definitionShape     = model.Instances.New <IfcProductDefinitionShape>();
                prod.Representation = definitionShape;
            }

            var shapeRepresentation = model.Instances.New <IfcShapeRepresentation>();

            shapeRepresentation.ContextOfItems           = context; // model.IfcProject.ModelContext();
            shapeRepresentation.RepresentationIdentifier = "Body";
            shapeRepresentation.RepresentationType       = "SweptSolid";
            definitionShape.Representations.Add(shapeRepresentation);
            return(shapeRepresentation);
        }
Ejemplo n.º 2
0
        public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext,
            IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth)
        {
            var extruded = new IfcExtrudedAreaSolid
                               {
                                   SweptArea = ifcProfileDef,
                                   Position =  placement3D,
                                   ExtrudedDirection = direction ,
                                   Depth = depth,
                               };

            var shaperep = new IfcShapeRepresentation
                               {
                                   ContextOfItems = representationContext,
                                   RepresentationIdentifier = "Body",
                                   RepresentationType = "SweptSolid",
                                   Items = new List<IfcRepresentationItem>(),
                               };
            shaperep.Items.Add(extruded);

            var ifcShape = new IfcProductDefinitionShape
                               {
                                   // Name=
                                   // Description =
                                   Representations = new List<IfcRepresentation>(),
                               };
            ifcShape.Representations.Add(shaperep);

            return ifcShape;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Convert a wall to an IfcWallStandardCase
        /// </summary>
        /// <param name="wall"></param>
        /// <param name="context"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        private static IfcWallStandardCase ToIfcWallStandardCase(this Wall wall, IfcRepresentationContext context, Document doc)
        {
            var sweptArea        = wall.CenterLine.Thicken(wall.Thickness()).ToIfcArbitraryClosedProfileDef(doc);
            var extrudeDirection = Vector3.ZAxis.ToIfcDirection();

            // We don't use the Wall's transform for positioning, because
            // our walls have a transform that lays the wall "flat". Just
            // use a identity transform.
            var position = new Transform().ToIfcAxis2Placement3D(doc);
            var repItem  = new IfcExtrudedAreaSolid(sweptArea, position,
                                                    extrudeDirection, new IfcPositiveLengthMeasure(wall.Height));
            var rep = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> {
                repItem
            });
            var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                rep
            });
            var id             = IfcGuid.ToIfcGuid(Guid.NewGuid());
            var localPlacement = new Transform().ToIfcLocalPlacement(doc);
            var ifcWall        = new IfcWallStandardCase(new IfcGloballyUniqueId(id),
                                                         null, wall.Name, null, null, localPlacement, productRep, null);

            doc.AddEntity(sweptArea);
            doc.AddEntity(extrudeDirection);
            doc.AddEntity(position);
            doc.AddEntity(repItem);
            doc.AddEntity(rep);
            doc.AddEntity(localPlacement);
            doc.AddEntity(productRep);
            doc.AddEntity(ifcWall);

            return(ifcWall);
        }
Ejemplo n.º 4
0
        public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext,
                                                               IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth)
        {
            var extruded = new IfcExtrudedAreaSolid
            {
                SweptArea         = ifcProfileDef,
                Position          = placement3D,
                ExtrudedDirection = direction,
                Depth             = depth,
            };

            var shaperep = new IfcShapeRepresentation
            {
                ContextOfItems           = representationContext,
                RepresentationIdentifier = "Body",
                RepresentationType       = "SweptSolid",
                Items = new List <IfcRepresentationItem>(),
            };

            shaperep.Items.Add(extruded);

            var ifcShape = new IfcProductDefinitionShape
            {
                // Name=
                // Description =
                Representations = new List <IfcRepresentation>(),
            };

            ifcShape.Representations.Add(shaperep);

            return(ifcShape);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Returns set of IFC representation items from the specified context or null;
        /// </summary>
        public static IItemSet <IfcRepresentationItem> GetShapeRepresentationItems(this IfcProduct prod,
                                                                                   IfcRepresentationContext context)
        {
            var definitionShape = prod.Representation as IfcProductDefinitionShape;

            if (definitionShape == null)
            {
                return(null);
            }

            var shapeRepresentation =
                definitionShape.Representations.FirstOrDefault <IfcShapeRepresentation>(rep => rep.ContextOfItems == context);

            return(shapeRepresentation == null ? null : shapeRepresentation.Items);
        }
Ejemplo n.º 6
0
        private static IfcBeam ToIfcBeam(this Beam beam, IfcRepresentationContext context, Document doc)
        {
            var sweptArea = beam.ElementType.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
            var line      = beam.Curve as Line;

            if (line == null)
            {
                throw new Exception("The beam could not be exported to IFC. Only linear beams are currently supported.");
            }

            // We use the Z extrude direction because the direction is
            // relative to the local placement, which is a transform at the
            // beam's end with the Z axis pointing along the direction.

            var extrudeDirection = Vector3.ZAxis.ToIfcDirection();

            var position = new Transform().ToIfcAxis2Placement3D(doc);
            var repItem  = new IfcExtrudedAreaSolid(sweptArea, position,
                                                    extrudeDirection, new IfcPositiveLengthMeasure(beam.Curve.Length()));
            var localPlacement = beam.Curve.TransformAt(0.0).ToIfcLocalPlacement(doc);
            var rep            = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> {
                repItem
            });
            var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                rep
            });
            var ifcBeam = new IfcBeam(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, productRep, null);

            doc.AddEntity(sweptArea);
            doc.AddEntity(extrudeDirection);
            doc.AddEntity(position);
            doc.AddEntity(repItem);
            doc.AddEntity(rep);
            doc.AddEntity(localPlacement);
            doc.AddEntity(productRep);
            doc.AddEntity(ifcBeam);

            return(ifcBeam);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///   Returns set of IFC representation items from the specified context or null;
        /// </summary>
        public static XbimSet <IfcRepresentationItem> GetShapeRepresentationItems(this IfcProduct prod,
                                                                                  IfcRepresentationContext context)
        {
            IfcProductDefinitionShape definitionShape = prod.Representation as IfcProductDefinitionShape;

            if (definitionShape == null)
            {
                return(null);
            }

            IfcShapeRepresentation shapeRepresentation =
                definitionShape.Representations.Where(rep => rep.ContextOfItems == context).FirstOrDefault() as
                IfcShapeRepresentation;

            if (shapeRepresentation == null)
            {
                return(null);
            }

            XbimSet <IfcRepresentationItem> shapeRepresentationItems = shapeRepresentation.Items;

            return(shapeRepresentationItems);
        }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
                _contextOfItems = (IfcRepresentationContext)(value.EntityVal);
                return;

            case 1:
                _representationIdentifier = value.StringVal;
                return;

            case 2:
                _representationType = value.StringVal;
                return;

            case 3:
                _items.InternalAdd((IfcRepresentationItem)value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Ejemplo n.º 9
0
        private static IfcOpeningElement ToIfcOpeningElement(this Opening opening, IfcRepresentationContext context, Document doc, IfcObjectPlacement parent)
        {
            // var sweptArea = opening.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
            // We use the Z extrude direction because the direction is
            // relative to the local placement, which is a transform at the
            // beam's end with the Z axis pointing along the direction.

            // var extrudeDirection = opening.ExtrudeDirection.ToIfcDirection();
            // var position = new Transform().ToIfcAxis2Placement3D(doc);
            // var solid = new IfcExtrudedAreaSolid(sweptArea, position,
            //     extrudeDirection, new IfcPositiveLengthMeasure(opening.ExtrudeDepth));

            var solid          = opening.ToIfcExtrudedAreaSolid(new Transform(), doc);
            var localPlacement = new Transform().ToIfcLocalPlacement(doc, parent);

            var shape = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> {
                solid
            });
            var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                shape
            });

            var ifcOpening = new IfcOpeningElement(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, productRep, null);

            // doc.AddEntity(sweptArea);
            // doc.AddEntity(extrudeDirection);
            // doc.AddEntity(position);
            // doc.AddEntity(repItem);

            doc.AddEntity(solid);
            doc.AddEntity(localPlacement);
            doc.AddEntity(shape);
            doc.AddEntity(productRep);

            return(ifcOpening);
        }
Ejemplo n.º 10
0
 public static IfcShapeRepresentation GetOrCreateSweptSolidShapeRepresentation(this IfcProduct prod, IfcRepresentationContext context)
 {
     return(GetSweptSolidShapeRepresentation(prod) ?? GetNewSweptSolidShapeRepresentation(prod, context));
 }
Ejemplo n.º 11
0
        private static IfcProductDefinitionShape ToIfcProductDefinitionShape(this List <IfcRepresentationItem> geoms, string shapeType, IfcRepresentationContext context, Document doc)
        {
            var rep   = new IfcShapeRepresentation(context, "Body", shapeType, geoms);
            var shape = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                rep
            });

            doc.AddEntity(rep);

            return(shape);
        }
Ejemplo n.º 12
0
        private static List <IfcProduct> ToIfcProducts(this Element e, IfcRepresentationContext context, Document doc)
        {
            var products = new List <IfcProduct>();

            if (e is IAggregateElements)
            {
                // TODO: Create the IFC aggregation relationship
                foreach (var subEl in ((IAggregateElements)e).Elements)
                {
                    products.AddRange(subEl.ToIfcProducts(context, doc));
                }

                return(products);
            }

            IfcProductDefinitionShape shape = null;
            var localPlacement = e.Transform.ToIfcLocalPlacement(doc);
            IfcGeometricRepresentationItem geom = null;

            if (e is ISweepAlongCurve)
            {
                var sweep = (ISweepAlongCurve)e;
                geom = sweep.ToIfcSurfaceCurveSweptAreaSolid(e.Transform, doc);
            }
            else if (e is IExtrude)
            {
                var extrude = (IExtrude)e;
                geom = extrude.ToIfcExtrudedAreaSolid(e.Transform, doc);
            }
            else if (e is ILamina)
            {
                var lamina = (ILamina)e;
                geom = lamina.ToIfcShellBasedSurfaceModel(e.Transform, doc);
            }
            else
            {
                throw new Exception("Only IExtrude, ISweepAlongCurve, and ILamina representations are currently supported.");
            }

            shape = ToIfcProductDefinitionShape(geom, context, doc);

            doc.AddEntity(shape);
            doc.AddEntity(localPlacement);
            doc.AddEntity(geom);

            var product = ConvertElementToIfcProduct(e, localPlacement, shape);

            products.Add(product);
            doc.AddEntity(product);

            // If the element has openings,
            // Make opening relationships in
            // the IfcElement.
            if (e is IHasOpenings)
            {
                var openings = (IHasOpenings)e;
                if (openings.Openings.Count > 0)
                {
                    foreach (var o in openings.Openings)
                    {
                        var element = (IfcElement)product;
                        var opening = o.ToIfcOpeningElement(context, doc, localPlacement);
                        var voidRel = new IfcRelVoidsElement(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, element, opening);
                        element.HasOpenings.Add(voidRel);
                        doc.AddEntity(opening);
                        doc.AddEntity(voidRel);
                    }
                }
            }

            IfcStyledItem style = null;

            if (e is IMaterial)
            {
                var m = (IMaterial)e;
                style = m.Material.ToIfcStyledItem(geom, doc);
            }
            if (e is IElementType <StructuralFramingType> )
            {
                var m = (IElementType <StructuralFramingType>)e;
                style = m.ElementType.Material.ToIfcStyledItem(geom, doc);
            }
            else if (e is IElementType <WallType> )
            {
                var m = (IElementType <WallType>)e;
                style = m.ElementType.MaterialLayers[0].Material.ToIfcStyledItem(geom, doc);
            }
            else if (e is IElementType <FloorType> )
            {
                var m = (IElementType <FloorType>)e;
                style = m.ElementType.MaterialLayers[0].Material.ToIfcStyledItem(geom, doc);
            }

            // Associate the style with the element
            style.Item = geom;

            geom.StyledByItem = new List <IfcStyledItem> {
                style
            };
            doc.AddEntity(style);

            return(products);
        }
Ejemplo n.º 13
0
 public static IfcShapeRepresentation GetOrCreateSweptSolidShapeRepresentation(this IfcProduct prod, IfcRepresentationContext context)
 {
     return GetSweptSolidShapeRepresentation(prod) ?? GetNewSweptSolidShapeRepresentation(prod, context);
 }
Ejemplo n.º 14
0
        /// <summary>
        ///   Returns set of IFC representation items from the specified context or null;
        /// </summary>
        public static XbimSet<IfcRepresentationItem> GetShapeRepresentationItems(this IfcProduct prod,
                                                                                 IfcRepresentationContext context)
        {
            IfcProductDefinitionShape definitionShape = prod.Representation as IfcProductDefinitionShape;
            if (definitionShape == null)
            {
                return null;
            }

            IfcShapeRepresentation shapeRepresentation =
                definitionShape.Representations.Where(rep => rep.ContextOfItems == context).FirstOrDefault() as
                IfcShapeRepresentation;
            if (shapeRepresentation == null) return null;

            XbimSet<IfcRepresentationItem> shapeRepresentationItems = shapeRepresentation.Items;
            return shapeRepresentationItems;
        }
Ejemplo n.º 15
0
        private IfcShapeRepresentation CreateShapeRepresentation(IfcRepresentationContext context,
                                                                 Representation representation)
        {
            //create presentation styles
            var presentationStyleDictionary = new Dictionary <String, IfcPresentationStyle>();

            foreach (Material material in representation.materials)
            {
                try
                {
                    presentationStyleDictionary.Add(material.id,
                                                    IfcInit.CreateSurfaceStyle(material.name,
                                                                               material.color,
                                                                               material.metal,
                                                                               material.roughness));
                }
                catch (ArgumentException ex)
                {
                    throw new ArgumentException(string.Format("Material with id {0} already exists", material.id),
                                                "materials", ex);
                }
            }

            //create representation items
            var representationItemList = new List <IfcRepresentationItem>();

            foreach (RepresentationItem item in representation.representationItems)
            {
                IfcRepresentationItem representationItem;
                try
                {
                    representationItem = RepresentationParser.ParseConstructionString(item.constructionString);
                }
                catch (ArgumentException ex)
                {
                    var errors = new Dictionary <string, string[]>();
                    errors.Add(ex.ParamName, new string[] { ex.Message });
                    throw new ValidationException(errors, ex.Message);
                }

                if (item.transformation != null)
                {
                    representationItem.ApplyQuaternion(new Quaternion(item.transformation.rotation))
                    .Translate(item.transformation.translation);
                }

                if (item.material != null)
                {
                    IfcPresentationStyle surfaceStyle;
                    if (presentationStyleDictionary.TryGetValue(item.material, out surfaceStyle))
                    {
                        representationItem.StyledBy(new IfcPresentationStyle[] { surfaceStyle });
                    }
                }

                representationItemList.Add(representationItem);
            }
            return(new IfcShapeRepresentation(context,
                                              new IfcLabel("Body"),
                                              new IfcLabel("SolidModel"),
                                              representationItemList.ToArray()));
        }
Ejemplo n.º 16
0
        /// <summary>
        ///   Creates new body representation it as "Body", "Brep".
        /// </summary>
        /// <param name = "context">Geometry context</param>
        /// <returns>New empty set of representation items</returns>
        public static IfcShapeRepresentation GetNewSweptSolidShapeRepresentation(this IfcProduct prod,
                                                                                              IfcRepresentationContext
                                                                                                  context)
        {
            IModel model = (prod as IPersistIfcEntity).ModelOf;
            if (model == null) model = prod.ModelOf;
            IfcProductDefinitionShape definitionShape = prod.Representation as IfcProductDefinitionShape;
            if (definitionShape == null)
            {
                definitionShape = model.Instances.New<IfcProductDefinitionShape>();
                prod.Representation = definitionShape;
            }

            IfcShapeRepresentation shapeRepresentation = model.Instances.New<IfcShapeRepresentation>();
            shapeRepresentation.ContextOfItems = context; // model.IfcProject.ModelContext();
            shapeRepresentation.RepresentationIdentifier = "Body";
            shapeRepresentation.RepresentationType = "SweptSolid";
            definitionShape.Representations.Add(shapeRepresentation);
            return shapeRepresentation;
        }
Ejemplo n.º 17
0
        internal static List <IfcProduct> ToIfcProducts(this Element e,
                                                        IfcRepresentationContext context,
                                                        Document doc,
                                                        Dictionary <Guid, List <IfcStyleAssignmentSelect> > styleAssignments)
        {
            var products = new List <IfcProduct>();

            IfcProductDefinitionShape shape      = null;
            GeometricElement          geoElement = null;
            Transform trans = null;
            Guid      id    = default(Guid);

            if (e is ElementInstance)
            {
                // If we're using an element instance, get the transform
                // and the id and use those to uniquely position and
                // identify the element.
                var instance = (ElementInstance)e;
                geoElement = instance.BaseDefinition;
                id         = instance.Id;
                trans      = instance.Transform;
            }
            else if (e is GeometricElement)
            {
                // If we've go a geometric element, use its properties as-is.
                geoElement = (GeometricElement)e;
                id         = geoElement.Id;
                trans      = geoElement.Transform;
            }

            geoElement.UpdateRepresentations();

            var localPlacement = trans.ToIfcLocalPlacement(doc);

            doc.AddEntity(localPlacement);

            var geoms = new List <IfcRepresentationItem>();

            if (geoElement is MeshElement)
            {
                var meshEl  = (MeshElement)geoElement;
                var lengths = meshEl.Mesh.Vertices.Select(v => v.Position.ToArray().Select(vi => new IfcLengthMeasure(vi)).ToList()).ToList();
                var pts     = new IfcCartesianPointList3D(lengths);
                doc.AddEntity(pts);
                var indices = meshEl.Mesh.Triangles.Select(t => t.Vertices.Select(vx => new IfcPositiveInteger(vx.Index + 1)).ToList()).ToList();
                var idxs    = new List <List <IfcPositiveInteger> >(indices);
                var geom    = new IfcTriangulatedFaceSet(pts, indices);
                geom.Closed = false;
                doc.AddEntity(geom);
                geoms.Add(geom);
                shape = ToIfcProductDefinitionShape(geoms, "Tessellation", context, doc);
            }
            else
            {
                foreach (var op in geoElement.Representation.SolidOperations)
                {
                    if (op is Sweep)
                    {
                        var sweep = (Sweep)op;

                        // Neither of these entities, which are part of the
                        // IFC4 specification, and which would allow a sweep
                        // along a curve, are supported by many applications
                        // which are supposedly IFC4 compliant (Revit). For
                        // Those applications where these entities appear,
                        // the rotation of the profile is often wrong or
                        // inconsistent.
                        // geom = sweep.ToIfcSurfaceCurveSweptAreaSolid(doc);
                        // geom = sweep.ToIfcFixedReferenceSweptAreaSolid(geoElement.Transform, doc);

                        // Instead, we'll divide the curve and create a set of
                        // linear extrusions instead.
                        Polyline pline;
                        if (sweep.Curve is Line)
                        {
                            pline = sweep.Curve.ToPolyline(1);
                        }
                        else
                        {
                            pline = sweep.Curve.ToPolyline();
                        }
                        foreach (var segment in pline.Segments())
                        {
                            var position         = segment.TransformAt(0.0).ToIfcAxis2Placement3D(doc);
                            var extrudeDepth     = segment.Length();
                            var extrudeProfile   = sweep.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
                            var extrudeDirection = Vector3.ZAxis.Negate().ToIfcDirection();
                            var geom             = new IfcExtrudedAreaSolid(extrudeProfile, position,
                                                                            extrudeDirection, new IfcPositiveLengthMeasure(extrudeDepth));

                            doc.AddEntity(extrudeProfile);
                            doc.AddEntity(extrudeDirection);
                            doc.AddEntity(position);
                            doc.AddEntity(geom);
                            geoms.Add(geom);
                        }
                    }
                    else if (op is Extrude)
                    {
                        var extrude = (Extrude)op;
                        var geom    = extrude.ToIfcExtrudedAreaSolid(doc);
                        doc.AddEntity(geom);
                        geoms.Add(geom);
                    }
                    else if (op is Lamina)
                    {
                        var lamina = (Lamina)op;
                        var geom   = lamina.ToIfcShellBasedSurfaceModel(doc);
                        doc.AddEntity(geom);
                        geoms.Add(geom);
                    }
                    else
                    {
                        throw new Exception("Only IExtrude, ISweepAlongCurve, and ILamina representations are currently supported.");
                    }
                }
                shape = ToIfcProductDefinitionShape(geoms, "SolidModel", context, doc);
            }
            doc.AddEntity(shape);


            // Can we use IfcMappedItem?
            // https://forums.buildingsmart.org/t/can-tessellation-typed-representation-hold-items-from-another-group/1621
            // var rep = new IfcShapeRepresentation(context, "Body", "Solids", geoms);
            // doc.AddEntity(rep);
            // var axisPt = Vector3.Origin.ToIfcCartesianPoint();
            // doc.AddEntity(axisPt);
            // var axis = new IfcAxis2Placement2D(axisPt);
            // doc.AddEntity(axis);
            // var repMap = new IfcRepresentationMap(new IfcAxis2Placement(axis), rep);
            // doc.AddEntity(repMap);
            // var x = trans.XAxis.ToIfcDirection();
            // var y = trans.YAxis.ToIfcDirection();
            // var z = trans.ZAxis.ToIfcDirection();
            // var origin = trans.Origin.ToIfcCartesianPoint();
            // var cart = new IfcCartesianTransformationOperator3D(x, y, origin, trans.XAxis.Length(), z);
            // doc.AddEntity(x);
            // doc.AddEntity(y);
            // doc.AddEntity(z);
            // doc.AddEntity(origin);
            // doc.AddEntity(cart);
            // var mappedItem = new IfcMappedItem(repMap, cart);
            // doc.AddEntity(mappedItem);
            // var shapeRep= new IfcShapeRepresentation(context, new List<IfcRepresentationItem>(){mappedItem});
            // doc.AddEntity(shapeRep);
            // shape = new IfcProductDefinitionShape(new List<IfcRepresentation>(){shapeRep});
            // doc.AddEntity(shape);

            var product = ConvertElementToIfcProduct(id, geoElement, localPlacement, shape);

            products.Add(product);
            doc.AddEntity(product);

            var ifcOpenings = doc.AllEntities.Where(ent => ent.GetType() == typeof(IfcOpeningElement)).Cast <IfcOpeningElement>();

            // If the element has openings, make opening relationships in
            // the IfcElement.
            if (e is IHasOpenings)
            {
                var openings = (IHasOpenings)e;
                if (openings.Openings.Count > 0)
                {
                    foreach (var o in openings.Openings)
                    {
                        var element = (IfcElement)product;
                        // TODO: Find the opening that we've already created that relates here
                        var opening = ifcOpenings.First(ifcO => ifcO.GlobalId == IfcGuid.ToIfcGuid(o.Id));
                        var voidRel = new IfcRelVoidsElement(IfcGuid.ToIfcGuid(Guid.NewGuid()), element, opening);
                        element.HasOpenings.Add(voidRel);
                        doc.AddEntity(voidRel);
                    }
                }
            }

            foreach (var geom in geoms)
            {
                var styledItem = new IfcStyledItem(geom, styleAssignments[geoElement.Material.Id], null);
                doc.AddEntity(styledItem);
            }

            return(products);
        }
Ejemplo n.º 18
0
 public virtual void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _contextOfItems = (IfcRepresentationContext) value.EntityVal;
             break;
         case 1:
             _representationIdentifier = value.StringVal;
             break;
         case 2:
             _representationType = value.StringVal;
             break;
         case 3:
             ((IXbimNoNotifyCollection)_items).Add((IfcRepresentationItem) value.EntityVal);
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Ejemplo n.º 19
0
        private static IfcProductDefinitionShape ToIfcProductDefinitionShape(this IfcGeometricRepresentationItem geom, IfcRepresentationContext context, Document doc)
        {
            var rep = new IfcShapeRepresentation(context, "Body", "SweptSolid",
                                                 new List <IfcRepresentationItem> {
                geom
            });
            var shape = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                rep
            });

            doc.AddEntity(rep);

            return(shape);
        }