Exemple #1
0
        private void calculation(NAngleEmprovedForm owner)
        {
            dataGridView1.RowCount = dataGridView1.RowCount + 1;
            accuracy = Convert.ToInt16(owner.GetAccuracy());

            cells.SetCellsHeight(owner.GetHeight());
            cells.SetAccuracy(accuracy);
            cells.Calculation();

            if (!cells.isAvailable())
            {
                string       reason       = "Степень - " + (dataGridView1.RowCount - 1) + " " + writeResults();
                DialogResult dialogResult = MessageBox.Show("Не было найдено решение для условий - " + reason +
                                                            Environment.NewLine + "Попробовать следущий шаг? (В противном случае, вычисления будут приостановлены)",
                                                            "Предупреждение", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    return;
                }
                else if (dialogResult == DialogResult.No)
                {
                    throw new ApplicationException();
                }
            }

            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0].Value = cells.GetRowsNumber() * cells.GetColumnsNumber(); // количество ячеек

            try { ResearchActions(); }
            catch (Exception)
            {
                MessageBox.Show("Невозможно построить сетку");
                return;
            }

            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[3].Value = Convert.ToDouble(dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[1].Value) -
                                                                            Convert.ToDouble(dataGridView1.Rows[0].Cells[1].Value); // Напряжение
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[4].Value = Convert.ToDouble(dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[1].Value) * 100 /
                                                                            Convert.ToDouble(dataGridView1.Rows[0].Cells[1].Value); // %

            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[5].Value = Convert.ToDouble(dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[2].Value) -
                                                                            Convert.ToDouble(dataGridView1.Rows[0].Cells[2].Value); // Деформация
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[6].Value = Convert.ToDouble(dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[2].Value) * 100 /
                                                                            Convert.ToDouble(dataGridView1.Rows[0].Cells[2].Value); // %
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[7].Value = cells.GetAnglesN();                                     // Количество углов

            if (owner.getAngleStart() == 3 || owner.getAngleStart() == 4 ||
                owner.getAngleEnd() == 3 || owner.getAngleEnd() == 4)
            {
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[8].Value = 0; // Угол отклонения
            }
            else
            {
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[8].Value = cellsDraw.GetDifflection(); // Угол отклонения
            }

            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[9].Value =
                (cells.GetCellsV() * 100) / FreeClass.body.GetV(); // Часть от объёма
        }
Exemple #2
0
        private void loopDifflection(NAngleEmprovedForm owner)
        {
            if (owner.getAngleStart() == 2 || owner.getAngleStart() == 3 || owner.getAngleStart() == 4 ||
                owner.getAngleEnd() == 2 || owner.getAngleEnd() == 3 || owner.getAngleEnd() == 4)
            {
                if (cells is CircleCells)
                {
                    circleDrawer = new CircleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, 0);
                }
                if (cells is RectangleCells)
                {
                    rectDrawer = new RectangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);
                }
                else if (cells is TriangleCells)
                {
                    triangleDrawer = new TriangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);
                }
                else
                {
                    cellsDraw = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, 0);
                }

                calculation(owner);
            }
            else
            {
                double DeflectionStart = owner.getDeflectionStart();
                double DeflectionEnd   = owner.getDeflectionEnd();
                double DeflectionStep  = owner.getDeflectionStep();

                if (DeflectionStart > DeflectionEnd && DeflectionStep < 0)
                {
                    for (double i = DeflectionStart; i >= DeflectionEnd; i = i + DeflectionStep)
                    {
                        cellsDraw = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, i);
                        //cells.SetCellsV((FreeClass.body.GetV() * i) / 100);
                        calculation(owner);
                    }
                }
                else if (DeflectionStart <= DeflectionEnd && DeflectionStep > 0)
                {
                    for (double i = DeflectionStart; i <= DeflectionEnd; i = i + DeflectionStep)
                    {
                        cellsDraw = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, i);
                        //cells.SetCellsV((FreeClass.body.GetV() * i) / 100);
                        calculation(owner);
                    }
                }
                else if (DeflectionStep == 0)
                {
                    cellsDraw = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, DeflectionStart);
                    //cells.SetCellsV((FreeClass.body.GetV() * DeflectionStart) / 100);
                    calculation(owner);
                }
                else
                {
                    throw new Exception();
                }
                //angle
                //calculation(owner);
            }
        }
Exemple #3
0
        /// <summary>
        /// Цикл по изменению количества углов
        /// </summary>
        /// <param name="matrixGrade">Степень матрицы</param>
        private void loopAngleNum(int matrixGrade, NAngleEmprovedForm owner)
        {
            int angleStart = owner.getAngleStart();
            int angeEnd    = owner.getAngleEnd();
            int angleStep  = owner.getAngleStep();

            /*cells = new NAngleCells(FreeClass.body);
             * cells.SetColumnsNumber(matrixGrade);
             * cells.SetRowsNumber(matrixGrade);*/

            if (angleStart > angeEnd && angleStep < 0)
            {
                for (int i = angleStart; i >= angeEnd; i = i + angleStep)
                {
                    if (i == 2)
                    {
                        cells = new CircleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                    }
                    else if (i == 3)
                    {
                        cells = new TriangleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                    }
                    else if (i == 4)
                    {
                        cells = new RectangleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                    }
                    else
                    {
                        cells = new NAngleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                        cells.SetAnglesN(i);
                    }
                    loopVolume(owner);
                }
            }
            else if (angleStart <= angeEnd && angleStep > 0)
            {
                for (int i = angleStart; i <= angeEnd; i = i + angleStep)
                {
                    if (i == 2)
                    {
                        cells = new CircleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                    }
                    else if (i == 3)
                    {
                        cells = new TriangleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                    }
                    else if (i == 4)
                    {
                        cells = new RectangleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                    }
                    else
                    {
                        cells = new NAngleCells(FreeClass.body);
                        cells.SetColumnsNumber(matrixGrade);
                        cells.SetRowsNumber(matrixGrade);
                        cells.SetAnglesN(i);
                    }
                    loopVolume(owner);
                }
            }
            else if (angleStep == 0)
            {
                if (angleStart == 2)
                {
                    cells = new CircleCells(FreeClass.body);
                    cells.SetColumnsNumber(matrixGrade);
                    cells.SetRowsNumber(matrixGrade);
                }
                else if (angleStart == 3)
                {
                    cells = new TriangleCells(FreeClass.body);
                    cells.SetColumnsNumber(matrixGrade);
                    cells.SetRowsNumber(matrixGrade);
                }
                else if (angleStart == 4)
                {
                    cells = new RectangleCells(FreeClass.body);
                    cells.SetColumnsNumber(matrixGrade);
                    cells.SetRowsNumber(matrixGrade);
                }
                else
                {
                    cells = new NAngleCells(FreeClass.body);
                    cells.SetColumnsNumber(matrixGrade);
                    cells.SetRowsNumber(matrixGrade);
                    cells.SetAnglesN(angleStart);
                }
                loopVolume(owner);
            }
            else
            {
                throw new Exception();
            }
            //ApplicationException
        }