/// <summary> /// Constructor of Points grid. Doesn't call Precalculate! /// </summary> /// <param name="matrixSize">at least 2</param> public PointsGridDT(int matrixSize) { if (matrixSize < 2) { throw new ArgumentException("matrixSize must be greater than 1"); } _matrixSize = matrixSize; _points2Triangles = new Dictionary <Point_dt, Triangle_dt>(_matrixSize * _matrixSize); DelaunayTriangulation = null; }
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); // } //}); }
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); }
// *** 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); // } //}); }
// *** 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); } } }
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(); } }
/// <summary> /// Constructor of Points grid. Doesn't call Precalculate! /// </summary> /// <param name="matrixSize">at least 2</param> /// <param name="delaunayTriangulation">triangulation to work on</param> public PointsGridDT(int matrixSize, Delaunay_Triangulation delaunayTriangulation) { _matrixSize = matrixSize; _points2Triangles = new Dictionary<Point_dt, Triangle_dt>(_matrixSize * _matrixSize); DelaunayTriangulation = delaunayTriangulation; }
/// <summary> /// Constructor of Points grid. Doesn't call Precalculate! /// </summary> /// <param name="matrixSize">at least 2</param> /// <param name="delaunayTriangulation">triangulation to work on</param> public PointsGridDT(int matrixSize, Delaunay_Triangulation delaunayTriangulation) { _matrixSize = matrixSize; _points2Triangles = new Dictionary <Point_dt, Triangle_dt>(_matrixSize * _matrixSize); DelaunayTriangulation = delaunayTriangulation; }
public Visibility(Delaunay_Triangulation dt) { _dt = dt; _section = new List<Point_dt>(); }