Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            if (figType != "" && textBox1.Text != "")//&& mode == "")
            {
                switch (figType)
                {
                case "Тетраэдр":
                    figure = new Polyhedron(PolyhedronType.Tetrahedron, int.Parse(textBox1.Text));
                    break;

                case "Гексаэдр":
                    figure = new Polyhedron(PolyhedronType.Hexahedron, int.Parse(textBox1.Text));
                    break;

                case "Октаэдр":
                    figure = new Polyhedron(PolyhedronType.Octahedron, int.Parse(textBox1.Text));
                    break;
                }
                DrawPolyhedron(figure, pictureBox1.Size);
                pictureBox1.Invalidate();
            }
        }
Example #2
0
 public Polyhedron(Polyhedron figure)
 {
 }
Example #3
0
 public Lab7task3()
 {
     InitializeComponent();
     figure = new Polyhedron();
 }
Example #4
0
 public Lab7task3(Form1 parent)
 {
     this.parent = parent;
     InitializeComponent();
     figure = new Polyhedron();
 }
Example #5
0
        private void ReadPolyhedronFromFile(string filepath)
        {
            var edgesLines      = File.ReadAllLines(filepath);
            int edgeVertexCount = edgesLines[0].Split('|').Length - 1;
            var edgesPoints     = new Point3D[edgesLines.Length, edgeVertexCount];

            for (int i = 0; i < edgesLines.Length; ++i)
            {
                for (int j = 0; j < edgeVertexCount; ++j)
                {
                    edgesPoints[i, j] = new Point3D();
                }
            }
            var edgesAdjacentPoints = new List <AdjacentPoints> [edgesLines.Length];

            for (int i = 0; i < edgesLines.Length; ++i)
            {
                edgesAdjacentPoints[i] = new List <AdjacentPoints>();
            }
            for (int i = 0; i < edgesLines.Length; ++i)
            {
                var edgeInfo = SplitEdgeInfo(edgesLines[i]);
                ParseEdge(edgeInfo.Item1, i, edgesPoints);
                foreach (var adjacentEdgeInfo in edgeInfo.Item2.Split('E'))
                {
                    if (adjacentEdgeInfo != "")
                    {
                        edgesAdjacentPoints[i].Add(ParseAdjacentPoints(adjacentEdgeInfo, i));
                    }
                }
            }
            AddAdjacentNeighbours(edgesPoints, edgesAdjacentPoints);
            figure = BuildPolyhedronFromPoints(edgesPoints);
            var testList = new List <Tuple <double, double, double> >();

            /*testList.Add(new Tuple<double, double, double>(1, 0, 2));
            *  testList.Add(new Tuple<double, double, double>(2, 0, 1));
            *  testList.Add(new Tuple<double, double, double>(1, 1, 3));*/
            figure.vertexes = figure.vertexes.OrderBy(v => new Tuple <double, double, double>(v.X, v.Y, v.Z))
                              .ThenByDescending(v => v.Neighbours.Count).ToList();
            var lastVertex  = figure.vertexes.First();
            var newVertexes = new List <Point3D>();

            for (int i = 0; i < figure.vertexes.Count; ++i)
            {
                if (figure.vertexes[i].X != lastVertex.X || figure.vertexes[i].Y != lastVertex.Y || figure.vertexes[i].Z != lastVertex.Z)
                {
                    lastVertex.Neighbours = lastVertex.Neighbours.GroupBy(x => new Tuple <double, double, double>(x.X, x.Y, x.Z)).Select(x => x.First()).ToList();
                    newVertexes.Add(lastVertex);
                    lastVertex = figure.vertexes[i];
                }
                else if (lastVertex != figure.vertexes[i])
                {
                    foreach (var neighbour in figure.vertexes[i].Neighbours)
                    {
                        lastVertex.Neighbours.Add(neighbour);
                    }
                }
            }
            newVertexes.Add(lastVertex);
            figure.CountVertex = figure.vertexes.GroupBy(x => Tuple.Create(x.X, x.Y, x.Z)).Count();
            foreach (var v in newVertexes)
            {
                for (int i = 0; i < v.Neighbours.Count; ++i)
                {
                    v.Neighbours[i] = newVertexes.Find(vx => vx.X == v.Neighbours[i].X && vx.Y == v.Neighbours[i].Y && vx.Z == v.Neighbours[i].Z);
                }
            }
            figure.vertexes = newVertexes;
        }
Example #6
0
 public void getFigureFromChild(Polyhedron p)
 {
     figure = p;
 }