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); }
void MainForm_Click(object sender, MouseEventArgs e) { int xx = e.X; int yy = e.Y; switch (_stage) { case 0: { Console.WriteLine("[" + xx + "," + yy + "]"); break; } case POINT: { Point_dt q = new Point_dt(xx, yy); Point_dt p = screen2world(q); _ajd.insertPoint(p); Refresh(); break; } case FIND: { Point_dt q = new Point_dt(xx, yy); Point_dt p = screen2world(q); //_t1 = _ajd.find(p); _t1 = _ajd.FastFind(p); Refresh(); break; } case SECTION1: { Point_dt q = new Point_dt(xx, yy); _p1 = screen2world(q); // _p1 = new Point_dt(99792.03,1073355.0,30.0); // _t1 = _ajd.find(_p1); _stage = SECTION2; break; } case SECTION2: { Point_dt q = new Point_dt(xx, yy); _p2 = screen2world(q); // _p2 = new Point_dt(149587.055,1040477.0,5.0); // _t2 = _ajd.find(_p2); _los = new Visibility(_ajd); _los.computeSection(_p1, _p2); Refresh(); _stage = SECTION1; break; } case GUARD: { Point_dt q = new Point_dt(xx, yy); _p1 = screen2world(q); if (_guards == null) { _guards = new List <Point_dt>(); } _guards.Add(new Point_dt(_p1.x, _p1.y, GH)); /* * if(_p2!=null) { _los = new Visibility(_ajd); * _los.computeSection(_p1,_p2); _visible = * _los.isVisible(30,5); } */ Refresh(); break; } case CLIENT: { Point_dt q = new Point_dt(xx, yy); _p2 = screen2world(q); if (_clients == null) { _clients = new List <Point_dt>(); } _clients.Add(new Point_dt(_p2.x, _p2.y, CH)); /* * if(_p1!=null) { _los = new Visibility(_ajd); * _los.computeSection(_p1,_p2); _visible = * _los.isVisible(30,5); } */ Refresh(); break; } } }