Пример #1
0
        private void draw_btn_Click(object sender, EventArgs e)
        {
            g.Clear(Color.White);
            g1.Clear(Color.White);
            if (radioButton1.Checked)
            {
                p = new Tetrahedron();
            }
            else if (radioButton2.Checked)
            {
                p = new Hexahedron();
            }
            else if (radioButton3.Checked)
            {
                p = new Octahedron();
            }

            cam_p = p.DeepCopy();
            p.Draw(g);
            DrawCameraFigure();
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string   data   = File.ReadAllText(openFileDialog1.FileName);
            Figure3D figure = new Figure3D();

            figure.Sides = new List <Figure>();

            var rows = data.Split('\n');

            foreach (string row in rows)
            {
                string[]        strPoints = row.Split(' ');
                List <PointXYZ> pts       = new List <PointXYZ>();

                if (strPoints.Length > 0)
                {
                    for (int i = 0; i < strPoints.Length - 1; i += 3)
                    {
                        float x, y, z;
                        x = (float)Convert.ToDouble(strPoints[i]);
                        y = (float)Convert.ToDouble(strPoints[i + 1]);
                        z = (float)Convert.ToDouble(strPoints[i + 2]);

                        pts.Add(new PointXYZ(x, y, z));
                    }
                    figure.Sides.Add(new Figure(pts));
                    pts.Clear();
                }
            }
            figure.UpdateCenter();
            g.Clear(Color.White);
            g1.Clear(Color.White);
            p     = figure;
            cam_p = p.DeepCopy();
            p.Draw(g);
            DrawCameraFigure();
        }