public void CompleteProductInsert() { const string original = "TestFiles\\4walls1floorSite.ifc"; using (var model = new IO.Memory.MemoryModel(ef2x3)) { var errs = model.LoadStep21(original); Assert.AreEqual(0, errs); using (model.BeginEntityCaching()) using (model.BeginInverseCaching()) { var products = model.Instances.OfType <IfcProduct>(); using (var iModel = new IO.Memory.MemoryModel(ef2x3)) { var map = new XbimInstanceHandleMap(model, iModel); using (var txn = iModel.BeginTransaction("Insert copy")) { var w = new Stopwatch(); w.Start(); iModel.InsertCopy(products, true, false, map); txn.Commit(); w.Stop(); var copies = Path.ChangeExtension(original, ".copy.ifc"); using (var f = File.Create(copies)) { iModel.SaveAsIfc(f); f.Close(); } } // use all caching we can for this using (iModel.BeginEntityCaching()) using (iModel.BeginInverseCaching()) { // number of products should be the same var origProdCount = model.Instances.CountOf <IfcProduct>(); var prodCount = iModel.Instances.CountOf <IfcProduct>(); Assert.AreEqual(origProdCount, prodCount); // number of geometry representations should be the same var origRepCount = model.Instances.CountOf <IfcProductRepresentation>(); var repCount = model.Instances.CountOf <IfcProductRepresentation>(); Assert.AreEqual(origRepCount, repCount); // number of geometry representations should be the same var origRepItemCount = model.Instances.CountOf <IfcRepresentationItem>(); var repItemCount = model.Instances.CountOf <IfcRepresentationItem>(); Assert.AreEqual(origRepItemCount, repItemCount); // number of representation items in every product should be the same foreach (var product in model.Instances.OfType <IfcProduct>()) { var iProduct = map[new XbimInstanceHandle(product)].GetEntity() as IfcProduct; var count = product.Representation?.Representations.SelectMany(r => r.Items).Count(); var iCount = iProduct.Representation?.Representations.SelectMany(r => r.Items).Count(); Assert.AreEqual(count, iCount); } } } } } }