コード例 #1
0
        /// <summary>
        /// Compares two objects for geometric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcConnectedFaceSet a, IfcRepresentationItem b)
        {
            if (a.Equals(b))
            {
                return(true);
            }
            IfcConnectedFaceSet p = b as IfcConnectedFaceSet;

            if (p == null)
            {
                return(false);
            }
            if (a.CfsFaces.Count != p.CfsFaces.Count)
            {
                return(false);
            }
            List <IfcFace> aFaces = a.CfsFaces.ToList();
            List <IfcFace> bFaces = p.CfsFaces.ToList();

            for (int i = 0; i < aFaces.Count; i++)
            {
                if (!(aFaces[i].GeometricEquals(bFaces[i])))
                {
                    return(false);
                }
            }
            return(true);
        }
 /// <summary>
 /// Compares two objects for geomtric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcRepresentationItem a, IfcRepresentationItem b)
 {
     if (a is IfcSolidModel)
     {
         return(((IfcSolidModel)a).GeometricEquals(b));
     }
     else if (a is IfcBooleanResult)
     {
         return(((IfcBooleanResult)a).GeometricEquals(b));
     }
     else if (a is IfcConnectedFaceSet)
     {
         return(((IfcConnectedFaceSet)a).GeometricEquals(b));
     }
     else if (a is IfcFaceBasedSurfaceModel)
     {
         return(((IfcFaceBasedSurfaceModel)a).GeometricEquals(b));
     }
     else if (a is IfcShellBasedSurfaceModel)
     {
         return(((IfcShellBasedSurfaceModel)a).GeometricEquals(b));
     }
     else if (a is IfcPlane)
     {
         return(((IfcPlane)a).GeometricEquals(b));
     }
     else
     {
         // return false;
         throw new XbimGeometryException("Unsupported solid geometry type " + a.GetType().Name);
     }
 }
コード例 #3
0
        private static IfcStyledItem ToIfcStyledItem(this Material material, IfcRepresentationItem shape, Document doc)
        {
            var color   = material.Color.ToIfcColourRgb(doc);
            var shading = new IfcSurfaceStyleShading(color);

            var styles = new List <IfcSurfaceStyleElementSelect> {
            };

            styles.Add(new IfcSurfaceStyleElementSelect(shading));
            var surfaceStyle = new IfcSurfaceStyle(material.Name, IfcSurfaceSide.POSITIVE, styles);
            var styleSelect  = new IfcPresentationStyleSelect(surfaceStyle);
            var assign       = new IfcPresentationStyleAssignment(new List <IfcPresentationStyleSelect> {
                styleSelect
            });
            var assignments = new List <IfcPresentationStyleAssignment>();

            assignments.Add(assign);
            var styledByItem = new IfcStyledItem(shape, assignments, material.Name);

            doc.AddEntity(color);
            doc.AddEntity(shading);
            doc.AddEntity(surfaceStyle);
            doc.AddEntity(styleSelect);
            doc.AddEntity(assign);

            return(styledByItem);
        }
コード例 #4
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcSolidModel a, IfcRepresentationItem b)
        {
            if (a is IfcExtrudedAreaSolid)
            {
                return(((IfcExtrudedAreaSolid)a).GeometricEquals(b));
            }
            else if (a is IfcFacetedBrep)
            {
                return(((IfcFacetedBrep)a).GeometricEquals(b));
            }
            else if (a is IfcRevolvedAreaSolid)
            {
                return(((IfcRevolvedAreaSolid)a).GeometricEquals(b));
            }
            else if (a is IfcCsgSolid)
            {
                return(((IfcCsgSolid)a).GeometricEquals(b));
            }
            else if (a is IfcSurfaceCurveSweptAreaSolid)
            {
                return(((IfcSurfaceCurveSweptAreaSolid)a).GeometricEquals(b));
            }
            else
            {
                return(false);

                throw new XbimGeometryException("Unsupported solid geometry tpype " + a.GetType().Name);
            }
        }
コード例 #5
0
        public IXbimShapeGeometryData Mesh(IfcRepresentationItem shape)
        {
            var fbm = shape as IfcFaceBasedSurfaceModel;

            if (fbm != null)
            {
                return(Mesh(fbm));
            }
            var sbm = shape as IfcShellBasedSurfaceModel;

            if (sbm != null)
            {
                return(Mesh(sbm));
            }
            var cfs = shape as IfcConnectedFaceSet;

            if (cfs != null)
            {
                return(Mesh(cfs));
            }
            var fbr = shape as IfcFacetedBrep;

            if (fbr != null)
            {
                return(Mesh(fbr));
            }
            throw new ArgumentException("Unsupported representation type for tessellation, " + shape.GetType().Name);
        }
 /// <summary>
 /// Returns a Hash Code for the geometric properties of this object
 /// </summary>
 /// <param name="repItem"></param>
 /// <returns></returns>
 public static int GetGeometryHashCode(this IfcRepresentationItem repItem)
 {
     if (repItem is IfcSolidModel)
     {
         return(((IfcSolidModel)repItem).GetGeometryHashCode());
     }
     else if (repItem is IfcBooleanResult)
     {
         return(((IfcBooleanResult)repItem).GetGeometryHashCode());
     }
     else if (repItem is IfcConnectedFaceSet)
     {
         return(((IfcConnectedFaceSet)repItem).GetGeometryHashCode());
     }
     else if (repItem is IfcFaceBasedSurfaceModel)
     {
         return(((IfcFaceBasedSurfaceModel)repItem).GetGeometryHashCode());
     }
     else if (repItem is IfcShellBasedSurfaceModel)
     {
         return(((IfcShellBasedSurfaceModel)repItem).GetGeometryHashCode());
     }
     else if (repItem is IfcPlane)
     {
         return(((IfcPlane)repItem).GetGeometryHashCode());
     }
     else if (repItem is IfcBoundingBox)
     {
         return(((IfcBoundingBox)repItem).GetGeometryHashCode());
     }
     else
     {
         throw new XbimGeometryException("Unsupported solid geometry type " + repItem.GetType().Name);
     }
 }
コード例 #7
0
ファイル: Conversion.cs プロジェクト: simonedd/TestIFC
        private static Boolean tryGetColorFromIfcRepresentationItem(IfcRepresentationItem reprItem, out Color color)
        {
            color = Color.Black;
            try
            {
                if (reprItem.mStyledByItem != null)
                {
                    IfcStyledItem ifcStyledItem = reprItem.mStyledByItem;

                    IfcPresentationStyleAssignment sas = (IfcPresentationStyleAssignment)ifcStyledItem.Styles[0];

                    IfcSurfaceStyle ss = (IfcSurfaceStyle)sas.Styles[0];

                    IfcSurfaceStyleRendering ssr = (IfcSurfaceStyleRendering)ss.Styles[0];

                    int alpha = Convert.ToInt32((1 - ssr.Transparency) * 255);

                    color = Color.FromArgb(alpha, ssr.SurfaceColour.Colour);

                    return(true);
                }
            }
            catch (Exception e)
            {
                //debug += e.Message + "\n";
            }
            return(false);
        }
コード例 #8
0
        public void ExtrudeAndRevolveTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            // -- extruded profile shape
            IfcPolyline outerCurve = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.5, -0.5 },
                new double[] { -0.5, 0.5 },
                new double[] { 0.5, 0.5 },
                new double[] { 0.5, -0.5 },
                new double[] { -0.5, -0.5 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcRepresentationItem extrudedRepresentation = profileDef.Extrude(1).Rotate(new double[] { 45, 0, 45 }).Translate(new double[] { -2, 0, 0 });

            // -- revolved profile shape
            IfcRepresentationItem revolvedRepresentation = profileDef.Revolve(-45,
                                                                              new IfcAxis1Placement(new IfcCartesianPoint(1, 0, 0),
                                                                                                    new IfcDirection(0, 1, 0)),
                                                                              null);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("extruded square"),
                                           new IfcLabel("SweptSolid"),
                                           new IfcRepresentationItem[] { extrudedRepresentation, revolvedRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });;
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./swept_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }
コード例 #9
0
        public void ParseConstructionStringTest()
        {
            string constructionString            = @"SHAPE({POLYLINE2D([[0,0],[0,1],[1,1],[1,0]]);
                                                 POLYLINE2D([[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]])})
                                          .EXTRUDE(1)
                                          .UNION(SHAPE({POLYLINE2D([[0.5,0.5],[0.5,1.5],[1.5,1.5],[1.5,0.5]])})
                                          .EXTRUDE(1))";
            IfcRepresentationItem representation =
                RepresentationParser.ParseConstructionString(constructionString);

            Assert.IsAssignableFrom <IfcBooleanResult>(representation);
        }
コード例 #10
0
 public static IfcRepresentationItem ApplyQuaternion(this IfcRepresentationItem representation,
                                                     Quaternion q)
 {
     if (representation is IfcBooleanResult)
     {
         ((IfcBooleanResult)representation).ApplyQuaternion(q);
     }
     if (representation is IfcSweptAreaSolid)
     {
         ((IfcSweptAreaSolid)representation).ApplyQuaternion(q);
     }
     return(representation);
 }
コード例 #11
0
        public static IfcPresentationStyleAssignment GetPresentationStyleAssignment(this IfcRepresentationItem repItem)
        {
            IfcStyledItem item = repItem.StyledByItem.FirstOrDefault();

            if (item != null && item.Styles != null)
            {
                return(item.Styles.FirstOrDefault());
            }
            else
            {
                return(null);
            }
        }
コード例 #12
0
 public static IfcRepresentationItem Rotate(this IfcRepresentationItem representation,
                                            double[] rotation)
 {
     if (representation is IfcBooleanResult)
     {
         ((IfcBooleanResult)representation).Rotate(rotation);
     }
     if (representation is IfcSweptAreaSolid)
     {
         ((IfcSweptAreaSolid)representation).Rotate(rotation);
     }
     return(representation);
 }
 /// <summary>
 /// Returns true if the object is a surface model, nb FacetedBreps can be both surface and solid
 /// </summary>
 /// <param name="repItem"></param>
 /// <returns></returns>
 public static bool IsSurfaceModel(this IfcRepresentationItem repItem)
 {
     if (repItem is IfcShellBasedSurfaceModel ||
         repItem is IfcFaceBasedSurfaceModel ||
         repItem is IfcFacetedBrep
         )
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #14
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcManifoldSolidBrep a, IfcRepresentationItem b)
        {
            IfcFacetedBrep fb = b as IfcFacetedBrep;

            if (fb == null)
            {
                return(false);            //different types are not the same
            }
            if (a.Equals(fb))
            {
                return(true);
            }
            return(a.Outer.GeometricEquals(fb.Outer));
        }
コード例 #15
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcExtrudedAreaSolid a, IfcRepresentationItem b)
        {
            IfcExtrudedAreaSolid eas = b as IfcExtrudedAreaSolid;

            if (eas == null)
            {
                return(false);            //different types are not the same
            }
            double precision = a.ModelOf.ModelFactors.Precision;

            return(Math.Abs(a.Depth - eas.Depth) <= precision &&
                   a.ExtrudedDirection.GeometricEquals(eas.ExtrudedDirection) &&
                   a.Position.GeometricEquals(eas.Position) &&
                   a.SweptArea.GeometricEquals(eas.SweptArea));
        }
 /// <summary>
 /// Returns true if the object represents a solid model nb FacetedBreps can be both surface and solid
 /// </summary>
 /// <param name="repItem"></param>
 /// <returns></returns>
 public static bool IsSolidModel(this IfcRepresentationItem repItem)
 {
     if (repItem is IfcSolidModel ||
         repItem is IfcBooleanResult ||
         repItem is IfcBoundingBox ||
         repItem is IfcSectionedSpine
         )
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcRevolvedAreaSolid a, IfcRepresentationItem b)
        {
            IfcRevolvedAreaSolid eas = b as IfcRevolvedAreaSolid;

            if (eas == null)
            {
                return(false);                 //different types are not the same
            }
            double precision = a.Model.ModelFactors.Precision;

            return(Math.Abs(a.Angle - eas.Angle) <= precision &&
                   a.Axis.GeometricEquals(eas.Axis) &&
                   a.Position.GeometricEquals(eas.Position) &&
                   a.SweptArea.GeometricEquals(eas.SweptArea));
        }
コード例 #18
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcBoundingBox a, IfcRepresentationItem b)
        {
            var bb = b as IfcBoundingBox;

            if (bb == null)
            {
                return(false);            //different types are not the same
            }
            double precision = a.ModelOf.ModelFactors.Precision;

            return(Math.Abs(a.XDim - bb.XDim) <= precision &&
                   Math.Abs(a.YDim - bb.YDim) <= precision &&
                   Math.Abs(a.ZDim - bb.ZDim) <= precision &&
                   a.Corner.GeometricEquals(bb.Corner));
        }
コード例 #19
0
        /// <summary>
        ///   If the space has a footprint represenation this will generate a set of walls conforming to that footprint, otherwise returns null
        /// </summary>
        /// <param name = "space"></param>
        /// <param name = "model"></param>
        /// <returns></returns>
        public static List <IfcWall> GenerateWalls(this IfcSpace space, IModel model)
        {
            IfcShapeRepresentation fp = GetFootPrintRepresentation(space);

            if (fp != null)
            {
                IfcRepresentationItem rep = fp.Items.FirstOrDefault();
                if (rep != null && rep is IfcGeometricCurveSet) //we have a set of curves and inner boundaries
                {
                }
                else if (rep != null)
                {
                }
            }
            return(null);
        }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this  IfcBooleanResult a, IfcRepresentationItem b)
        {
            IfcBooleanResult p = b as IfcBooleanResult;

            if (p == null)
            {
                return(false);           //different types are not the same
            }
            if (a.Equals(p))
            {
                return(true);
            }
            return(a.FirstOperand.EntityLabel == p.FirstOperand.EntityLabel &&
                   a.SecondOperand.EntityLabel == p.SecondOperand.EntityLabel &&
                   a.Operator == p.Operator);
        }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcSurfaceCurveSweptAreaSolid a, IfcRepresentationItem b)
        {
            IfcSurfaceCurveSweptAreaSolid scsa = b as IfcSurfaceCurveSweptAreaSolid;

            if (scsa == null)
            {
                return(false);              //different types are not the same
            }
            double precision = a.Model.ModelFactors.Precision;

            return(a.Directrix.GeometricEquals(scsa.Directrix) &&
                   a.StartParam == scsa.EndParam &&
                   a.EndParam == scsa.EndParam &&
                   a.ReferenceSurface.GeometricEquals(scsa.ReferenceSurface) &&
                   a.Position.GeometricEquals(scsa.Position) &&
                   a.SweptArea.GeometricEquals(scsa.SweptArea));
        }
コード例 #22
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
                _item = (IfcRepresentationItem)(value.EntityVal);
                return;

            case 1:
                _styles.InternalAdd((IfcPresentationStyleAssignment)value.EntityVal);
                return;

            case 2:
                _name = value.StringVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
コード例 #23
0
        /// <summary>
        /// Returns the first IfcSurfaceStyle associated with the representation item
        /// </summary>
        /// <param name="repItem"></param>
        /// <returns></returns>
        public static IfcSurfaceStyle SurfaceStyle(this IfcRepresentationItem repItem)
        {
            var styledItem = repItem.Model.Instances.Where <IfcStyledItem>(s => s.Item == repItem).FirstOrDefault();

            if (styledItem != null)
            {
                foreach (var presStyle in styledItem.Styles)
                {
                    if (presStyle != null)
                    {
                        var aSurfaceStyle = presStyle.Styles.OfType <IfcSurfaceStyle>().FirstOrDefault();
                        if (aSurfaceStyle != null)
                        {
                            return(aSurfaceStyle);
                        }
                    }
                }
            }
            return(null);
        }
コード例 #24
0
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
                _item = (IfcRepresentationItem)value.EntityVal;
                break;

            case 1:
                _styles.Add((IfcPresentationStyleAssignment)value.EntityVal);
                break;

            case 2:
                _name = value.StringVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
コード例 #25
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcCsgSolid a, IfcRepresentationItem b)
        {
            IfcCsgSolid csg = b as IfcCsgSolid;

            if (csg == null)
            {
                return(false);             //different types are not the same
            }
            if (a.TreeRootExpression is IfcBooleanResult && csg.TreeRootExpression is IfcBooleanResult)
            {
                return(((IfcBooleanResult)(a.TreeRootExpression)).GeometricEquals((IfcBooleanResult)(csg.TreeRootExpression)));
            }
            else if (a.TreeRootExpression is IfcCsgPrimitive3D)
            {
                throw new XbimGeometryException("Equality of IfcCsgPrimitive3D is not implmeneted yet");
            }
            else
            {
                throw new XbimGeometryException("Equality of unknown Csg Solid is not implmeneted yet");
            }
        }
コード例 #26
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this  IfcFaceBasedSurfaceModel a, IfcRepresentationItem b)
        {
            IfcFaceBasedSurfaceModel p = b as IfcFaceBasedSurfaceModel;

            if (p == null)
            {
                return(false);           //different type
            }
            List <IfcConnectedFaceSet> fsa = a.FbsmFaces.ToList();
            List <IfcConnectedFaceSet> fsb = p.FbsmFaces.ToList();

            if (fsa.Count != fsb.Count)
            {
                return(false);
            }
            for (int i = 0; i < fsa.Count; i++)
            {
                if (!fsa[i].GeometricEquals(fsb[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #27
0
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this  IfcShellBasedSurfaceModel a, IfcRepresentationItem b)
        {
            var p = b as IfcShellBasedSurfaceModel;

            if (p == null)
            {
                return(false);           //different type
            }
            var fsa = a.SbsmBoundary.ToList();
            var fsb = p.SbsmBoundary.ToList();

            if (fsa.Count != fsb.Count)
            {
                return(false);
            }
            for (var i = 0; i < fsa.Count; i++)
            {
                if (!fsa[i].GeometricEquals(fsb[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #28
0
 public IfcAnnotationTextOccurrence(IfcRepresentationItem __Item, IfcPresentationStyleAssignment[] __Styles, IfcLabel?__Name)
     : base(__Item, __Styles, __Name)
 {
 }
コード例 #29
0
ファイル: IfcStyledItem.cs プロジェクト: vdubya/IfcDoc
 public IfcStyledItem(IfcRepresentationItem __Item, IfcStyleAssignmentSelect[] __Styles, IfcLabel?__Name)
 {
     this.Item   = __Item;
     this.Styles = new HashSet <IfcStyleAssignmentSelect>(__Styles);
     this.Name   = __Name;
 }
コード例 #30
0
        public void BooleanOperatorTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            IfcCsgPrimitive3D union_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D union_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem unionRepresentation = union_first.Union(union_second);

            IfcCsgPrimitive3D diff_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(2, 0, 0), null, null),
                                                        new IfcPositiveLengthMeasure(1),
                                                        new IfcPositiveLengthMeasure(1),
                                                        new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D diff_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(2.5, 0.5, 0.5), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem diffRepresentation = diff_first.Difference(diff_second);

            IfcCsgPrimitive3D inter_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(4, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D inter_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(4.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem interRepresentation = inter_first.Intersection(inter_second);
            IfcPolyline           outerCurve          = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { 6, 0 },
                new double[] { 6, 1 },
                new double[] { 7, 1 },
                new double[] { 7, 0 },
                new double[] { 6, 0 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcSweptAreaSolid cut_reference = profileDef.Extrude(1);
            IfcPlane          plane         = IfcGeom.CreatePlane(new double[] { 6.5, 0.5, 0 },
                                                                  new double[] { 1, 1, 0 });
            IfcRepresentationItem cutRepresentation = cut_reference.ClipByPlane(plane);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("union shape"),
                                           new IfcLabel("BooleanResult"),
                                           new IfcRepresentationItem[] { unionRepresentation, diffRepresentation, interRepresentation, cutRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./constructive_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }