Esempio n. 1
0
        public static GraphManager <PointI> CreatePolygonGridManager(
            GraphDialog dialog, RegularPolygon polygon)
        {
            int         width = 20, height = 20;
            PolygonGrid grid = new PolygonGrid(polygon);

            grid.Size = new SizeI(width, height);

            // shrink grid until it fits in output box
            double outputWidth  = dialog.OutputBox.Width - 16;
            double outputHeight = dialog.OutputBox.Height - 16;

            while (grid.DisplayBounds.Width > outputWidth)
            {
                grid.Size = new SizeI(--width, height);
            }
            while (grid.DisplayBounds.Height > outputHeight)
            {
                grid.Size = new SizeI(width, --height);
            }

            var manager = new GraphManager <PointI>(dialog, 4);

            manager.Graph    = grid;
            manager.Renderer = new GraphRenderer <PointI>(manager);
            return(manager);
        }
Esempio n. 2
0
        private GraphManager(GraphDialog dialog, int maxCost)
        {
            Dialog  = dialog;
            MaxCost = maxCost;

            Locations  = new List <T>();
            Highlights = new List <T>(2);
        }
Esempio n. 3
0
        private void GraphCommandExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            args.Handled = true;
            Window dialog = new GraphDialog()
            {
                Owner = this
            };

            dialog.ShowDialog();
        }
Esempio n. 4
0
        public static GraphManager <PointD> CreateSubdivisionManager(GraphDialog dialog)
        {
            RectD output = new RectD(0, 0, dialog.OutputBox.Width, dialog.OutputBox.Height);
            RectD bounds = new RectD(8, 8, output.Width - 16, output.Height - 16);

            PointD[] points = GeoAlgorithms.RandomPoints(40, bounds, new PointDComparerX(), 20);

            VoronoiResults results  = Voronoi.FindAll(points, output);
            Subdivision    division = results.ToDelaunySubdivision(output, true);

            var manager = new GraphManager <PointD>(dialog, 8);

            manager.Graph    = division;
            manager.Renderer = new GraphRenderer <PointD>(manager);

            // scaling factor to keep step costs above node distance
            manager._scaleCost = output.Width + output.Height;
            return(manager);
        }