public async Task RemoveByName() { IfcStore.ModelProviderFactory.UseMemoryModelProvider(); using (var source = IfcStore.Open(@"Resources\Ifc4-Storey-With-4Walls.ifc")) { var stampBefore = SchemaValidator.OfModel(source); Assert.IsTrue(stampBefore.IsCompliantToSchema); Assert.AreEqual(4, source.Instances .OfType <IIfcPropertySet>() .Where(s => s.Name == "AllplanAttributes") .Count()); var request = new IfcPropertySetRemovalRequest(this.TestLoggerFactory) { ExludePropertySetByName = new string[] { "AllplanAttributes" }, IsNameMatchingCaseSensitive = false, // Common config IsLogEnabled = true, TargetStoreType = Xbim.IO.XbimStoreType.InMemoryModel, EditorCredentials = EditorCredentials }; var cp = new CancelableProgressing(true); cp.OnProgressChange += (sender, e) => TestLogger.LogDebug($"State {e.State}: Percentage = {e.Percentage}; State object = {e.StateObject}"); using (var result = await request.Run(source, cp)) { if (null != result.Cause) { TestLogger?.LogError("Exception: {0}, {1}, {2}", result.Cause, result.Cause.Message, result.Cause.StackTrace); } Assert.AreEqual(TransformResult.Code.Finished, result.ResultCode); Assert.AreEqual(0, result.Target.Instances .OfType <IIfcPropertySet>() .Where(s => s.Name == "AllplanAttributes") .Count()); var pset = result.Target.Instances .OfType <IIfcPropertySet>() .Where(s => s.Name == "AllplanAttributes Copy") .ToArray(); Assert.AreEqual(4, pset.Length); Assert.IsTrue(pset.All(p => p.Properties <IIfcProperty>().Count() == 3)); var stampAfter = SchemaValidator.OfModel(result.Target); Assert.IsTrue(stampAfter.IsCompliantToSchema); Assert.IsTrue(cp.State.State.HasFlag(ProgressTokenState.IsTerminated)); result.Target.SaveAsIfc(new FileStream("Ifc4-Storey-With-4Walls-AllplanAttributes-Copy-1.ifc", FileMode.Create)); } } }
public async Task KeepOrRemoveByName() { IfcStore.ModelProviderFactory.UseMemoryModelProvider(); using (var source = IfcStore.Open(@"Resources\Ifc4-SampleHouse.ifc")) { var stampBefore = SchemaValidator.OfModel(source); Assert.IsTrue(stampBefore.IsCompliantToSchema); var request = new IfcPropertySetRemovalRequest(this.TestLoggerFactory) { ExludePropertySetByName = new string[] { "Other" }, IncludePropertySetByName = new string[] { "Pset_SpaceCommon", "Other" }, IsNameMatchingCaseSensitive = false, FilterRuleStrategy = FilterRuleStrategyType.ExcludeBeforeInclude, // Common config IsLogEnabled = true, TargetStoreType = Xbim.IO.XbimStoreType.InMemoryModel, EditorCredentials = EditorCredentials }; var cp = new CancelableProgressing(true); cp.OnProgressChange += (sender, e) => TestLogger.LogDebug($"State {e.State}: Percentage = {e.Percentage}; State object = {e.StateObject}"); using (var result = await request.Run(source, cp)) { if (null != result.Cause) { TestLogger?.LogError("Exception: {0}, {1}, {2}", result.Cause, result.Cause.Message, result.Cause.StackTrace); } var psetsRemaining = result.Target.Instances .OfType <IIfcPropertySet>() .Select(s => s.Name.ToString()) .Distinct() .ToArray(); Assert.AreEqual(TransformResult.Code.Finished, result.ResultCode); Assert.AreEqual(1, psetsRemaining.Length); Assert.IsTrue(string.Equals("Pset_SpaceCommon", psetsRemaining[0], StringComparison.OrdinalIgnoreCase)); var stampAfter = SchemaValidator.OfModel(result.Target); Assert.IsTrue(stampAfter.IsCompliantToSchema); Assert.IsTrue(cp.State.State.HasFlag(ProgressTokenState.IsTerminated)); result.Target.SaveAsIfc(new FileStream("Ifc4-SampleHouse-Pset_SpaceCommon-Other.ifc", FileMode.Create)); } } }
public async Task OffsetShiftAndRotateTest2_New() { IfcStore.ModelProviderFactory.UseMemoryModelProvider(); using (var source = IfcStore.Open(@"Resources\Ifc4-SampleHouse.ifc")) { var stampBefore = SchemaValidator.OfModel(source); var testConfig = IfcAxisAlignment.LoadFromFile(@"Resources\IfcAlignmentTestAxis2.xml"); Assert.IsNotNull(testConfig); Assert.IsNotNull(testConfig.SourceReferenceAxis); Assert.IsNotNull(testConfig.TargetReferenceAxis); var request = new IfcPlacementTransformRequest(this.TestLoggerFactory) { AxisAlignment = testConfig, PlacementStrategy = IfcPlacementStrategy.NewRootPlacement, // Common config IsLogEnabled = true, TargetStoreType = Xbim.IO.XbimStoreType.InMemoryModel, EditorCredentials = EditorCredentials }; using (var cp = new CancelableProgressing(true)) { cp.OnProgressChange += (s, o) => TestLogger.LogDebug($"State {o.State}: Percentage = {o.Percentage}; State object = {o.StateObject}"); using (var result = await request.Run(source, cp)) { if (null != result.Cause) { TestLogger?.LogError("Exception: {0}, {1}, {2}", result.Cause, result.Cause.Message, result.Cause.StackTrace); } var rootPlacement = result.Target.Instances.OfType <IIfcLocalPlacement>().Where(i => i.PlacementRelTo == null).FirstOrDefault(); Assert.IsNotNull(rootPlacement.PlacesObject); Assert.IsFalse(rootPlacement.PlacesObject.Any(), "Root has no objects"); //Assert.AreEqual(TransformResult.Code.Finished, result.ResultCode); // TODO Specific tests var stampAfter = SchemaValidator.OfModel(result.Target); //Assert.AreEqual(stampBefore, stampAfter); result.Target.SaveAsIfc(new FileStream("Ifc4-SampleHouse-Transformed.ifc", FileMode.Create)); } } } }
public void SchemaConstraintTest() { IfcStore.ModelProviderFactory.UseMemoryModelProvider(); using (var source = IfcStore.Open(@"Resources\Ifc2x3-Slab-BooleanResult.ifc")) { var validationStamp = SchemaValidator.OfModel(source, Xbim.Common.Enumerations.ValidationFlags.TypeWhereClauses | Xbim.Common.Enumerations.ValidationFlags.EntityWhereClauses); var lookUp = validationStamp.InstanceResults; Assert.AreEqual(1, lookUp.Count); Assert.IsFalse(validationStamp.IsConstraintToSchema); Assert.IsTrue(validationStamp.IsCompliantToSchema); var results = lookUp[new Xbim.Common.XbimInstanceHandle(source.Model.Instances[25])]; Assert.AreEqual(1, results.Count()); Assert.IsFalse(SchemaValidator.Diff(validationStamp.Results, validationStamp.Results).Any()); Assert.IsTrue(validationStamp.Equals(validationStamp)); } }