Пример #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     points.Clear();
     selectedTriangule = null;
     if (triangulated != null)
     {
         triangulated.Clear();
     }
     Refresh();
 }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)//generar puntos aleatorios
        {
            Random randomizer = new Random();
            int    count      = randomizer.Next(25) + 3;

            points.Clear();
            for (int i = 0; i < count; i++)
            {
                points.Add(new Point2D(r.Next(0, pictureBox1.Width), r.Next(0, pictureBox1.Height)));
            }
            selectedTriangule = null;
            Refresh();
        }
Пример #3
0
 private void button2_Click(object sender, EventArgs e)//triangular
 {
     if (points.Count > 2)
     {
         selectedTriangule = null;
         delaunay          = new DelaunayTriangulation(points);
         triangulated      = delaunay.Triangulate();
         if (checkBox1.Checked)
         {
             triangulatedWithCircles = delaunay.GetCircumcicles(triangulated);
         }
         Refresh();
     }
 }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)//generar puntos aleatorios
        {
            if (textBox1.Text == null || textBox1.Text.Length == 0)
            {
                MessageBox.Show("Debe escribir la cantidad de puntos aleatorios a generar");
                return;
            }
            int count = 0;

            if (!int.TryParse(textBox1.Text, out count))
            {
                MessageBox.Show("Debe escribir correctamente un número entero");
                return;
            }
            points.Clear();
            for (int i = 0; i < count; i++)
            {
                points.Add(new Point2D(r.Next(0, pictureBox1.Width), r.Next(0, pictureBox1.Height)));
            }
            selectedTriangule = null;
            Refresh();
        }
Пример #5
0
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         released = true;
         if (!moved && checkBox2.Checked)
         {
             button2_Click(null, null);
         }
         else
         {
             Refresh(); moved = false;
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (selectedTriangule == null)
         {
             Rect rab, rbc, rca;
             foreach (Triangule t in triangulated)
             {
                 rab = delaunay.GetRectEcuation(t.a, t.b);
                 rbc = delaunay.GetRectEcuation(t.b, t.c);
                 rca = delaunay.GetRectEcuation(t.c, t.a);
                 if ((rab.Eval(e.X) <= e.Y && rbc.Eval(e.X) >= e.Y && rca.Eval(e.X) <= e.Y) || ((rab.Eval(e.X) >= e.Y && rbc.Eval(e.X) <= e.Y && rca.Eval(e.X) >= e.Y)))
                 {
                     selectedTriangule = t;
                     break;
                 }
             }
         }
         else
         {
             selectedTriangule = null;
         }
         Refresh();
     }
 }