Пример #1
0
        public void TestPlacementSerialization()
        {
            var sb = new StringBuilder();
            var sw = new StringWriter(sb);

            // Use mesh order for edges
            Placement.SetEdgeOrder(-1);

            // No two points share the same X position
            var mesh = new BndFactory(2).CreateMesh() as BndMesh;

            BuildTrapezoid(mesh);
            // ReSharper disable once PossibleNullReferenceException
            mesh.FinalizeMesh();

            var tree = Placement.GetPlacementTree(mesh);

            Placement.Serialize(tree, f => f == null ? "outside" : "The one and only!", sw);

            StringReader sr = new StringReader(sb.ToString());

            tree = Placement.Deserialize(s => s, sr);
            Assert.AreEqual(tree.Locate((T)0.5, (T)0.1), "The one and only!");
            Assert.AreEqual(tree.Locate((T)1.5, (T)0.1), "The one and only!");
            Assert.AreEqual(tree.Locate((T)2.5, (T)0.1), "The one and only!");
            Assert.AreEqual(tree.Locate((T)(-1), (T)0), "outside");
            Assert.AreEqual(tree.Locate((T)0.5, (T)(-1)), "outside");
            Assert.AreEqual(tree.Locate((T)0.5, (T)3), "outside");
            Assert.AreEqual(tree.Locate((T)1.5, (T)(-1)), "outside");
            Assert.AreEqual(tree.Locate((T)1.5, (T)3), "outside");
            Assert.AreEqual(tree.Locate((T)2.5, (T)0.9), "outside");
            Assert.AreEqual(tree.Locate((T)2.5, (T)3), "outside");
        }