Example #1
0
        /// <summary>
        ///get executing time for a path
        ///</summary>
        public Int64 getPathExecutingTime(FloorPlan floorPlan, int StartX, int StartY, int TargetX, int TargetY)
        {
            Int64 ExecutingTime = 0;

            floorPlan.setStartTile(StartX, StartY);
            floorPlan.setTargetTile(TargetX, TargetY);
            QGPathFinder target = new QGPathFinder(floorPlan);
            List<FloorTile> actual;

            DateTime StartTime = DateTime.Now;
            actual = target.getPath();
            DateTime EndTime = DateTime.Now;
            TimeSpan t= EndTime - StartTime;

            if (actual != null){
                ExecutingTime = (Int64) t.TotalMilliseconds;
            }

            return ExecutingTime;
        }
 public void TestStartTilewalkable()
 {
     FloorPlan image1 = new FloorPlan(new Bitmap("../../testImage.jpg"), 5);
     bool result = image1.setStartTile(3, 4);
     FloorTile tile = image1.getTile(3, 4);
     bool t_res = tile.IsStart();
     bool t_res2 = tile.IsTarget();
     Assert.AreEqual(true, result);
     System.Diagnostics.Debug.WriteLine("Start:" + t_res);
     System.Diagnostics.Debug.WriteLine("Target:" + t_res2);
 }
Example #3
0
        public void getPathTest()
        {
            TextWriter tw = new StreamWriter("../../getPathResult.txt");

            Image myimage = new Bitmap("../../floorplan.bmp");
            FloorPlan floorPlan = new FloorPlan(myimage, 3); // TODO: Initialize to an appropriate value
            int StartX = 106;
            int StartY = 74;
            int TargetX = 107;
            int TargetY = 43;
            floorPlan.setStartTile(StartX, StartY);
            floorPlan.setTargetTile(TargetX, TargetY);

            String TargetString = TargetX + "_" + TargetY;

            QGPathFinder qgpf = new QGPathFinder(floorPlan);

            //show neighbors
            List<FloorTile> TargetNeighbors = floorPlan.getTargetTile().getNeighbours();
            String neighborString = "";
            for (int i = 0; i < TargetNeighbors.Count; i++)
            {
                neighborString = TargetNeighbors[i].Position.X + "_" + TargetNeighbors[i].Position.Y;

                //tw.WriteLine("Target Neighbors: " + neighborString + ": " + isContainEdge);
            }

            List<FloorTile> actual;
            actual = qgpf.getPath();

            tw.WriteLine(qgpf.GetMessages());
            tw.Close();

            visualizeFloorPlan(floorPlan, StartX, StartY, TargetX, TargetY);

            List<FloorTile> expected = new List<FloorTile>();
            FloorTile t1 = new FloorTile(0, 0, true, floorPlan);
            FloorTile t2 = new FloorTile(0, 1, true, floorPlan);
            FloorTile t3 = new FloorTile(0, 2, true, floorPlan);
            expected.Add(t1);
            expected.Add(t2);
            expected.Add(t3);
            //String actualString = actual[1].Position.X + "," + actual[1].Position.Y;
            //String expectedString = expected[1].Position.X + "," + expected[1].Position.Y;

            //Assert.AreEqual(expectedString, actualString);
        }
Example #4
0
        /// <summary>
        ///get executing time for a path
        ///</summary>
        public void visualizeFloorPlan(FloorPlan floorPlan, int StartX, int StartY, int TargetX, int TargetY)
        {
            floorPlan.setStartTile(StartX, StartY);
            floorPlan.setTargetTile(TargetX, TargetY);
            QGPathFinder target = new QGPathFinder(floorPlan);
            List<FloorTile> actual;

            actual = target.getPath();

            Form f = new WindowsFormsApplication1.Form1(floorPlan, actual);
            Application.Run(f);

            //f.Invoke();
            //f.Draw(floorPlan, actual);
        }