Ejemplo n.º 1
0
        private void sToolStripMenuItem_Click(object sender, EventArgs e)
        {
            visibilityGraphToolStripMenuItem_Click(null, null);
            Wall       wall   = (Wall)_graphObjects.Where(s => s is Wall).First();
            RectangleF bounds = wall.getBounds();
            Bitmap     bitmap = pictureBoxMain.Image as Bitmap;
            Graphics   g      = setupGraphic(bitmap, bounds);

            VisibilityGraph vg = new VisibilityGraph();

            vg.addObjects(_graphObjects);
            vg.Goal  = _goal;
            vg.Start = _start;
            NodeGraph ng = new NodeGraph();

            foreach (LineSegment line in vg.getVisibilityGraph())
            {
                ng.addLine(line);
            }
            Node start = new Node();

            start.Location = _start;
            Node goal = new Node();

            goal.Location = _goal;
            Node solution = Djikstra.ShortestPath(ng, start, goal);

            ScaledDrawer.drawShortestPath(g, _shortestPathPen, solution, _scale);
            pictureBoxMain.Image = bitmap;
            Driver driver = new Driver(solution);

            System.Threading.Thread tr = new System.Threading.Thread(driver.followPathToGoal);
            tr.Start();
        }
Ejemplo n.º 2
0
        public void visibilityGraphToolStripMenuItem_Click(object sender, EventArgs e)
        {
            grownObstaclesToolStripMenuItem_Click(null, null);
            Wall       wall   = (Wall)_graphObjects.Where(s => s is Wall).First();
            RectangleF bounds = wall.getBounds();
            Bitmap     bitmap = pictureBoxMain.Image as Bitmap;
            Graphics   g      = setupGraphic(bitmap, bounds);

            ScaledDrawer.drawBoxedPoint(g, _positionPen, _start, _scale);

            ScaledDrawer.drawBoxedPoint(g, _positionPen, _goal, _scale);

            VisibilityGraph vg = new VisibilityGraph();

            vg.addObjects(_graphObjects);
            vg.Goal  = _goal;
            vg.Start = _start;
            try
            {
                vg.drawVisibilityGraph(g, _scale);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            pictureBoxMain.Image = bitmap;
        }