Пример #1
0
        static void DoTimeTest()
        {
            int    size = 100000, size2 = size;
            double delta = 1000, delta2 = delta / 2;

            double[]   xx  = new double[size], yy = new double[size];
            Point_dt[] ps  = new Point_dt[size];
            double[]   xx2 = new double[size2], yy2 = new double[size2];

            DateTime start            = DateTime.Now;
            Delaunay_Triangulation ad = new Delaunay_Triangulation();

            Random r = new Random();

            for (int i = 0; i < size; i++)
            {
                xx[i] = (r.NextDouble() * delta - (delta * 0.1));
                yy[i] = (r.NextDouble() * delta - (delta * 0.1));

                ps[i] = new Point_dt(xx[i], yy[i]);
                ad.insertPoint(ps[i]);
            }
            DateTime mid = DateTime.Now;

            for (int i = 0; i < size2; i++)
            {
                xx2[i] = (r.NextDouble() * delta2);
                yy2[i] = (r.NextDouble() * delta2);
            }
            DateTime m1 = DateTime.Now;

            for (int i = 0; i < size2; i++)
            {
                Point_dt    p  = new Point_dt(xx2[i], yy2[i]);
                Triangle_dt t1 = ad.find(p);
                if (!t1.contains(p))
                {
                    Console.WriteLine(i + ") **ERR: find *** T: " + t1);
                }
            }
            DateTime e1 = DateTime.Now;

            Console.WriteLine("delaunay_triangulation " + ad.size() + " points, "
                              + ad.trianglesSize() + " triangles,  Triangles_td: "
                              + Triangle_dt._counter + "  ,c2: " + Triangle_dt._c2);
            Console.WriteLine("Constructing time: " + (mid - start).TotalSeconds);
            Console.WriteLine("*** E3 find:  time: " + (e1 - m1).TotalSeconds);
            Console.WriteLine("delaunay_triangulation " + ad.size() + " points, "
                              + ad.trianglesSize() + " triangles,  Triangles_td: "
                              + Triangle_dt._counter + "  ,c2: " + Triangle_dt._c2);
        }
Пример #2
0
        void MainMenuClick(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi == null)
            {
                throw new Exception("MainMenuClick");
            }

            string arg = mi.Text;

            if (arg.Equals("Open"))
            {
                openTextFile();
            }
            else if (arg.Equals("Save tsin"))
            {
                saveTextFile();
            }
            else if (arg.Equals("Save smf"))
            {
                saveTextFile2();
            }
            else if (arg.Equals("Lines"))
            {
                this._view_flag = VIEW1;
                Refresh();
            }
            else if (arg.Equals("Triangles"))
            {
                this._view_flag = VIEW2;
                Refresh();
            }
            else if (arg.Equals("Topo"))
            {
                this._view_flag = VIEW3;
                Refresh();
            }
            else if (arg.Equals("Clear"))
            {
                _ajd     = new Delaunay_Triangulation();
                _dx_map  = new Point_dt(_dx_f);
                _dy_map  = new Point_dt(_dy_f);
                _clients = null;
                _guards  = null;
                _mc      = 0;
                Refresh();
            }
            else if (arg.Equals("Exit"))
            {
                Application.Exit();
            }

            else if (arg.Equals("Point"))
            {
                _stage = POINT;
            }
            else if (arg.Equals("CH"))
            {
                _ajd.CH_vertices_Iterator();
            }
            else if (arg.Equals("100-rand-ps"))
            {
                Random r = new Random();
                double x0 = 10, y0 = 60, dx = this.Width - x0 - 10, dy = this.Height - y0 - 10;
                for (int i = 0; i < 100; i++)
                {
                    double   x = r.NextDouble() * dx + x0;
                    double   y = r.NextDouble() * dy + y0;
                    Point_dt q = new Point_dt(x, y);
                    Point_dt p = screen2world(q);
                    _ajd.insertPoint(p);
                }

                Refresh();
            }
            else if (arg.Equals("Find"))
            {
                _stage = MainForm.FIND;
            }
            else if (arg.Equals("Section"))
            {
                _stage = MainForm.SECTION1;
            }
            else if (arg.Equals("Client-5m"))
            {
                // Console.WriteLine("CL!");
                _stage = MainForm.CLIENT;
            }
            else if (arg.Equals("Guard-30m"))
            {
                _stage = MainForm.GUARD;
            }
            else if (arg.Equals("Info"))
            {
                string ans = "" + _ajd.GetType().FullName
                             + "  # vertices:" + _ajd.size() + "  # triangles:"
                             + _ajd.trianglesSize();
                ans += "   min BB:" + _ajd.minBoundingBox() + "   max BB:"
                       + _ajd.maxBoundingBox();
                Console.WriteLine(ans);
                Console.WriteLine();
            }
        }