Esempio n. 1
0
 public PlanningForm(PathPlanningGraph graph, HexagonalMap map, Agent agent, HexaPos startPos, HexagonalMapDrawer mapDrawer, HexaPath humanPath = null)
 {
     _graph      = graph;
     _map        = map;
     _mapDrawer  = mapDrawer;
     _agent      = agent;
     _startPos   = startPos;
     _humanPath  = humanPath;
     _planMethod = planMethod.UNKNOWN;
     InitializeComponent();
 }
Esempio n. 2
0
        public SimTestForm(ParameterManager paramMgr)
        {
            _paramMgr   = paramMgr;
            _map        = new HexagonalMap(paramMgr.simTestWidth, paramMgr.simTestHeight, paramMgr.simTestSize, Hexagonal.HexOrientation.Pointy);
            _mapDrawer  = new HexagonalMapDrawer(_map, 5, 5);
            _human      = new Human(_map);
            _robot      = new Robot(_map);
            _planMethod = PlanningForm.planMethod.UNKNOWN;

            InitializeComponent();
        }
Esempio n. 3
0
        private void MapForm_Closing(object sender, FormClosingEventArgs e)
        {
            if (_mapDrawer != null)
            {
                _mapDrawer = null;
            }

            if (_map != null)
            {
                _map = null;
            }
        }
Esempio n. 4
0
        public MapForm(HexagonalMap map, ParameterManager paramMgr)
        {
            _map       = map;
            _mapDrawer = new HexagonalMapDrawer(_map, 20, 20);
            _paramMgr  = paramMgr;

            _formState = FormState.IDLE;

            _human = new Human(_map);
            _robot = new Robot(_map);

            InitializeComponent();

            transitTimer       = new Timer();
            transitTimer.Tick += new EventHandler(this.ShowSearchSpace);

            transitCurrentCnt = 0;
            _visGraphForm     = new VisibilityGraphForm(_map);
        }
Esempio n. 5
0
 public VisibilityGraphForm(HexagonalMap map)
 {
     _visibilityGraph = new VisibilityGraph(map);
     _graphDrawer     = new HexagonalMapDrawer(_visibilityGraph.VisGraph);
     InitializeComponent();
 }
Esempio n. 6
0
        private void mapViewOpenFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                workingPath = System.IO.Path.GetDirectoryName(this.mapViewOpenFileDialog.FileName);
                infoMgr.LoadFile(this.mapViewOpenFileDialog.FileName);

                this.mapFilepath = System.IO.Path.Combine(workingPath, infoMgr.mapFilename);

                this.pixelMap = new PixelMap.PixelMap(this.mapFilepath);
                //this.mapViewPictureBox.BackgroundImage = this.pixelMap.GreyMap;
                this.mapViewPictureBox.BackgroundImage = this.pixelMap.GetTransparentMap(50);
                this.mapViewPictureBox.Size            = new Size(this.pixelMap.Header.Width, this.pixelMap.Header.Height);
                this.mapViewPanel.Size            = this.mapViewPictureBox.Size;
                this.mapViewPanel.AutoScroll      = true;
                this.toolbarForm.Visible          = true;
                this.mapToolStripMenuItem.Checked = true;

                this.saveToolStripMenuItem.Enabled = true;

                this.widthNum  = (int)this.pixelMap.Header.Width / (paramMgr.hexagonalSize);
                this.heightNum = (int)(this.pixelMap.Header.Height / (Math.Sqrt(2) * paramMgr.hexagonalSize / 2));

                this.map       = new HexagonalMap(this.widthNum, this.heightNum, paramMgr.hexagonalSize, HexOrientation.Pointy);
                this.mapDrawer = new HexagonalMapDrawer(this.map);

                Random rnd = new Random();
                for (int i = 0; i < this.widthNum; i++)
                {
                    for (int j = 0; j < this.heightNum; j++)
                    {
                        //this.map.MapState.hexVals[i, j] = rnd.NextDouble();
                        this.map.MapState.hexVals[i, j] = this.infoMgr.GetDiffusionValue(i, j);
                    }
                }

                this.map.MapState.NormalizeHexVal();
                //this.map.MapState.DumpHexValToFile("test.csv");

                for (int i = 0; i < this.widthNum; i++)
                {
                    for (int j = 0; j < this.heightNum; j++)
                    {
                        this.map.GetMapStateMgr().SetEntropy(i, j, this.map.MapState.hexVals[i, j]);
                    }
                }

                /*
                 * for (int i = 0; i < this.pixelMap.BitMap.Width; i++)
                 * {
                 *  for (int j = 0; j < this.pixelMap.BitMap.Height; j++)
                 *  {
                 *      Color c = this.pixelMap.BitMap.GetPixel(i, j);
                 *      Console.WriteLine("[" + i.ToString() + "," + j.ToString() + "]:" + c.R.ToString() + " " + c.G.ToString() + " " + c.B.ToString());
                 *
                 *  }
                 * }
                 */

                for (int i = 0; i < this.map.mapWidth; i++)
                {
                    for (int j = 0; j < this.map.mapHeight; j++)
                    {
                        List <System.Drawing.PointF> points = this.map.GetHex(i, j).inPointSet;
                        int obsCnt = 0;
                        List <System.Drawing.PointF> .Enumerator eP = points.GetEnumerator();
                        while (eP.MoveNext())
                        {
                            int tX = (int)System.Math.Floor(eP.Current.X);
                            int tY = (int)System.Math.Floor(eP.Current.Y);

                            int bW = this.pixelMap.BitMap.Width;
                            int bH = this.pixelMap.BitMap.Height;

                            if (tX > (bW - 1))
                            {
                                tX = bW - 1;
                            }
                            if (tY > (bH - 1))
                            {
                                tY = bH - 1;
                            }

                            Color tColor = this.pixelMap.BitMap.GetPixel(tX, tY);
                            if ((int)tColor.R < 200 || (int)tColor.G < 200 || (int)tColor.B < 200)
                            {
                                obsCnt++;
                            }
                        }

                        //if (obsCnt * 2 > points.Count)
                        if (obsCnt > 0)
                        {
                            this.map.mapState.AddObstalce(this.map.GetHex(i, j));
                        }
                    }
                }

                robot        = new Robot(map);
                this.pathMgr = new PathManager(map, infoMgr.mapFilename);
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }