Example #1
0
 void listBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (sender == listBox1)
     {
         all.vec3 p = harr.points[listBox1.SelectedIndex];
         all.harrpoint = all.v3(p);
         textBox1.Text = p.x + " " + p.y + " " + p.z;
     }
     else if (sender == listBox2)
     {
         int[] l = harr.lines[listBox2.SelectedIndex];
         all.harrpoint = all.v3(
             (harr.points[l[0]].x + harr.points[l[1]].x) / 2,
             (harr.points[l[0]].y + harr.points[l[1]].y) / 2,
             (harr.points[l[0]].z + harr.points[l[1]].z) / 2
             );
         textBox2.Text = l[0] + " " + l[1];
     }
     else if (sender == listBox3)
     {
         int[] t = harr.tris[listBox3.SelectedIndex];
         all.harrpoint = all.v3(
             (harr.points[t[1]].x + harr.points[t[2]].x + harr.points[t[3]].x) / 3,
             (harr.points[t[1]].y + harr.points[t[2]].y + harr.points[t[3]].y) / 3,
             (harr.points[t[1]].z + harr.points[t[2]].z + harr.points[t[3]].z) / 3
             );
         textBox3.Text = t[0] + " " + t[1] + " " + t[2] + " " + t[3];
     }
     panel1.Refresh();
 }
Example #2
0
 void abutton_Click(object sender, EventArgs e)
 {
     if (sender == abutton1)
     {
         all.vec3[] pts = new all.vec3[harr.points.Length + 1];
         int        i;
         for (i = 0; i < harr.points.Length; i++)
         {
             pts[i] = all.v3(harr.points[i]);
         }
         pts[harr.points.Length] = all.v3(harr.points[i - 1]);
         harr.points             = pts;
         refreshLists();
         listBox1.SelectedIndex = i;
     }
     else if (sender == abutton2)
     {
         int[][] lines = new int[harr.lines.Length + 1][];
         int     i;
         for (i = 0; i < harr.lines.Length; i++)
         {
             lines[i] = new int[] { harr.lines[i][0], harr.lines[i][1] };
         }
         lines[i]   = new int[] { harr.lines[i - 1][0], harr.lines[i - 1][1] };
         harr.lines = lines;
         refreshLists();
         listBox2.SelectedIndex = i;
     }
     else if (sender == abutton3)
     {
         int[][] tris = new int[harr.tris.Length + 1][];
         int     i;
         for (i = 0; i < harr.tris.Length; i++)
         {
             tris[i] = new int[] { harr.tris[i][0], harr.tris[i][1],
                                   harr.tris[i][2], harr.tris[i][3] };
         }
         tris[i] = new int[] { harr.tris[i - 1][0], harr.tris[i - 1][1],
                               harr.tris[i - 1][2], harr.tris[i - 1][3] };
         harr.tris = tris;
         refreshLists();
         listBox3.SelectedIndex = i;
     }
 }