public void ExtrudedCircularProfilesTest()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\15 - Swept pipes.ifc", null, null, true, true);
                    foreach (
                        var cp in
                        m.Instances.OfType <IfcExtrudedAreaSolid>().Where(e => e.SweptArea is IfcCircleProfileDef))
                    {
                        Assert.IsTrue(cp != null, "No Extruded Solid found");
                        Assert.IsTrue(cp.SweptArea is IfcCircleProfileDef, "Incorrect profiledef found");

                        var solid = xbimGeometryCreator.CreateSolid(cp);
                        Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                        IfcCsgTests.GeneralTest(solid);
                    }

                    //Assert.IsTrue(solid.Faces.Count() == 10, "T Shaped profiles should have 10 faces");
                }
            }
        }
        public void ConvertIfcCylinderToBRepTest()
        {
            using (var m = XbimModel.CreateTemporaryModel())
            {
                using (var txn = m.BeginTransaction())
                {
                    var cylinder = IfcModelBuilder.MakeRightCircularCylinder(m, 10, 20);
                    var solid    = _xbimGeometryCreator.CreateSolid(cylinder);
                    var brep     = _xbimGeometryCreator.CreateFacetedBrep(m, solid);
                    var solid2   = _xbimGeometryCreator.CreateSolidSet(brep);

                    txn.Commit();
                    try
                    {
                        //Uncomment below to see the results in Ifc
                        //m.SaveAs("brep.ifc", XbimStorageType.IFC);
                    }
                    catch (Exception)
                    {
                        Assert.IsTrue(false, "Failed to save the results to Ifc");
                    }
                    Assert.IsTrue(solid2.Count == 1, "Expected one solid");
                    IfcCsgTests.GeneralTest(solid2.First);

                    Assert.IsTrue(brep.Outer.CfsFaces.Count == solid2.First.Faces.Count, "Number of faces in round tripped solid is not the same");
                }
            }
        }
        public void IfcExtrudedArea_With_IfcArbritraryClosedProfileDef_And_IfcCompositeCurve()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\2- IfcExtrudedAreaSolid-IfcArbitraryClosedProfileDef-IfcCompositeCurve.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault();
                    Assert.IsTrue(eas != null);
                    Assert.IsTrue(eas.SweptArea is IfcArbitraryClosedProfileDef, "Incorrect profile definition");
                    Assert.IsTrue(((IfcArbitraryClosedProfileDef)eas.SweptArea).OuterCurve is IfcCompositeCurve, "Incorrect SweptArea type");

                    var solid = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0, "Warnings or errors raised in geometry conversion"); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);

                    //now make the extrusion invalid
                    eas.Depth = 0;
                    solid     = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 1, "An expected error was not raised raised in geometry conversion"); //we should have an event here
                    Assert.IsTrue(Math.Abs(solid.Volume) < m.ModelFactors.Precision);
                    Assert.IsTrue(solid.BoundingBox.IsEmpty);
                    Assert.IsFalse(solid.IsValid);
                }
            }
        }
        public void RectangleProfileDefTest()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\1- IfcExtrudedAreaSolid-IfcProfileDef-Parameterised.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea.GetType() == typeof(IfcRectangleProfileDef));
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IfcRectangleProfileDef, "Incorrect profiledef found");

                    var solid = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 6, "Rectangular profiles should have six faces");

                    ////now make the extrusion invalid
                    //eas.Depth = 0;
                    //solid = XbimGeometryCreator.CreateSolid(eas);
                    //Assert.IsTrue(eventTrace.Events.Count == 1); //we should have an event here
                    //Assert.IsTrue(Math.Abs(solid.Volume) < m.ModelFactors.Precision);
                    //Assert.IsTrue(solid.BoundingBox.IsEmpty);
                    //Assert.IsFalse(solid.IsValid);
                }
            }
        }
        public void ConvertIfcCircleHollowProfileToBRepTest()
        {
            using (var m = IfcModelBuilder.CreateandInitModel())
            {
                using (var txn = m.BeginTransaction())
                {
                    //add a shape
                    //Create a Definition shape to hold the geometry
                    var shape = m.Instances.New <IfcShapeRepresentation>();
                    shape.ContextOfItems           = m.IfcProject.ModelContext();
                    shape.RepresentationType       = "Brep";
                    shape.RepresentationIdentifier = "Body";

                    //Create a Product Definition and add the model geometry to the wall
                    var rep = m.Instances.New <IfcProductDefinitionShape>();
                    rep.Representations.Add(shape);
                    var building = m.Instances.OfType <IfcBuilding>().FirstOrDefault();
                    Assert.IsNotNull(building, "Failed to find Building");
                    building.Representation = rep;



                    var block = IfcModelBuilder.MakeExtrudedAreaSolid(m, IfcModelBuilder.MakeCircleHollowProfileDef(m, 1000, 500), 3000);
                    var solid = _xbimGeometryCreator.CreateSolid(block);

                    var brep = _xbimGeometryCreator.CreateFacetedBrep(m, solid);

                    shape.Items.Add(brep);

                    var solid2 = _xbimGeometryCreator.CreateSolidSet(brep); //round trip it

                    txn.Commit();
                    try
                    {
                        //Uncomment below to see the results in Ifc
                        //m.SaveAs("brep.ifc", XbimStorageType.IFC);
                    }
                    catch (Exception)
                    {
                        Assert.IsTrue(false, "Failed to save the results to Ifc");
                    }
                    Assert.IsTrue(solid2.Count == 1, "Expected one solid");
                    IfcCsgTests.GeneralTest(solid2.First);

                    Assert.IsTrue(brep.Outer.CfsFaces.Count == solid2.First.Faces.Count, "Number of faces in round tripped solid is not the same");
                }
            }
        }
        public void ConvertIfcBlockToBRepTest()
        {
            using (var m = XbimModel.CreateTemporaryModel())
            {
                using (var txn = m.BeginTransaction())
                {
                    var block = IfcModelBuilder.MakeBlock(m, 10, 15, 20);

                    var solid = _xbimGeometryCreator.CreateSolid(block);
                    var brep  = _xbimGeometryCreator.CreateFacetedBrep(m, solid);
                    var xrep  = _xbimGeometryCreator.CreateSolidSet(brep);
                    Assert.IsTrue(xrep.Count == 1, "Expected one solid");
                    Assert.IsTrue(solid.Volume - xrep.First.Volume <= m.ModelFactors.Precision, "Volume of round tripped block is not the same");
                    IfcCsgTests.GeneralTest(xrep.First);
                }
            }
        }
        public void IfcRevolvedArea_With_IfcCircleHollowProfileDef()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\5- IfcRevolvedAreaSolid-IfcCircularHollowProfileDef.ifc", null, null, true, true);
                    var ss = m.Instances.OfType <IfcRevolvedAreaSolid>().FirstOrDefault(e => e.SweptArea is IfcCircleHollowProfileDef);
                    Assert.IsTrue(ss != null, "No Revolved Area found");
                    Assert.IsTrue(ss.SweptArea is IfcCircleHollowProfileDef, "Incorrect profiledef found");


                    var solid = _xbimGeometryCreator.CreateSolid(ss);
                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 4, "Circle Hollow profiles should have 4 faces");
                }
            }
        }
예제 #8
0
        public void IfcSurfaceCurveSweptAreaSolid()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\11- IfcSurfaceCurveSweptAreaSolid.ifc", null, null, true, true);
                    var ss = m.Instances.OfType <IfcSurfaceCurveSweptAreaSolid>().FirstOrDefault();
                    Assert.IsTrue(ss != null, "No Swept Disk found");


                    var solid = _xbimGeometryCreator.CreateSolid(ss);

                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 6, "This IfcSurfaceCurveSweptAreaSolid with hollow circular profile def should have 6 faces");
                }
            }
        }
        public void IfcFacetedBRepWithMultipleSolids()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\12 - Multiple FacetedBrep.ifc", null, null, true, true);
                    var fbr = m.Instances[25] as IfcFacetedBrep;
                    Assert.IsTrue(fbr != null, "No IfcFacetedBRep found");
                    int faceCount = fbr.Outer.CfsFaces.Count;

                    var solids = _xbimGeometryCreator.CreateSolidSet(fbr);

                    Assert.IsTrue(solids.Count == 11, "Expected 11 solids");
                    foreach (var solid in solids)
                    {
                        IfcCsgTests.GeneralTest(solid, true);
                    }
                }
            }
        }
예제 #10
0
        public void IfcSweptDisk_With_IfcComposite()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\6- IfcSweptDiskSolid_With_BooleanResult.ifc", null, null, true, true);
                    var ss = m.Instances.OfType <IfcSweptDiskSolid>().FirstOrDefault(e => e.Directrix is IfcCompositeCurve);
                    Assert.IsTrue(ss != null, "No Swept Disk found");
                    Assert.IsTrue(ss.Directrix is IfcCompositeCurve, "Incorrect sweep found");


                    var solid = _xbimGeometryCreator.CreateSolid(ss);

                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 4, "Swept disk solids along a this composite curve should have 4 faces");
                }
            }
        }
        public void CompositeProfileDefTest()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\IfcCompositeProfileDefTest.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea.GetType() == typeof(IfcCompositeProfileDef));
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IfcCompositeProfileDef, "Incorrect profiledef found");

                    var solid = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 40, "IfcCompositeProfileDef profile should have six faces");
                }
            }
        }
        public void IfcFacetedBRepTest()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\12 - Multiple FacetedBrep.ifc", null, null, true, true);
                    var fbr = m.Instances[780] as IfcFacetedBrep;
                    Assert.IsTrue(fbr != null, "No IfcFacetedBRep found");
                    int faceCount = fbr.Outer.CfsFaces.Count;

                    var solids = _xbimGeometryCreator.CreateSolidSet(fbr);
                    Assert.IsTrue(eventTrace.Events.Count == 0, "Warning or Error events were raised"); //we should have no warnings

                    Assert.IsTrue(solids.Count == 1, "Expected 11 solids");

                    IfcCsgTests.GeneralTest(solids.First);

                    Assert.IsTrue(solids.First.Faces.Count() == faceCount, "Failed to convert all faces");
                }
            }
        }
        public void IfcExtrudedArea_With_IfcArbritraryProfileDefWithVoids()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\18 - IfcArbritaryClosedProfileDefWithVoids.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IfcArbitraryProfileDefWithVoids);
                    Assert.IsTrue(eas != null);
                    Assert.IsTrue(eas.SweptArea is IfcArbitraryProfileDefWithVoids, "Incorrect profile definition");

                    var solid = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0, "Warnings or errors raised in geometry conversion"); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);

                    //Assert.IsTrue(solid.Faces.Count() == 6, "IfcPolyline  profiles should have (number of polyline egdes + 2) faces");
                }
            }
        }
        public void TestDerivedProfileDefWithLShapedParent()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\1- IfcExtrudedAreaSolid-IfcProfileDef-Parameterised.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IfcDerivedProfileDef && ((IfcDerivedProfileDef)e.SweptArea).ParentProfile is IfcLShapeProfileDef);
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IfcDerivedProfileDef, "Incorrect profiledef found");
                    Assert.IsTrue(((IfcDerivedProfileDef)eas.SweptArea).ParentProfile is IfcLShapeProfileDef, "Incorrect parent profiledef found");

                    var solid = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 8, "L Shaped profiles should have 8 faces");
                }
            }
        }
        public void IfcExtrudedArea_With_IfcArbritraryClosedProfileDef_And_IfcPolyline()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\1- IfcExtrudedAreaSolid-IfcProfileDef-Parameterised.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IfcArbitraryClosedProfileDef && ((IfcArbitraryClosedProfileDef)e.SweptArea).OuterCurve is IfcPolyline);
                    Assert.IsTrue(eas != null);
                    Assert.IsTrue(eas.SweptArea is IfcArbitraryClosedProfileDef, "Incorrect profile definition");
                    Assert.IsTrue(((IfcArbitraryClosedProfileDef)eas.SweptArea).OuterCurve is IfcPolyline, "Incorrect SweptArea outer curve type");

                    var solid = xbimGeometryCreator.CreateSolid(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0, "Warnings or errors raised in geometry conversion"); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    var plineCount = ((IfcPolyline)((IfcArbitraryClosedProfileDef)eas.SweptArea).OuterCurve).Points.Count - 1;
                    Assert.IsTrue(solid.Faces.Count() == plineCount + 2, "IfcPolyline  profiles should have (number of polyline egdes + 2) faces");
                }
            }
        }
        public void BIM_Logo_LetterB_Test()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\BIM Logo-LetterB.ifc", null, null, true, true);
                    var eas = m.Instances[88] as IfcCsgSolid;
                    Assert.IsTrue(eas != null, "No CSG Solid found");

                    var solid = (IXbimSolid)xbimGeometryCreator.Create(eas);
                    Assert.IsTrue(eventTrace.Events.Count == 0); //no events should have been raised from this call

                    IfcCsgTests.GeneralTest(solid);
                    Assert.IsTrue(solid.Faces.Count() == 15, "Letter B should have 15 faces");
                    var xbimTessellator = new XbimTessellator(m, XbimGeometryType.PolyhedronBinary);
                    // Assert.IsTrue(xbimTessellator.CanMesh(solid));//if we can mesh the shape directly just do it
                    // var shapeGeom = xbimTessellator.Mesh(solid);
                    var shapeGeom = xbimGeometryCreator.CreateShapeGeometry(solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance, m.ModelFactors.DeflectionAngle, XbimGeometryType.PolyhedronBinary);
                }
            }
        }
예제 #17
0
        public void TestAllModels()
        {
            const string modelDirectory = ""; // enter your model directoy here "@"D:\Users\steve\xBIM\Test Models\Use Cases\Live";#

            if (string.IsNullOrWhiteSpace(modelDirectory))
            {
                Trace.WriteLine("TestAllModels tests skipped. Enter a directory where the test models can be found");
                return;
            }
            var di = new DirectoryInfo(modelDirectory);

            FileInfo[] toProcess = di.GetFiles("*.IFC", SearchOption.TopDirectoryOnly);
            foreach (var file in toProcess)
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom(file.FullName, null, null, true, true);

                    using (var eventTrace = LoggerFactory.CreateEventTrace())
                    {
                        foreach (var rep in m.Instances.OfType <IfcGeometricRepresentationItem>())
                        {
                            if (rep is IfcAxis2Placement ||
                                rep is IfcCartesianPoint ||
                                rep is IfcDirection ||
                                rep is IfcCartesianTransformationOperator ||
                                rep is IfcPlanarExtent ||
                                rep is IfcTextLiteralWithExtent ||
                                rep is IfcFillAreaStyleHatching
                                )
                            {
                                continue;
                            }
                            var shape = _xbimGeometryCreator.Create(rep);
                            // var w = new XbimOccWriter();
                            //IXbimSolidSet solids = shape as IXbimSolidSet;

                            //foreach (var solid in solids)
                            //{
                            //     w.Write(solid, "d:\\xbim\\f" + i++);
                            //}

                            if (!shape.IsValid)
                            {
                                Assert.IsTrue(shape.IsValid, "Invalid shape found");
                            }
                            var solid = shape as IXbimSolid;
                            if (solid != null)
                            {
                                //  w.Write(solid, "d:\\xbim\\x" + rep.EntityLabel.ToString());

                                IfcCsgTests.GeneralTest((IXbimSolid)shape, true, rep is IfcHalfSpaceSolid, rep.EntityLabel);
                            }
                        }
                        if (eventTrace.Events.Count > 0)
                        {
                            //var assertNow = false;
                            Trace.WriteLine("Model: " + file.Name);
                            foreach (var err in eventTrace.Events)
                            {
                                Trace.WriteLine(err.Message);
                                //if (err.EventLevel == EventLevel.ERROR)
                                //    assertNow = true;
                            }

                            // Assert.IsTrue(assertNow == false, "Error events were raised");
                        }
                    }
                }
            }
        }
예제 #18
0
        public void TestCuttingOpenings()
        {
            //   var w = new XbimOccWriter();
            const string modelDirectory = "";//define where your files to test are @"D:\Users\steve\xBIM\Test Models\Use Cases\Live";

            if (string.IsNullOrWhiteSpace(modelDirectory))
            {
                Trace.WriteLine("TestCuttingOpenings tests skipped. Enter a directory where the test models can be found");
                return;
            }
            var di = new DirectoryInfo(modelDirectory);

            FileInfo[] toProcess = di.GetFiles("*.IFC", SearchOption.TopDirectoryOnly);
            foreach (var file in toProcess)
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom(file.FullName, null, null, true, true);

                    using (var eventTrace = LoggerFactory.CreateEventTrace())
                    {
                        var theElements = _xbimGeometryCreator.CreateSolidSet();
                        var openings    = m.Instances.OfType <IfcRelVoidsElement>()
                                          .Where(
                            r =>
                            r.RelatingBuildingElement.Representation != null &&
                            r.RelatedOpeningElement.Representation != null)
                                          .Select(
                            f =>
                            new
                        {
                            element = f.RelatingBuildingElement,
                            feature = f.RelatedOpeningElement
                        });

                        var toCut = openings.GroupBy(x => x.element, y => y.feature).ToList();

                        Parallel.ForEach(toCut, new ParallelOptions(), rel =>
                                         //         foreach (var rel in toCut)
                        {
                            var elem          = rel.Key;
                            var elemTransform = elem.Transform();
                            var elemSolids    = _xbimGeometryCreator.CreateSolidSet();
                            foreach (var rep in elem.Representation.Representations)
                            {
                                if (rep.ContextOfItems.ContextType != null &&
                                    "Model" == rep.ContextOfItems.ContextType.Value.ToString() && (rep.RepresentationIdentifier.HasValue && rep.RepresentationIdentifier == "Body"))
                                {
                                    foreach (var item in rep.Items.OfType <IfcGeometricRepresentationItem>())
                                    {
                                        IXbimGeometryObject shape = _xbimGeometryCreator.Create(item);
                                        if (!shape.IsValid)
                                        {
                                            Assert.IsTrue(shape.IsValid, "Invalid shape found in #" + item.EntityLabel);
                                        }
                                        var solid = shape as IXbimSolid;
                                        if (solid != null)
                                        {
                                            IfcCsgTests.GeneralTest(solid, true, item is IfcHalfSpaceSolid,
                                                                    rep.EntityLabel);

                                            solid = (IXbimSolid)solid.Transform(elemTransform);
                                            elemSolids.Add(solid);
                                        }
                                        else if (shape is IXbimSolidSet)
                                        {
                                            foreach (var subSolid in shape as IXbimSolidSet)
                                            {
                                                IfcCsgTests.GeneralTest(subSolid, true, item is IfcHalfSpaceSolid,
                                                                        rep.EntityLabel);
                                                elemSolids.Add(subSolid.Transform(elemTransform));
                                            }
                                        }
                                        else if (shape is IXbimGeometryObjectSet)
                                        {
                                            foreach (var subShape in shape as IXbimGeometryObjectSet)
                                            {
                                                if (subShape is IXbimSolid)
                                                {
                                                    IfcCsgTests.GeneralTest((IXbimSolid)subShape, true,
                                                                            item is IfcHalfSpaceSolid,
                                                                            rep.EntityLabel);
                                                }
                                                elemSolids.Add(subShape.Transform(elemTransform));
                                            }
                                        }
                                        else
                                        {
                                            Trace.WriteLine("No Solid found #" + item.EntityLabel + " " +
                                                            shape.GetType().Name);
                                        }
                                    }
                                }
                            }

                            var openingSolids = _xbimGeometryCreator.CreateSolidSet();
                            foreach (var opening in rel)
                            {
                                var openingTransform = opening.Transform();
                                foreach (var openingrep in opening.Representation.Representations)
                                {
                                    if (openingrep.ContextOfItems.ContextType != null &&
                                        "Model" == openingrep.ContextOfItems.ContextType.Value.ToString() && (openingrep.RepresentationIdentifier.HasValue && openingrep.RepresentationIdentifier == "Body"))
                                    {
                                        foreach (
                                            var openingitem in openingrep.Items.OfType <IfcGeometricRepresentationItem>()
                                            )
                                        {
                                            IXbimGeometryObject openingshape = _xbimGeometryCreator.Create(openingitem);

                                            if (!openingshape.IsValid)
                                            {
                                                Trace.WriteLine("Invalid shape found in #" + openingitem.EntityLabel);
                                                continue;
                                            }
                                            var openingsolid = openingshape as IXbimSolid;
                                            if (openingsolid != null)
                                            {
                                                IfcCsgTests.GeneralTest((IXbimSolid)openingshape, true,
                                                                        openingitem is IfcHalfSpaceSolid,
                                                                        openingrep.EntityLabel);
                                                openingsolid = (IXbimSolid)openingsolid.Transform(openingTransform);
                                                openingSolids.Add(openingsolid);
                                            }
                                            else if (openingshape is IXbimSolidSet)
                                            {
                                                foreach (var subOpeningSolid in openingshape as IXbimSolidSet)
                                                {
                                                    IfcCsgTests.GeneralTest(subOpeningSolid, true,
                                                                            openingitem is IfcHalfSpaceSolid,
                                                                            openingrep.EntityLabel);
                                                    openingSolids.Add(subOpeningSolid.Transform(openingTransform));
                                                }
                                            }
                                            else if (openingshape is IXbimGeometryObjectSet)
                                            {
                                                foreach (var subShape in openingshape as IXbimGeometryObjectSet)
                                                {
                                                    if (subShape is IXbimSolid)
                                                    {
                                                        IfcCsgTests.GeneralTest((IXbimSolid)subShape, true,
                                                                                openingitem is IfcHalfSpaceSolid,
                                                                                openingrep.EntityLabel);
                                                    }
                                                    openingSolids.Add(subShape.Transform(openingTransform));
                                                }
                                            }
                                            else
                                            {
                                                Trace.WriteLine("No Solid found #" + openingitem.EntityLabel + " " +
                                                                openingshape.GetType().Name);
                                            }
                                        }
                                    }
                                }
                            }

                            // ReSharper disable once AccessToDisposedClosure

                            var solidResult = elemSolids.Cut(openingSolids, m.ModelFactors.PrecisionBoolean);
                            foreach (var result in solidResult)
                            {
                                IfcCsgTests.GeneralTest(result, true, false,
                                                        elem.EntityLabel);
                                theElements.Add(result);
                            }
                        }
                                         );
                        // w.Write(theElements, "d:\\xbim\\r");
                        if (eventTrace.Events.Count > 0)
                        {
                            //var assertNow = false;
                            Trace.WriteLine("Model: " + file.Name);
                            foreach (var err in eventTrace.Events)
                            {
                                Trace.WriteLine(err.Message);
                                //if (err.EventLevel == EventLevel.ERROR)
                                //    assertNow = true;
                            }

                            // Assert.IsTrue(assertNow == false, "Error events were raised");
                        }
                    }
                }
            }
        }