示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            sheet.Image = G.GetBitmap();

            Triangle tr = new Triangle(new Vertex(125, 125), new Vertex(350, 300), new Vertex(125, 84));

            G.BrushTriangle(tr);
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool flagempty = true;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells[2].Value == null || dataGridView1.Rows[i].Cells[3].Value == null)
                {
                    flagempty = false;
                }
            }

            if (flagempty)
            {
                DelaunayTriangulator.Triangulator  triangulate = new DelaunayTriangulator.Triangulator();
                List <DelaunayTriangulator.Vertex> listvertex  = new List <DelaunayTriangulator.Vertex>();


                for (int i = 0; i < graph.verteex.Count; i++)
                {
                    listvertex.Add(graph.verteex[i]);

                    //дописать tryparse-условие
                    float x = Convert.ToSingle(dataGridView1.Rows[i].Cells[2].Value.ToString());
                    float y = Convert.ToSingle(dataGridView1.Rows[i].Cells[3].Value.ToString());
                    listvertex[i].Vector = new Vector(x, y);
                }

                List <DelaunayTriangulator.Triangle> tr = triangulate.Triangulation(listvertex);

                Program.monitor = new Monitoring(tr);

                Program.monitor.GetArrayOfOutsideEdge();
                Program.monitor.AllDensities();
                Stopwatch sp = new Stopwatch();
                sp.Start();

                sp.Stop();

                foreach (Triangle t in Program.monitor.triangles)
                {
                    G.BrushTriangle(t);
                    richTextBox1.Text += t.ToString();
                }

                foreach (DelaunayTriangulator.Triangle t in tr)
                {
                    G.drawTriangle(t);
                }

                //переписать не под вызов конструктора, а под вызов метода, который будет сравнивать треугольники.
                //т.е. Equals для треугольников, который сравнивает по вершинам.


                MessageBox.Show(sp.Elapsed.Milliseconds.ToString());

                foreach (DelaunayTriangulator.Triangle t in tr)
                {
                    for (int i = 0; i < t.edgemas.Length; i++)
                    {
                        if (t.edgemas[i].isOuside)
                        {
                            G.drawEdge(t.edgemas[i]);
                        }
                        //if (t.edgemas[i].brother != null) G.drawEdge(t.edgemas[i].brother, new Pen(Color.Aqua));
                    }
                    G.drawVector(t);
                }



                sheet.Image = G.GetBitmap();
            }
            else
            {
                MessageBox.Show("Заполните значения векторов", "Ошибка заполнения");
            }
        }