private void cellsCalculate(AbstractAngle c, int columns) { c.SetColumnsNumber(columns); c.SetRowsNumber(columns); c.SetCellsHeight(Convert.ToDouble(textBox2.Text.Replace('.', ','))); c.SetAccuracy(Convert.ToInt16(textBox4.Text)); c.SetCellsV(FreeClass.body.GetV() * Convert.ToDouble(textBox3.Text.Replace('.', ',')) / 100); c.Calculation(); }
private void calculateButton_Click(object sender, EventArgs e) { resultBox.Clear(); if (FreeClass.body == null) { MessageBox.Show("Тело не было задано. Невозможно произвести вычисления"); return; } int start, end, step; if (loopBuildRadioButton.Checked) { start = Convert.ToInt16(GetStartPoint()); end = Convert.ToInt16(GetEndPoint()); step = Convert.ToInt16(GetStep()); } else { start = end = Convert.ToInt16(GetStartPoint()); step = 1; } for (int i = start; i <= end; i = i + step) { if (Convert.ToInt16(textBox5.Text) == 3) { cells = new TriangleCells(FreeClass.body); } else if (Convert.ToInt16(textBox5.Text) >= 91) { cells = new CircleCells(FreeClass.body); } else { cells = new NAngleCells(FreeClass.body); cells.SetAnglesN(Convert.ToInt16(textBox5.Text)); } cellsCalculate(cells, i); //resultBox.Text += cells.GetType(); if (cells is TriangleCells) { resultBox.Text += writeResults((TriangleCells)cells); } else { resultBox.Text += writeResults((AbstractRelationAngle)cells); } resultBox.Text += Environment.NewLine; resultBox.Text += Environment.NewLine; } }
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(); }
/// <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 }
/// <summary> /// Цикл по изменению количества углов /// </summary> /// <param name="matrixGrade">Степень матрицы</param> private void loopAngleNum(int matrixGrade) { int angleStart = Convert.ToInt16(angleNumStartTextBox.Text); int angeEnd = Convert.ToInt16(angleEndTextBox.Text); int angleStep = Convert.ToInt16(angleStepTextBox.Text); 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(i); } } 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(i); } } 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(angleStart); } else { throw new Exception(); } }