Пример #1
0
 public void Initialize()
 {
     mSystemObjects               = new DeserializedObjects(mSystemDescription, _path);
     m_testMSystem                = new MSystem(mSystemObjects);
     m_tilesWorld                 = new TilesWorld(m_testMSystem);
     m_floatingObjWorld           = new FloatingObjectsWorld(m_testMSystem, m_tilesWorld);
     m_tilesWorld.FltObjectsWorld = m_floatingObjWorld;
 }
Пример #2
0
 //Initialize object/s before each test is run. It will be called for each test.
 public void Initialize()
 {
     _testTilesWorld = new TilesWorld(_testMSystem);
     // Leaving only tile q1 in the TilesWorld
     _testTilesWorld.Remove(_testTilesWorld.ToArray()[1]);
     _testTilesWorld.Remove(_testTilesWorld.ToArray()[1]);
     _testFltObjectsWorld            = new FloatingObjectsWorld(_testMSystem, _testTilesWorld);
     _testTilesWorld.FltObjectsWorld = _testFltObjectsWorld;
 }
Пример #3
0
        // TODO move to the TilesWorldTest.cs (low priority)
        public void TestPushingDirection()
        {
            Assert.AreEqual(new Point3D(0, 0, 1), TilesWorld.PushingDirection(tubule.Connectors[0]).ToPoint3D().Round());
            Assert.AreEqual(new Point3D(-1, 0, 0), TilesWorld.PushingDirection(baseTile.Connectors[0]).ToPoint3D().Round());
            Assert.AreEqual(new Point3D(0, 1, 0), TilesWorld.PushingDirection(eastTile.Connectors[0]).ToPoint3D().Round());
            Assert.AreEqual(new Point3D(0, 0, -1), TilesWorld.PushingDirection(southTile.Connectors[1]).ToPoint3D().Round());

            baseTile.Connectors[3].ConnectObject(_tubule.Connectors[0]);
            Assert.IsTrue(new Vector3D(0, 0, -1).Equals(TilesWorld.PushingDirection(baseTile.Connectors[3]), 1e-14));
        }
Пример #4
0
        /// <summary>
        /// MSystemStats constructor.
        /// </summary>
        /// <param name="tilesWorld">Tiles in simulation world</param>
        public void CalculateTileStats(TilesWorld tilesWorld)
        {
            if (tilesWorld == null)
            {
                throw new ArgumentException("TilesWorld cannot be null.");
            }
            // get copy of all tiles
            HashSet <TileInSpace> polygonTiles = new HashSet <TileInSpace>(tilesWorld.PolygonTiles);

            while (polygonTiles.Count != 0)
            {
                // get first tile in the collection and get its component, e.g. all tiles connected to it
                TileInSpace           tile      = polygonTiles.First();
                HashSet <TileInSpace> component = tile.Component();

                // now walk through the whole component and count q1 (valued at 1) and q2 (valued at 10) tiles
                int completionValue = 0;
                foreach (TileInSpace element in component)
                {
                    // only polygon tiles matter
                    if (element.Vertices is Polygon3D)
                    {
                        switch (element.Name)
                        {
                        case "q0":
                        case "q1":
                            completionValue += 15;
                            break;

                        case "q2":
                            completionValue += 1;
                            break;
                        }
                    }
                }

                // increment number of components in stats dictionary
                if (!m_componentStats.ContainsKey(completionValue))
                {
                    m_componentStats.Add(completionValue, 0);
                }
                m_componentStats[completionValue]++;

                // remove all tiles of the component form the list
                foreach (TileInSpace element in component)
                {
                    polygonTiles.Remove(element);
                }
            }
        }
Пример #5
0
 public void TestConstructorMSystemNull()
 {
     TilesWorld fow = new TilesWorld(null);
 }
Пример #6
0
 /// <summary>
 /// Adds a new snapshot to the snapshots XML document
 /// </summary>
 /// <param name="snapshotXmlDoc">Target snapshots XML document</param>
 /// <param name="stepID">Snapshot number.</param>
 /// <param name="floatingObjects">Floating objects to be serialized.</param>
 /// <param name="tilesWorld">Tiles to be serialized.</param>
 public static void AddSnapshot(ulong stepID, FloatingObjectsSet floatingObjects, TilesWorld tilesWorld, SerializeSnapshot snapshotXmlDoc)
 {
     if (floatingObjects == null)
     {
         throw new ArgumentNullException("Parameter 'floatingObjects' may not be null.");
     }
     if (tilesWorld == null)
     {
         throw new ArgumentNullException("Parameter 'tilesWorld' may not be null.");
     }
     if (snapshotXmlDoc == null)
     {
         throw new ArgumentNullException("Parameter 'snapshotXmlDoc' may not be null.");
     }
     snapshotXmlDoc.Serialize(stepID, floatingObjects, tilesWorld);
 }