Ejemplo n.º 1
0
        private void drawButton_Click(object sender, EventArgs e)
        {
            if (cells == null)
            {
                MessageBox.Show("Расчёты не были произведены. Невозможно построить ячеистую структуру");
                return;
            }

            if (FreeClass.bodyDrawer == null)
            {
                MessageBox.Show("Тело не было построенно. Невозможно построить ячеистую структуру");
                return;
            }

            if (!cells.isAvailable())
            {
                MessageBox.Show("Невозможно построить структуру. Проверьте вычисления");
                return;
            }

            if (loopBuildRadioButton.Checked)
            {
                DialogResult dialogResult = MessageBox.Show("Выбрано циклическое построение. Будет выполненно только одно " +
                                                            "построение (самое последнее). Продолжить?",
                                                            "Предупреждение", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            int angel = Convert.ToInt16(textBox6.Text);

            if (cells is CircleCells)
            {
                drawer = new CircleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, angel);
                drawer.SetCells((AbstractRelationAngle)cells);
            }
            else if (cells is TriangleCells)
            {
                triangleDrawer = new TriangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);
                triangleDrawer.SetCells((TriangleCells)cells);
            }
            else
            {
                drawer = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, angel);
                drawer.SetCells((AbstractRelationAngle)cells);
            }

            if (drawer != null)
            {
                FreeClass.cells = drawer; drawer.drawCells();
            }
            else
            {
                FreeClass.cells = triangleDrawer; triangleDrawer.drawCells();
            }
            //FreeClass.cells = drawer;
            //drawer.SetCells(cells); drawer.drawCells();
        }
Ejemplo n.º 2
0
        private void ResearchActions(AbstractNAngleDrawer cellsDraw, int i, int j)
        {
            //создаём исследование
            research = new Research(FreeClass.sldManager, FreeClass.bodyDrawer.GetFacesArray());
            research.CreateStudy();

            cellsDraw.SetCells(cells); cellsDraw.drawCells();

            //прикладываем силы или фиксируем грани
            foreach (object[] act in action)
            {
                if (act[0].Equals("fix"))
                {
                    research.BodyParts_Select((int)act[1]);
                    research.FixFace();
                }
                else if (act[0].Equals("force"))
                {
                    research.BodyParts_Select((int)act[1]);
                    research.CreateLoad((double)act[2]);
                }
            }

            research = new Research(FreeClass.sldManager, FreeClass.bodyDrawer.GetFacesArray());
            research.CreateStudy();

            research.CreateMesh();

            research.MaterialSet();
            research.RunAnalysis();

            double stress = research.GetStress(), displacement = research.GetDisplacement();

            dataGridView1.Rows[j - 1].Cells[1].Value = stress;       // Деформация
            dataGridView1.Rows[j - 1].Cells[2].Value = displacement; // Смещение

            logTextBox.Text += Environment.NewLine;
            logTextBox.Text += "Итерация: " + i.ToString(); logTextBox.Text += Environment.NewLine;
            logTextBox.Text += "Напряжение(ksi): " + stress.ToString(); logTextBox.Text += Environment.NewLine;
            logTextBox.Text += "Смещение(mk): " + displacement.ToString(); logTextBox.Text += Environment.NewLine;

            // задержка
            //Thread.Sleep(2500);

            // Очищаем
            research.deleteStudy(); research = null;
            FreeClass.sldManager.swModel.ClearSelection2(true);

            cellsDraw.deleteCells();
        }
Ejemplo n.º 3
0
        ////////////////// Конец наложения действий //////////////////

        ////////////////// Исследование //////////////////
        private void startResearch4_Click(object sender, EventArgs e)
        {
            NAngleForm owner;

            try { owner = (NAngleForm)this.Owner; }
            catch { MessageBox.Show("Ошибка получения матеинской формы"); return; }

            FreeClass.sldManager.swModel.ClearSelection2(true);

            try { FreeClass.cells.deleteCells(); }
            catch { }

            if (!owner.CheckLoop())
            {
                MessageBox.Show("Ошибка: На материнской форме не выбрана функция циклического построения");
                return;
            }

            int angle = owner.GetDeflection();

            if ((owner.GetAngles() == 3))
            {
                triangleResearch(owner); return;
            }
            else if (owner.GetAngles() >= 91)
            {
                cellsDraw = new CircleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, angle);
            }
            else
            {
                cellsDraw = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, angle);
            }
            dataGridView1.RowCount = 2; withoutIterationResearch();

            int start, end, step;

            start = Convert.ToInt16(owner.GetStartPoint());
            end   = Convert.ToInt16(owner.GetEndPoint());
            step  = Convert.ToInt16(owner.GetStep());
            double partOfVolume = Convert.ToDouble(owner.GetVolume());

            for (int i = start, j = 2; i <= end; i = i + step, j++)
            {
                dataGridView1.RowCount = j;

                //рисуем ячейки
                if (owner.GetAngles() >= 91)
                {
                    cells = new CircleCells(FreeClass.body);
                }
                else
                {
                    cells = new NAngleCells(FreeClass.body);
                    cells.SetAnglesN(owner.GetAngles());
                }

                cells.SetAccuracy(Convert.ToInt16(owner.GetAccuracy()));
                cells.SetColumnsNumber(i); cells.SetRowsNumber(i);
                cells.SetCellsHeight(owner.GetHeight());
                cells.SetCellsV(FreeClass.body.GetV() * partOfVolume / 100);

                cells.Calculation();

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

                dataGridView1.Rows[j - 1].Cells[0].Value = cells.GetRowsNumber() * cells.GetColumnsNumber();

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


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

                dataGridView1.Rows[j - 1].Cells[5].Value = Convert.ToDouble(dataGridView1.Rows[j - 1].Cells[2].Value) -
                                                           Convert.ToDouble(dataGridView1.Rows[0].Cells[2].Value);     // Деформация
                dataGridView1.Rows[j - 1].Cells[6].Value = Convert.ToDouble(dataGridView1.Rows[0].Cells[2].Value) * 100 /
                                                           Convert.ToDouble(dataGridView1.Rows[j - 1].Cells[2].Value); // %
            }

            //На случай, если нужно будет поменять условия циклического построения
            //чтобы приложение не обращалось по нулевой ссылке
            research = new Research(FreeClass.sldManager, FreeClass.bodyDrawer.GetFacesArray());
        }
Ejemplo n.º 4
0
        private void reResearch(int dataRow, double webDensity, double tlCurrent)
        {
            NAngleEmprovedForm owner;

            try { owner = (NAngleEmprovedForm)this.Owner; }
            catch { MessageBox.Show("Ошибка получения материнской формы"); return; }

            int angles = Convert.ToInt16(dataGridView1.Rows[dataRow].Cells[7].Value);

            if (angles == 3)
            {
                cells = new TriangleCells(FreeClass.body);
            }
            else if (angles == 4)
            {
                cells = new RectangleCells(FreeClass.body);
            }
            else
            {
                cells = new NAngleCells(FreeClass.body);
                cells.SetAnglesN(Convert.ToInt16(dataGridView1.Rows[dataRow].Cells[7].Value));
            }
            cells.SetAccuracy(accuracy);

            int cellsNum = Convert.ToInt16(Math.Sqrt(Convert.ToInt16(dataGridView1.Rows[dataRow].Cells[0].Value)));

            cells.SetColumnsNumber(cellsNum); cells.SetRowsNumber(cellsNum);
            cells.SetCellsHeight(owner.GetHeight());
            cells.SetCellsV(FreeClass.body.GetV() * Convert.ToDouble(owner.GetVolume()) / 100);

            cells.Calculation();

            //создаём исследование
            research = new Research(FreeClass.sldManager, FreeClass.bodyDrawer.GetFacesArray());
            research.CreateStudy();

            if (cells is RectangleCells)
            {
                rectDrawer = new RectangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);
                rectDrawer.SetCells((RectangleCells)cells);
                FreeClass.cells = rectDrawer; rectDrawer.drawCells();
            }
            else if (cells is TriangleCells)
            {
                triangleDrawer = new TriangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);
                triangleDrawer.SetCells((TriangleCells)cells);
                FreeClass.cells = triangleDrawer; triangleDrawer.drawCells();
            }
            else
            {
                cellsDraw = new NAngleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer, 0);
                cellsDraw.SetCells((AbstractRelationAngle)cells);
                FreeClass.cells = cellsDraw; cellsDraw.drawCells();
            }

            // прикладываем силы или фиксируем грани
            foreach (object[] act in action)
            {
                if (act[0].Equals("fix"))
                {
                    research.BodyParts_Select((int)act[1]);
                    research.FixFace();
                }
                else if (act[0].Equals("force"))
                {
                    research.BodyParts_Select((int)act[1]);
                    research.CreateLoad((double)act[2]);
                }
            }

            //research = new Research(FreeClass.sldManager, FreeClass.bodyDrawer.GetFacesArray());
            //research.CreateStudy();

            research.webDensity = webDensity;
            research.tlCurrent  = tlCurrent;

            research.CreateMesh(); research.MaterialSet();
            research.RunAnalysis();

            double stress = research.GetStress(), displacement = research.GetDisplacement();

            dataGridView2.Rows[dataRow].Cells[1].Value = stress;       // Деформация
            dataGridView2.Rows[dataRow].Cells[2].Value = displacement; // Смещение

            dataGridView2.Rows[dataRow].Cells[3].Value = Convert.ToDouble(dataGridView2.Rows[dataRow].Cells[1].Value) -
                                                         Convert.ToDouble(dataGridView2.Rows[0].Cells[1].Value); // Разность напряжения
            dataGridView2.Rows[dataRow].Cells[4].Value = Convert.ToDouble(dataGridView2.Rows[dataRow].Cells[1].Value) * 100 /
                                                         Convert.ToDouble(dataGridView2.Rows[0].Cells[1].Value); // %

            dataGridView2.Rows[dataRow].Cells[5].Value = Convert.ToDouble(dataGridView2.Rows[dataRow].Cells[2].Value) -
                                                         Convert.ToDouble(dataGridView2.Rows[0].Cells[2].Value); // Разность деформации
            dataGridView2.Rows[dataRow].Cells[6].Value = Convert.ToDouble(dataGridView2.Rows[dataRow].Cells[2].Value) * 100 /
                                                         Convert.ToDouble(dataGridView2.Rows[0].Cells[2].Value); // %

            dataGridView2.Rows[dataRow].Cells[10].Value = research.webDensity;                                   // плотность сетки
            dataGridView2.Rows[dataRow].Cells[11].Value = research.tlCurrent;                                    // tl

            // Очищаем
            research.deleteStudy(); research = null;
            FreeClass.sldManager.swModel.ClearSelection2(true);

            FreeClass.cells.deleteCells();
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     try { FreeClass.cells.deleteCells(); }
     catch { }
     drawer = null; FreeClass.cells = null;
 }