Exemple #1
0
        public void ValidIdentityInFederation()
        {
            using (var fedModel = Xbim.Ifc2x3.IO.XbimModel.CreateTemporaryModel())
            {
                fedModel.Initialise("Federation Creating Author", "Federation Creating Organisation", "This Application", "This Developer", "v1.1");
                using (var txn = fedModel.BeginTransaction())
                {
                    fedModel.IfcProject.Name = "Federation Project Name";
                    txn.Commit();
                }
                //now add federated models
                fedModel.AddModelReference(ModelFedP1, "The Architects Name", IfcRoleEnum.ARCHITECT);
                fedModel.AddModelReference(ModelFedP2, "The Owners Name", IfcRoleEnum.BUILDINGOWNER);
                fedModel.SaveAs("P1P2Federation", IfcStorageType.Ifc);
            } //close and automatically delete the temporary database
            //Now open the Ifc file and see what we have
            using (var fed = new Xbim.Ifc2x3.IO.XbimModel())
            {
                fed.CreateFrom("P1P2Federation.ifc", "P1P2Federation.xBIMF"); //use xBIMF to help us distinguish
                fed.Open("P1P2Federation.xBIMF");
                fed.EnsureUniqueUserDefinedId();

                var mustDiffer =
                    fed.FederatedInstances.OfType <IfcGeometricRepresentationSubContext>()
                    .Where(x => x.ContextIdentifier == @"Body").ToArray();

                // we are expecting two items (one body from each model loaded)
                // they happen to share the same entitylabel, but they have different models.

                var first  = mustDiffer[0];
                var second = mustDiffer[1];

                Assert.IsFalse(first == second);

                var tst = new HashSet <IfcGeometricRepresentationContext>();
                tst.Add(first);
                tst.Add(second);
                Assert.IsTrue(tst.Count == 2);
            }
        }