Exemple #1
0
        // Runs a specific Voronoi Generation test and returns the time it took
        // to complete.
        static long RunTests(int trial, int numPoints, int max, TestMode t)
        {
            Stopwatch    timer = new Stopwatch();
            List <Point> sites = Point.GetRandomPoints(numPoints, 0, max);

            if (t == TestMode.BOWYER_WATSON)
            {
                timer.Start();
                DelaunayTriangulator generator = new DelaunayTriangulator(sites);
                generator.GenerateVoronoi();
                timer.Stop();
            }
            else
            {
                timer.Start();
                BruteForceVoronoi generator = new BruteForceVoronoi(sites);
                generator.GenerateVoronoi();
                timer.Stop();
            }

            long elapsed = timer.ElapsedMilliseconds;

            Console.WriteLine(trial + "\t\t" + numPoints + "\t\t" + max + "\t\t" + elapsed);
            return(elapsed);
        }
Exemple #2
0
        // Renders a diagram based off of random points.
        // Uses same points with both methods.
        public static void RenderSameDiagram()
        {
            List <Point> points = Point.GetRandomPoints(numPointsForPic, 0, rangeForPic);

            DelaunayTriangulator tri           = new DelaunayTriangulator(points);
            VoronoiDiagram       voroEfficient = tri.GenerateVoronoi();


            BruteForceVoronoi voroBrute = new BruteForceVoronoi(points);

            voroBrute.GenerateVoronoi();

            RenderConfig config = voroBrute.FullFrameConfig;

            config.xPadding += 50;
            config.yPadding += 50;

            VoronoiRenderer.DrawDiagram(voroEfficient, config, "bowyer_output.bmp");
            VoronoiRenderer.DrawTriangulation(tri.WithoutSupertriangle(), config, "bowyer_triangulation_no_super.bmp");
            VoronoiRenderer.DrawTriangulation(tri, config, "bowyer_triangulation_super.bmp");

            VoronoiRenderer.DrawDiagram(voroBrute, config, "brute_force_output.bmp");
        }