Beispiel #1
0
        override public void drawCells()
        {
            //получить грани бобышки
            faces = bodyDrawer.GetFacesArray();
            //выбрать вторую (вверх бобышки)
            var ent = faces.GetValue(1) as Entity;

            //выбрать верхнюю грань
            ent.Select(true);
            //добавить на неё эскиз
            swSketchManager.InsertSketch(false);

            // Получаем объект эскиза, на котором будем рисовать
            activeSketch = application.swModel.GetActiveSketch2();

            //cells
            // Определяем положение центра верхней левой ячейки относительно центра плоскости (0, 0, 0)
            double x_current = ((-body.GetWidth()) / 2.0) + (cells.GetKX() + (cells.GetSide() / 2));
            double y_current = (body.GetLenght() / 2.0) - (cells.GetKY() + cells.GetRadius());// - (cells.GetKY() + cells.GetTriangleHeight());

            // Определяем положение самого верхнего угла ячейки
            double x_end = x_current;
            double y_end = y_current + cells.GetRadius();
            //MessageBox.Show(x_end + " " + y_end);
            //Запоминаем позицию для дальнейшего использования
            double leftHoleCenterX = x_current, leftHoleCenterY = y_current;

            //Сдвиг, расстояние от центра одной ячейки до центра другой по координате Х
            double delta = cells.GetSide() + cells.GetKX();

            //Определяем количество ячеек в зависимости от итерации
            int row = cells.GetRowsNumber(), collumn = cells.GetColumnsNumber();

            for (int i = 0; i < row; i++)
            {
                //Рисуем первую в ряду ячейку
                application.swModel.SketchManager.CreatePolygon(x_current, y_current, 0, x_end, y_end, 0, cells.GetAnglesN(), false);
                //Рисуем остальные
                for (int j = 1; j < collumn; j++)
                {
                    x_current = x_current + delta;
                    x_end     = x_end + delta;
                    application.swModel.SketchManager.CreatePolygon(x_current, y_current, 0, x_end, y_end, 0, cells.GetAnglesN(), false);
                }
                //Возвращаемся к первой ячейке
                x_current = leftHoleCenterX;
                //Сдвигаемся по координате Y
                y_current = leftHoleCenterY - (cells.GetTriangleHeight() + cells.GetKY());
                //Запоминаем координаты
                leftHoleCenterX = x_current; leftHoleCenterY = y_current;
                //Определяем положение правого нижнего угла ячейки
                x_end = x_current;
                y_end = y_current + cells.GetRadius();
            }

            //Получаем объект "вырез"
            cut = featureCut(cells.GetCellsHeight());
            application.swModel.ClearSelection();
        }
Beispiel #2
0
        private void triangleResearch(NAngleForm owner)
        {
            triangleDrawer = new TriangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);

            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;
                triangleCells          = new TriangleCells(FreeClass.body);

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

                triangleCells.Calculation();

                if (!triangleCells.isAvailable())
                {
                    string       reason       = "Степень - " + i + " " + writeResults(triangleCells);
                    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 = triangleCells.GetRowsNumber() * triangleCells.GetColumnsNumber();

                try { ResearchActions(triangleDrawer, 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());
        }