Ejemplo n.º 1
0
 public void MoveAndCopyTest()
 {
     //this test checks that a object is correctly copied and moved
     //create a box
     using (
         var m = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel)
         )
     {
         using (var txn = m.BeginTransaction())
         {
             var block = IfcModelBuilder.MakeBlock(m, 10, 10, 10);
             var solid = _geomEngine.CreateSolid(block);
             var ax3D  = IfcModelBuilder.MakeAxis2Placement3D(m);
             ax3D.Location.Y = 100;
             var solidA = _geomEngine.Moved(solid, ax3D) as IXbimSolid;
             Assert.IsNotNull(solidA, "Should be the same type as the master");
             Assert.IsTrue(Math.Abs(solidA.Volume - solid.Volume) < 1e-9, "Volume has changed");
             var displacement = solidA.BoundingBox.Centroid() - solid.BoundingBox.Centroid();
             Assert.IsTrue(displacement == new XbimVector3D(0, 100, 0));
             var bbA    = solidA.BoundingBox;
             var solidB = _geomEngine.Moved(solid, ax3D);
             Assert.IsTrue(bbA.Centroid() - solidB.BoundingBox.Centroid() == new XbimVector3D(0, 0, 0));
         }
     }
 }
Ejemplo n.º 2
0
        public void IfcRectangularPyramidTest()
        {
            using (var m = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))
            {
                using (var txn = m.BeginTransaction())
                {
                    var pyramid = m.Instances.New <IfcRectangularPyramid>();
                    var p       = m.Instances.New <IfcAxis2Placement3D>();
                    p.Axis           = m.Instances.New <IfcDirection>(d => d.SetXYZ(1, 0, 0));
                    p.Location       = m.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(10, 10, 0));
                    pyramid.Position = p;
                    pyramid.Height   = 20;
                    pyramid.XLength  = 10;
                    pyramid.YLength  = 15;

                    var solid = _xbimGeometryCreator.CreateSolid(pyramid);

                    Assert.IsTrue(solid.Faces.Count == 5, "5 faces are required of a pyramid");
                    Assert.IsTrue(solid.Vertices.Count == 5, "5 vertices are required of a pyramid");
                    var meshRec = new MeshHelper();
                    _xbimGeometryCreator.Mesh(meshRec, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance * 10);
                    Assert.IsTrue(meshRec.FaceCount == 5, "5 mesh faces are required of a pyramid");
                    Assert.IsTrue(meshRec.PointCount == 16, "16 mesh points are required of a pyramid");
                    txn.Commit();
                }
            }
        }
        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 ExtrudedCircularProfilesTest()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\15 - Swept pipes.ifc"))
                {
                    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 RectangleProfileDefTest()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\1- IfcExtrudedAreaSolid-IfcProfileDef-Parameterised.ifc"))
                {
                    var eas = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IIfcRectangleProfileDef && !(e.SweptArea is IIfcRectangleHollowProfileDef));
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IIfcRectangleProfileDef, "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);
                }
            }
        }
        // // [DeploymentItem(@"TestFiles\Regression\FailingGeom.ifc", "FailingGeom.ifc")]
        public void IfcHalfspace_FailingGeom()
        {
            using (var m = IfcStore.Open("TestFiles\\Regression\\FailingGeom.ifc"))
            {
                var extSolid = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault(hs => hs.EntityLabel == 185025);
                var solid    = geomEngine.CreateSolid(extSolid, null);
                IfcCsgTests.GeneralTest(solid);

                var mlist = m.Instances.OfType <IIfcBooleanClippingResult>();
                foreach (var eas in mlist)
                {
                    Debug.WriteLine("Todo: " + eas.EntityLabel);
                }

                foreach (var eas in mlist)
                {
                    // var eas = m.Instances.OfType<IIfcBooleanClippingResult>().FirstOrDefault(hs => hs.EntityLabel == 185249);
                    Assert.IsTrue(eas != null, "No IfcBooleanClippingResult found");
                    var ret = geomEngine.CreateSolidSet(eas, logger);

                    IfcCsgTests.GeneralTest(solid);

                    Debug.WriteLine(eas.EntityLabel + " ok");
                    if (eas.EntityLabel == 185243)
                    {
                        File.WriteAllText(@"C:\Data\_tmp\185243.v5.brep", solid.ToBRep);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void IfcRevolvedArea_With_IfcCircleHollowProfileDef()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\5- IfcRevolvedAreaSolid-IfcCircularHollowProfileDef.ifc"))
                {
                    var ss = m.Instances.OfType <IIfcRevolvedAreaSolid>().FirstOrDefault(e => e.SweptArea is IIfcCircleHollowProfileDef);
                    Assert.IsTrue(ss != null, "No Revolved Area found");
                    Assert.IsTrue(ss.SweptArea is IIfcCircleHollowProfileDef, "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");
                }
            }
        }
Ejemplo n.º 9
0
        public void IfcSweptDisk_With_IfcPolyline()
        {
            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\6- IfcSweptDiskSolid_With_BooleanResult.ifc"))
                {
                    var ss = m.Instances.OfType <IIfcSweptDiskSolid>().FirstOrDefault(e => e.Directrix is IIfcPolyline);
                    Assert.IsTrue(ss != null, "No Swept Disk found");
                    Assert.IsTrue(ss.Directrix is IIfcPolyline, "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 single polyline with inner radius should have 4 faces");
                }
            }
        }
Ejemplo n.º 10
0
        public void IfcRectangularPyramidTest()
        {
            using (var m = XbimModel.CreateTemporaryModel())
            {
                using (var txn = m.BeginTransaction())
                {
                    var pyramid = m.Instances.New <IfcRectangularPyramid>();
                    var p       = m.Instances.New <IfcAxis2Placement3D>();
                    p.Axis           = m.Instances.New <IfcDirection>(d => d.SetXYZ(1, 0, 0));
                    p.Location       = m.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(10, 10, 0));
                    pyramid.Position = p;
                    pyramid.Height   = 20;
                    pyramid.XLength  = 10;
                    pyramid.YLength  = 15;

                    var solid = _xbimGeometryCreator.CreateSolid(pyramid);

                    Assert.IsTrue(solid.Faces.Count == 5, "5 faces are required of a pyramid");
                    Assert.IsTrue(solid.Vertices.Count == 5, "5 vertices are required of a pyramid");
                }
            }
        }
Ejemplo n.º 11
0
        public void CreateAdvancedBrep()
        {
            var engine = new XbimGeometryEngine();
            var files  = Directory.GetFiles(@"Ifc4TestFiles\NBSAdvancedBreps", "*.ifc");

            foreach (var file in files)
            {
                using (var store = IfcStore.Open(file))
                {
                    foreach (var brep in store.Instances.OfType <IIfcAdvancedBrep>())
                    {
                        var solid = engine.CreateSolid(brep);

                        Assert.IsTrue(solid.Volume > 0, "Breps should have a positive volume");
                    }
                }
            }
        }
        public void IfcExtrudedArea_With_IfcArbritraryClosedProfileDef_And_IfcCompositeCurve()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\2- IfcExtrudedAreaSolid-IfcArbitraryClosedProfileDef-IfcCompositeCurve.ifc"))
                {
                    var eas = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault();
                    Assert.IsTrue(eas != null);
                    Assert.IsTrue(eas.SweptArea is IIfcArbitraryClosedProfileDef, "Incorrect profile definition");
                    Assert.IsTrue(((IIfcArbitraryClosedProfileDef)eas.SweptArea).OuterCurve is IIfcCompositeCurve, "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);
                }
            }
        }
        public void CompositeProfileDefTest()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\IfcCompositeProfileDefTest.ifc"))
                {
                    var eas = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IIfcCompositeProfileDef);
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IIfcCompositeProfileDef, "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 TestDerivedProfileDefWithTShapedParent()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\1- IfcExtrudedAreaSolid-IfcProfileDef-Parameterised.ifc"))
                {
                    var eas = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IIfcDerivedProfileDef && ((IIfcDerivedProfileDef)e.SweptArea).ParentProfile is IIfcTShapeProfileDef);
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IIfcDerivedProfileDef, "Incorrect profiledef found");
                    Assert.IsTrue(((IIfcDerivedProfileDef)eas.SweptArea).ParentProfile is IIfcTShapeProfileDef, "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() == 10, "T Shaped profiles should have 10 faces");
                }
            }
        }
        public void IfcExtrudedArea_With_IfcArbritraryProfileDefWithVoids()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\18 - IfcArbritaryClosedProfileDefWithVoids.ifc"))
                {
                    var eas = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IIfcArbitraryProfileDefWithVoids);
                    Assert.IsTrue(eas != null);
                    Assert.IsTrue(eas.SweptArea is IIfcArbitraryProfileDefWithVoids, "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 TestCircleProfileDef()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = new XbimModel())
                {
                    m.CreateFrom("SolidTestFiles\\3- IfcExtrudedAreaSolid-IfcCircularProfileDef.ifc", null, null, true, true);
                    var eas = m.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IfcCircleProfileDef);
                    Assert.IsTrue(eas != null, "No Extruded Solid found");
                    Assert.IsTrue(eas.SweptArea is IfcCircleProfileDef, "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() == 3, "Circular  profiles should have 3 faces");
                }
            }
        }
        public void IfcExtrudedArea_With_IfcArbritraryClosedProfileDef_And_IfcPolyline()
        {
            var xbimGeometryCreator = new XbimGeometryEngine();

            using (var eventTrace = LoggerFactory.CreateEventTrace())
            {
                using (var m = IfcStore.Open("SolidTestFiles\\1- IfcExtrudedAreaSolid-IfcProfileDef-Parameterised.ifc"))
                {
                    var eas = m.Instances.OfType <IIfcExtrudedAreaSolid>().FirstOrDefault(e => e.SweptArea is IIfcArbitraryClosedProfileDef && ((IIfcArbitraryClosedProfileDef)e.SweptArea).OuterCurve is IIfcPolyline);
                    Assert.IsTrue(eas != null);
                    Assert.IsTrue(eas.SweptArea is IIfcArbitraryClosedProfileDef, "Incorrect profile definition");
                    Assert.IsTrue(((IIfcArbitraryClosedProfileDef)eas.SweptArea).OuterCurve is IIfcPolyline, "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 = ((IIfcPolyline)((IIfcArbitraryClosedProfileDef)eas.SweptArea).OuterCurve).Points.Count() - 1;
                    Assert.IsTrue(solid.Faces.Count() == plineCount + 2, "IfcPolyline  profiles should have (number of polyline egdes + 2) faces");
                }
            }
        }
Ejemplo n.º 18
0
 public void TransformSolidRectangularProfileDef()
 {
     using (var m = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))
     {
         using (var txn = m.BeginTransaction())
         {
             var profile   = IfcModelBuilder.MakeRectangleHollowProfileDef(m, 20, 10, 1);
             var extrude   = IfcModelBuilder.MakeExtrudedAreaSolid(m, profile, 40);
             var solid     = _xbimGeometryCreator.CreateSolid(extrude);
             var transform = new XbimMatrix3D(); //test first with identity
             var solid2    = (IXbimSolid)solid.Transform(transform);
             var s1Verts   = solid.Vertices.ToList();
             var s2Verts   = solid2.Vertices.ToList();
             for (int i = 0; i < s1Verts.Count; i++)
             {
                 XbimVector3D v = s1Verts[i].VertexGeometry - s2Verts[i].VertexGeometry;
                 Assert.IsTrue(v.Length < m.ModelFactors.Precision, "vertices not the same");
             }
             transform.RotateAroundXAxis(Math.PI / 2);
             transform.RotateAroundYAxis(Math.PI / 4);
             transform.RotateAroundZAxis(Math.PI);
             transform.OffsetX += 100;
             transform.OffsetY += 200;
             transform.OffsetZ += 300;
             solid2             = (IXbimSolid)solid.Transform(transform);
             Assert.IsTrue(Math.Abs(solid.Volume - solid2.Volume) < 0.001, "Volume differs");
             transform.Invert();
             solid2  = (IXbimSolid)solid2.Transform(transform);
             s1Verts = solid.Vertices.ToList();
             s2Verts = solid2.Vertices.ToList();
             for (int i = 0; i < s1Verts.Count; i++)
             {
                 XbimVector3D v = s1Verts[i].VertexGeometry - s2Verts[i].VertexGeometry;
                 Assert.IsTrue(v.Length < m.ModelFactors.Precision, "vertices not the same");
             }
             txn.Commit();
         }
     }
 }
Ejemplo n.º 19
0
        public void ArbitraryClosedProfileDefWithIncorrectPlacementTest()
        {
            using (var model = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))
            {
                using (var txn = model.BeginTransaction("Create Column"))
                {
                    IfcProject project = model.Instances.New <IfcProject>();
                    project.Initialize(ProjectUnits.SIUnitsUK);
                    project.Name = "Test Project";

                    IfcColumn col = model.Instances.New <IfcColumn>();
                    col.Name = "Column With ArbitraryClosedProfileDef";


                    //Creating IfcArbitraryClosedProfileDef that will contain IfcCompositeCurve
                    IfcArbitraryClosedProfileDef arbClosedProf = model.Instances.New <IfcArbitraryClosedProfileDef>();

                    //To create IfcArbitraryClosedProfileDef, we'll need to create IfcCompositeCurve
                    //Creating IfcCompositeCurve
                    IfcCompositeCurve myCompCurve = model.Instances.New <IfcCompositeCurve>();

                    //To Create IfcCompositeCurve, We'll need to create IfcCompositeCurveSegment
                    //create IfcCompositeCurveSegment (polyline)
                    IfcCompositeCurveSegment polylineSeg = model.Instances.New <IfcCompositeCurveSegment>();

                    //create IfcCompositeCurveSegment (arc)
                    IfcCompositeCurveSegment arcSeg = model.Instances.New <IfcCompositeCurveSegment>();

                    //Creating IfcPolyline that will be the parent curve for IfcCompositeCurveSegment "polylineSeg"
                    IfcPolyline myPolyline = model.Instances.New <IfcPolyline>();

                    //Creating Points to build the IfcPolyline
                    IfcCartesianPoint p0 = model.Instances.New <IfcCartesianPoint>();
                    p0.SetXY(200, 100);

                    IfcCartesianPoint p1 = model.Instances.New <IfcCartesianPoint>();
                    p1.SetXY(0, 100);

                    IfcCartesianPoint p2 = model.Instances.New <IfcCartesianPoint>();
                    p2.SetXY(0, 0);

                    IfcCartesianPoint p3 = model.Instances.New <IfcCartesianPoint>();
                    p3.SetXY(400, 0);

                    IfcCartesianPoint p4 = model.Instances.New <IfcCartesianPoint>();
                    p4.SetXY(400, 600);

                    IfcCartesianPoint p5 = model.Instances.New <IfcCartesianPoint>();
                    p5.SetXY(0, 600);

                    IfcCartesianPoint p6 = model.Instances.New <IfcCartesianPoint>();
                    p6.SetXY(0, 500);

                    IfcCartesianPoint p7 = model.Instances.New <IfcCartesianPoint>();
                    p7.SetXY(200, 500);

                    //Adding points to the polyline
                    myPolyline.Points.Add(p0);
                    myPolyline.Points.Add(p1);
                    myPolyline.Points.Add(p2);
                    myPolyline.Points.Add(p3);
                    myPolyline.Points.Add(p4);
                    myPolyline.Points.Add(p5);
                    myPolyline.Points.Add(p6);
                    myPolyline.Points.Add(p7);

                    //Assigning myPolyline to the IfcCompositeCurveSegment polylineSeg
                    polylineSeg.ParentCurve = myPolyline;

                    //Creating Arc using IfcTrimmedCurve
                    IfcTrimmedCurve myArc = model.Instances.New <IfcTrimmedCurve>();

                    //To create IfcTrimmedCurve, We'll need to create IfcCircle and trim it using IfcTrimmingSelect
                    IfcCircle myCirc = model.Instances.New <IfcCircle>();
                    myCirc.Radius = 213.554;
                    IfcCartesianPoint cP = model.Instances.New <IfcCartesianPoint>();
                    cP.SetXY(125.1312, 300); //this should really be a 3D point

                    IfcAxis2Placement3D plcmnt = model.Instances.New <IfcAxis2Placement3D>();
                    plcmnt.Location     = cP;
                    plcmnt.RefDirection = model.Instances.New <IfcDirection>();
                    plcmnt.RefDirection.SetXY(0, 1);//this should eb a 3D axis
                    myCirc.Position = plcmnt;

                    myArc.BasisCurve = myCirc;

                    IfcTrimmingSelect v1 = p7;
                    IfcTrimmingSelect v2 = p0;

                    myArc.Trim1.Add(v1);
                    myArc.Trim2.Add(v2);

                    arcSeg.ParentCurve = myArc;

                    //Adding the created two IfcCompositeCurveSegments to the IfcCompositeCurve
                    myCompCurve.Segments.Add(arcSeg);
                    myCompCurve.Segments.Add(polylineSeg);

                    //Assigning IfcCompositeCurve "myCompCurve" to the IfcArbitraryClosedProfileDef
                    arbClosedProf.OuterCurve = myCompCurve;

                    arbClosedProf.ProfileType = IfcProfileTypeEnum.AREA;

                    //model as a swept area solid
                    IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();
                    body.Depth             = 2000;
                    body.SweptArea         = arbClosedProf;
                    body.ExtrudedDirection = model.Instances.New <IfcDirection>();
                    body.ExtrudedDirection.SetXYZ(0, 0, 1);


                    txn.Commit();
                    var solid = _xbimGeometryCreator.CreateSolid(body);
                    Assert.IsTrue((int)solid.Volume == 239345450);
                }
            }
        }
Ejemplo n.º 20
0
 public void ExtrudedSolidWithNullPositionTest()
 {
     using (var model = IfcStore.Open(@"Ifc4TestFiles\Wall.ifc"))
     {
         var extSolid = model.Instances.OfType <IfcExtrudedAreaSolid>().FirstOrDefault();
         Assert.IsNotNull(extSolid);
         var wall = _xbimGeometryCreator.CreateSolid(extSolid);
         Assert.IsTrue(wall.Volume > 0);
     }
 }