Пример #1
0
        public void Ifc2X3XMLSerialization()
        {
            const string output = "..\\..\\4walls1floorSite.ifcxml";

            using (var esent = new IO.Esent.EsentModel(new EntityFactory()))
            {
                string fileName = Guid.NewGuid() + ".xbim";
                esent.CreateFrom("4walls1floorSite.ifc", fileName, null, true, true);
                esent.SaveAs(output, IfcStorageType.IfcXml);
                var errs = ValidateIfc2X3("..\\..\\4walls1floorSite.ifcxml");
                Assert.AreEqual(0, errs);
                esent.Close();
            }

            using (var esent = new IO.Esent.EsentModel(new EntityFactory()))
            {
                string fileName = Guid.NewGuid() + ".xbim";
                var    success  = esent.CreateFrom(output, fileName, null, true, true);
                Assert.IsTrue(success);
                Assert.AreEqual(4, esent.Instances.CountOf <IfcWall>());
                esent.Close();
            }

            //check version info
            using (var file = File.OpenRead(output))
            {
                var header = XbimXmlReader4.ReadHeader(file);
                Assert.AreEqual("IFC2X3", header.SchemaVersion);
            }
        }
Пример #2
0
        public void Ifc2X3XMLSerialization()
        {
            // if there's no network a message is asserted, but then this test passes
            // to prevent concerns when testing the solution offline (which would appear to fail)
            //
            if (!Network.Available)
            {
                return;
            }

            const string output = "..\\..\\4walls1floorSite.ifcxml";

            using (var esent = new IO.Esent.EsentModel(new EntityFactoryIfc2x3()))
            {
                string fileName = Guid.NewGuid() + ".xbim";
                esent.CreateFrom("4walls1floorSite.ifc", fileName, null, true, true);
                esent.SaveAs(output, StorageType.IfcXml);
                var errs = ValidateIfc2X3("..\\..\\4walls1floorSite.ifcxml");
                Assert.AreEqual(0, errs);
                esent.Close();
            }

            using (var esent = new IO.Esent.EsentModel(new EntityFactoryIfc2x3()))
            {
                string fileName = Guid.NewGuid() + ".xbim";
                var    success  = esent.CreateFrom(output, fileName, null, true, true);
                Assert.IsTrue(success);
                Assert.AreEqual(4, esent.Instances.CountOf <IfcWall>());
                esent.Close();
            }

            //check version info
            using (var file = File.OpenRead(output))
            {
                var header = XbimXmlReader4.ReadHeader(file);
                Assert.AreEqual("IFC2X3", header.SchemaVersion);
            }
        }
Пример #3
0
        public void IfcStoreGeometryGeometryClearTest()
        {
            using (var model = new IO.Esent.EsentModel(ef4))
            {
                model.CreateFrom("SampleHouse4.ifc", null, null, true);
                var store = model.GeometryStore;
                using (var txn = store.BeginInit())
                {
                    //ADD A GEOMETRY SHAPE
                    var geomData = new XbimShapeGeometry()
                    {
                        IfcShapeLabel  = 1,
                        Format         = XbimGeometryType.BoundingBox,
                        GeometryHash   = 0,
                        LOD            = XbimLOD.LOD100,
                        ReferenceCount = 1,
                        ShapeData      = "2123",
                        BoundingBox    = XbimRect3D.Empty
                    };
                    var shapeGeomLabel = txn.AddShapeGeometry(geomData);

                    //ADD A SHAPE INSTANCE
                    var shapeInstance = new XbimShapeInstance()
                    {
                        ShapeGeometryLabel = shapeGeomLabel
                    };

                    var instanceId = txn.AddShapeInstance(shapeInstance, shapeGeomLabel);
                    Assert.IsTrue(instanceId == 1);

                    //ADD A REGIONCOLLECTION
                    var regions = new XbimRegionCollection {
                        ContextLabel = 50
                    };
                    regions.Add(new XbimRegion("region1", XbimRect3D.Empty, 100, XbimMatrix3D.Identity));
                    txn.AddRegions(regions);

                    txn.Commit();
                }
                //now redo which should clear the geoemtry
                using (var txn = store.BeginInit())
                {
                    Assert.IsNotNull(txn);
                    //ADD A GEOMETRY SHAPE
                    var geomData = new XbimShapeGeometry()
                    {
                        IfcShapeLabel  = 1,
                        Format         = XbimGeometryType.BoundingBox,
                        GeometryHash   = 0,
                        LOD            = XbimLOD.LOD100,
                        ReferenceCount = 1,
                        ShapeData      = "2123",
                        BoundingBox    = XbimRect3D.Empty
                    };
                    var shapeGeomLabel = txn.AddShapeGeometry(geomData);

                    //ADD A SHAPE INSTANCE
                    var shapeInstance = new XbimShapeInstance()
                    {
                        ShapeGeometryLabel = shapeGeomLabel
                    };

                    var instanceId = txn.AddShapeInstance(shapeInstance, shapeGeomLabel);
                    Assert.IsTrue(instanceId == 1); //if this is 2 it has failed to clear

                    //ADD A REGIONCOLLECTION
                    var regions = new XbimRegionCollection {
                        ContextLabel = 50
                    };
                    regions.Add(new XbimRegion("region1", XbimRect3D.Empty, 100, XbimMatrix3D.Identity));
                    txn.AddRegions(regions);

                    txn.Commit();
                }
                model.Close();
            }
        }
Пример #4
0
        public void EsentGeometryStoreBatchTest()
        {
            using (var model = new IO.Esent.EsentModel(ef4))
            {
                model.CreateFrom("SampleHouse4.ifc", null, null, true);
                var store = model.GeometryStore;
                using (var txn = store.BeginInit())
                {
                    for (int i = 0; i < 100; i++)
                    {
                        //ADD A GEOMETRY SHAPE
                        var geomData = new XbimShapeGeometry()
                        {
                            IfcShapeLabel  = 1,
                            Format         = XbimGeometryType.BoundingBox,
                            GeometryHash   = 0,
                            LOD            = XbimLOD.LOD100,
                            ReferenceCount = 1,
                            ShapeData      = "2123",
                            BoundingBox    = XbimRect3D.Empty
                        };
                        var shapeGeomLabel = txn.AddShapeGeometry(geomData);
                    }
                    for (int i = 0; i < 100; i++)
                    {
                        //ADD A SHAPE INSTANCE
                        var shapeInstance = new XbimShapeInstance()
                        {
                            ShapeGeometryLabel = i + 1
                        };

                        var instanceId = txn.AddShapeInstance(shapeInstance, i + 1);
                        Assert.IsTrue(instanceId == i + 1);
                    }
                    for (int i = 0; i < 100; i++)
                    {
                        //ADD A SHAPE INSTANCE
                        var shapeInstance = new XbimShapeInstance()
                        {
                            ShapeGeometryLabel = i + 1
                        };

                        var instanceId = txn.AddShapeInstance(shapeInstance, i + 1);
                        Assert.IsTrue(instanceId == i + 101);
                    }
                    for (int i = 0; i < 100; i++)
                    {
                        //ADD A SHAPE INSTANCE
                        var shapeInstance = new XbimShapeInstance()
                        {
                            ShapeGeometryLabel = i + 1
                        };

                        var instanceId = txn.AddShapeInstance(shapeInstance, i + 1);
                        Assert.IsTrue(instanceId == i + 201);
                    }
                    //ADD A REGIONCOLLECTION
                    var regions = new XbimRegionCollection {
                        ContextLabel = 50
                    };
                    regions.Add(new XbimRegion("region1", XbimRect3D.Empty, 100, XbimMatrix3D.Identity));
                    txn.AddRegions(regions);

                    txn.Commit();
                }
                model.Close();
            }
        }