public IEnumerable <Triangle.Edge> GenerateEdgesFromDelaunay(List <Triangle> triangulation) { var voronoiEdges = new List <Triangle.Edge>(); foreach (Triangle triangle1 in triangulation) { foreach (Triangle triangle2 in triangulation) { if (!triangle1.Equals(triangle2)) { if (triangle1.SharesEdgeWith(triangle2)) { var edge = new Triangle.Edge(triangle1.Circumcenter(), triangle2.Circumcenter()); voronoiEdges.Add(edge); } } } } return(voronoiEdges); }
public static void Main(string[] args) { MyForm myform = new MyForm(); myform.Text = "Main Window"; myform.Size = new Size(1280, 720); myform.FormBorderStyle = FormBorderStyle.FixedDialog; myform.StartPosition = FormStartPosition.CenterScreen; myform.MaximizeBox = false; //myform.WindowState = FormWindowState.Maximized; BowyerWatson bw = new BowyerWatson(myform.Width, myform.Height); List <Triangle> triangulation = bw.BW_method(); myform.randomPoints = bw.pointList; myform.triangles = triangulation; Voronoi v = new Voronoi(); IEnumerable <Triangle.Edge> realEdges = v.GenerateEdgesFromDelaunay(triangulation); myform.edges = realEdges.ToList(); myform.voronoiCells = v.GetVoronoiCells(bw.pointList, triangulation).ToList(); Graphics g = myform.CreateGraphics(); myform.ShowDialog(); Triangle.Edge e1 = new Triangle.Edge(new Triangle.Point(1, 1), new Triangle.Point(2, 2)); Triangle.Edge e2 = new Triangle.Edge(new Triangle.Point(2, 2), new Triangle.Point(1, 1)); HashSet <Triangle.Edge> e = new HashSet <Triangle.Edge>(); e.Add(e2); e.Add(e1); }