Beispiel #1
0
        public void TestIntersection()
        {
            Assert.IsFalse(baseTile.IntersectsWith(eastTile));
            Assert.IsFalse(baseTile.IntersectsWith(southTile));
            Assert.IsFalse(eastTile.IntersectsWith(southTile));
            Assert.IsFalse(topTile.IntersectsWith(eastTile));
            Assert.IsFalse(topTile.IntersectsWith(southTile));

            baseTile.Move(new Vector3D(MSystem.Tolerance / 10, -MSystem.Tolerance / 10, MSystem.Tolerance / 10));
            Assert.IsFalse(baseTile.IntersectsWith(eastTile));
            Assert.IsFalse(baseTile.IntersectsWith(southTile));

            baseTile.Move(new Vector3D(MSystem.Tolerance * 10, -MSystem.Tolerance * 10, MSystem.Tolerance * 10));
            Assert.IsTrue(baseTile.IntersectsWith(eastTile));
            Assert.IsTrue(baseTile.IntersectsWith(southTile));
        }
Beispiel #2
0
        public void CreateComplexSnapshotFileTest()
        // Petr: Actually not a test - only temporary debugging method. Please do not remove.
        // Produces a test snapshot file for Honza - testing the visualization package in Unity.
        {
            //Set test Floating objects set
            var testFloatingObjectInSpace = new FloatingObjectInSpace(v_TestFloatingObject, new Point3D(0, 1, 2)); // Add more
            var testFloatingObjectsSet    = new FloatingObjectsSet {
                testFloatingObjectInSpace
            };

            Tile baseTile        = CreateTile("q2");
            Tile baseTubule      = CreateSegment("s1");
            var  v_baseTilesList = new List <Tile> {
                baseTile, baseTubule
            };

            var testTilesList = new List <TileInSpace>
            {
                new TileInSpace(baseTile, Point3D.Origin, Quaternion.One)
            };

            SerializeSnapshot testSnapshot = new SerializeSnapshot(c_TestMSystemDescription, v_baseTilesList);

            testSnapshot.Serialize(0, testFloatingObjectsSet, testTilesList);

            TileInSpace bottomTile = testTilesList.First();

            bottomTile.State = TileInSpace.FState.Unchanged;
            var level1Tiles = new List <TileInSpace>();

            for (int i = 0; i < 5; i++)
            {
                level1Tiles.Add(bottomTile.Connectors[i].ConnectObject(baseTile.Connectors[0]));
            }

            testTilesList.AddRange(level1Tiles);

            var tubule1 = bottomTile.Connectors.Last().ConnectObject(baseTubule.Connectors[0]);

            testTilesList.Add(tubule1);
            testSnapshot.Serialize(1, testFloatingObjectsSet, testTilesList);

            // Adding the second level of tiles of dodecahedron and tubules
            tubule1.State = TileInSpace.FState.Unchanged;
            var level2Tiles   = new List <TileInSpace>();
            var level2Tubules = new List <TileInSpace>();

            foreach (var tile in level1Tiles)
            {
                tile.State = TileInSpace.FState.Unchanged;
                level2Tiles.Add(tile.Connectors[2].ConnectObject(baseTile.Connectors[0]));
            }
            for (int i = 1; i < 3; i++)
            {
                level2Tubules.Add(tubule1.Connectors[i].ConnectObject(baseTubule.Connectors[0]));
            }

            testTilesList.AddRange(level2Tiles);
            testTilesList.AddRange(level2Tubules);
            testSnapshot.Serialize(2, testFloatingObjectsSet, testTilesList);

            foreach (var tile in level2Tiles)
            {
                tile.State = TileInSpace.FState.Unchanged;
            }

            // Adding the last top tile of dodecahedron
            TileInSpace topTile = level2Tiles.Last().Connectors[3].ConnectObject(baseTile.Connectors[0]);

            testTilesList.Add(topTile);

            var level3Tubules = new List <TileInSpace>();

            foreach (var tubule in level2Tubules)
            {
                tubule.State = TileInSpace.FState.Unchanged;
                for (int i = 1; i < 3; i++)
                {
                    level3Tubules.Add(tubule.Connectors[i].ConnectObject(baseTubule.Connectors[0]));
                }
            }

            // Dodecahedron complete, three levels of tubule tree complete
            testTilesList.AddRange(level3Tubules);
            testSnapshot.Serialize(3, testFloatingObjectsSet, testTilesList);

            topTile.State = TileInSpace.FState.Unchanged;
            foreach (var tubule in level3Tubules)
            {
                tubule.State = TileInSpace.FState.Unchanged;
            }

            foreach (var tile in level2Tiles)
            {
                tile.State = TileInSpace.FState.Destroy;
            }

            // Level 2 tiles destructed
            testSnapshot.Serialize(4, testFloatingObjectsSet, testTilesList);

            testTilesList.RemoveAll(obj => level2Tiles.Contains(obj));
            topTile.Move(new Vector3D(0, 0, -5));

            // Top tile moved 5 units down
            testSnapshot.Serialize(5, testFloatingObjectsSet, testTilesList);

            topTile.State = TileInSpace.FState.Unchanged;
            var         Tile        = CreateSquareTile("TestSquare");
            TileInSpace baseSquare  = new TileInSpace(Tile, new Point3D(30, 0, 0), Quaternion.One);
            TileInSpace eastSquare  = baseSquare.Connectors[0].ConnectObject(Tile.Connectors[1]);
            TileInSpace southSquare = eastSquare.Connectors[0].ConnectObject(Tile.Connectors[0]);
            TileInSpace topSquare   = southSquare.Connectors[1].ConnectObject(Tile.Connectors[0]);

            // Four squares added, forming an incomplete cube
            testTilesList.AddRange(new List <TileInSpace>()
            {
                baseSquare, eastSquare, southSquare, topSquare
            });
            testSnapshot.Serialize(6, testFloatingObjectsSet, testTilesList);

            testSnapshot.SaveXmlFile(@"..\..\..\Cytos_v2\Examples\TestSnapshotFile.xml");
        }