Esempio n. 1
0
        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));
                    }
                }
            }
        }
Esempio n. 2
0
        public void IfcAxisAlignmentSerializationTest()
        {
            var axis1 = new IfcAxisAlignment()
            {
                SourceReferenceAxis = new IfcAlignReferenceAxis(new XYZ(), new XYZ {
                    X = 1
                }),
                TargetReferenceAxis = new IfcAlignReferenceAxis(new XYZ(), new XYZ {
                    Y = 1
                })
            };

            axis1.SaveToFile("TestAxisAlignment.xml");

            var axis2 = IfcAxisAlignment.LoadFromFile("TestAxisAlignment.xml");

            Assert.IsNotNull(axis2);
            Assert.IsNotNull(axis2.SourceReferenceAxis);
            Assert.IsTrue(axis2.SourceReferenceAxis.Offset.IsAlmostEqual(axis1.SourceReferenceAxis.Offset, Precision));
            Assert.IsTrue(axis2.SourceReferenceAxis.Target.IsAlmostEqual(axis1.SourceReferenceAxis.Target, Precision));
            Assert.IsNotNull(axis2.TargetReferenceAxis);
            Assert.IsTrue(axis2.TargetReferenceAxis.Offset.IsAlmostEqual(axis1.TargetReferenceAxis.Offset, Precision));
            Assert.IsTrue(axis2.TargetReferenceAxis.Target.IsAlmostEqual(axis1.TargetReferenceAxis.Target, Precision));
        }
Esempio n. 3
0
#pragma warning restore CS1591

        /// <summary>
        /// Loads an alignment from persitent file.
        /// </summary>
        /// <param name="fileName">The file name</param>
        /// <returns>An alignment structure.</returns>
        public static Alignment ByFile(string fileName)
        {
            return(new Alignment(IfcAxisAlignment.LoadFromFile(fileName)));
        }