예제 #1
0
        // *** private methodes - random points obs ****

        // ********** Private methodes (open,save...) ********

        private void openTextFile()
        {
            _stage = 0;
            OpenFileDialog d  = new OpenFileDialog();
            DialogResult   dr = d.ShowDialog();

            if (dr != DialogResult.OK)
            {
                return;
            }

            string fi = d.FileName;

            _clients = null;
            _guards  = null;

            if (!string.IsNullOrEmpty(fi)) // the user actualy choose a file.
            {
                try
                {
                    _ajd    = new Delaunay_Triangulation(fi);
                    _dx_map = new Point_dt(_ajd.minBoundingBox().x, _ajd.maxBoundingBox().x);
                    _dy_map = new Point_dt(_ajd.minBoundingBox().y, _ajd.maxBoundingBox().y);

                    Refresh();
                }
                catch (Exception e)  // in case something went wrong.
                {
                    Console.WriteLine("** Error while reading text file **");
                    Console.WriteLine(e);
                }
            }
        }
예제 #2
0
        public AbstractComposite build(Coordinates coord)
        {
            ICoordinateValidator         cv         = new DelaunayCoordinateValidator(coord);
            Delaunay_Triangulation       dt         = new Delaunay_Triangulation();
            DelaunayTriangulationManager tesselator = new DelaunayTriangulationManager(cv, dt);

            return((Shape)tesselator.buildDrawable());
        }
예제 #3
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);
        }
예제 #4
0
 public MainForm(Delaunay_Triangulation aj)
 {
     this.Text = "ajDelaunay GUI tester";
     this.Size = new Size(550, 550);
     _stage    = 0;
     _ajd      = aj;
     _dx_f     = new Point_dt(5, this.Width - 5);
     _dy_f     = new Point_dt(5, this.Height - 5);
     _dx_map   = new Point_dt(aj.maxBoundingBox().x, aj.minBoundingBox().x);
     _dy_map   = new Point_dt(aj.maxBoundingBox().y, aj.minBoundingBox().y);
     _clients  = null;
     _guards   = null;
     //addWindowListener(new WindowAdapter() {
     //    public void windowClosing(WindowEvent e) {
     //        System.exit(0);
     //    }
     //});
 }
예제 #5
0
        private Visibility _los;// , _section2;


        // *** text area ***
        public MainForm()
        {
            InitializeComponent();

            this.Text           = "Delaunay GUI tester";
            this.Size           = new Size(500, 500);
            this.BackColor      = Color.White;
            _stage              = 0;
            _ajd                = new Delaunay_Triangulation();
            _ajd.PotentialBbMax = new Point_dt(this.Width, this.Height);

            _dx_f   = new Point_dt(10, this.Width - 10);
            _dy_f   = new Point_dt(55, this.Height - 10);
            _dx_map = new Point_dt(_dx_f);
            _dy_map = new Point_dt(_dy_f);

            //addWindowListener(new WindowAdapter() {
            //    public void windowClosing(WindowEvent e) {
            //        System.exit(0);
            //    }
            //});
        }
예제 #6
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();
            }
        }
예제 #7
0
파일: Visibility.cs 프로젝트: VKaban/jdt
 public Visibility(Delaunay_Triangulation dt)
 {
     _dt      = dt;
     _section = new List <Point_dt>();
 }