示例#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 + (cellObj.GetK() + cellObj.GetCellsWidth() / 2.0);
            double y_current = (body.GetHeight() / 2.0) - (cellObj.GetK() + (cellObj.GetCellsLenght() / 2.0));
            //Определяем положение правого нижнего угла ячейки
            double x_end = ((-body.GetWidth()) / 2.0) + (cellObj.GetK() + cellObj.GetCellsWidth());
            double y_end = (body.GetHeight() / 2.0) - (cellObj.GetK() + cellObj.GetCellsLenght());

            //Запоминаем позицию для дальнейшего использования
            double leftHoleCenterX = x_current, leftHoleCenterY = y_current;

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

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

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

            //Получаем объект "вырез"
            cut = featureCut(cellObj.GetCellsHeight());
            application.swModel.ClearSelection();
        }
示例#2
0
 private void textResultsCellsRectangelNaM(TextBox box)
 {
     //box.Text += "Номер итерации - " + cellsRectangelNaM.GetIterationNumber().ToString();
     //box.Text += Environment.NewLine;
     box.Text += "Количество ячеек - " + (cells.GetColumnsNumber() * cells.GetRowsNumber()).ToString();
     box.Text += Environment.NewLine;
     box.Text += "Часть объёма, занимаемая ячеками - " + cells.GetCellsV().ToString();
     box.Text += Environment.NewLine;
     box.Text += "ФАКТИЧЕСКАЯ часть объёма, занимаемая ячеками - " + cells.GetVCellsFactical().ToString();
     box.Text += Environment.NewLine;
     box.Text += "K - " + cells.GetK().ToString();
     box.Text += Environment.NewLine;
     box.Text += "Ширина 1 ячейки - " + cells.GetCellsWidth().ToString();
     box.Text += Environment.NewLine;
     box.Text += "Длинна 1 ячейки - " + cells.GetCellsLenght().ToString();
     box.Text += Environment.NewLine;
     box.Text += "Высота 1 ячейки - " + cells.GetCellsHeight().ToString();
     box.Text += Environment.NewLine;
     box.Text += Environment.NewLine;
 }
        private void startResearch4_Click(object sender, EventArgs e)
        {
            NandMForm owner;

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

            //if (true) { return; }

            FreeClass.sldManager.swModel.ClearSelection2(true);

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

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

            cellsDraw = new
                        NandMRectangleCellsDrawer(FreeClass.sldManager, FreeClass.body, FreeClass.bodyDrawer);

            /*
             * switch (answer) {
             *  case "2n": {  break; }
             *  case "maxtrix": break;
             *  case "free": break;
             *  default: break;
             * }*/

            dataGridView1.RowCount = 1;

            if (owner.GetMethod() == "matrix")
            {
                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());

                //withoutIterationResearch();

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

                    //рисуем ячейки
                    cells = new NandMRectangleCells(FreeClass.body);

                    cells.SetAccuracy(Convert.ToInt16(owner.GetAccuracy()));
                    cells.SetCellsV(FreeClass.body.GetV() * partOfVolume / 100);

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

                    ResearchActions(cellsDraw, i, j);
                }
            }
            else if (owner.GetMethod() == "2n")
            {
                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());

                //withoutIterationResearch();

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

                    //рисуем ячейки
                    cells = new NandMRectangleCells(FreeClass.body);

                    cells.SetAccuracy(Convert.ToInt16(owner.GetAccuracy()));
                    cells.SetCellsV(FreeClass.body.GetV() * partOfVolume / 100);

                    if (i % 2 == 0)
                    {
                        double buff = Math.Sqrt(Math.Pow(2, i));
                        cells.SetColumnsNumber(Convert.ToInt16(buff));
                        cells.SetRowsNumber(Convert.ToInt16(buff));
                    }
                    else
                    {
                        double buff = Math.Sqrt(Math.Pow(2, i - 1));
                        cells.SetColumnsNumber(Convert.ToInt16(buff) * 2);
                        cells.SetRowsNumber(Convert.ToInt16(buff));
                    }

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

                    ResearchActions(cellsDraw, i, j);
                }
            }
            else if (owner.GetMethod() == "free")
            {
                int start1, start2, end, step;
                start1 = Convert.ToInt16(owner.GetStartPoint());
                start2 = Convert.ToInt16(owner.GetEndPoint());
                end    = Convert.ToInt16(owner.GetMiddlePoint());
                step   = Convert.ToInt16(owner.GetStep());
                double partOfVolume = Convert.ToDouble(owner.GetVolume());

                //withoutIterationResearch();

                for (int i = start1, j = 1; i <= end; i = i + step, j++, start2 = start2 + step)
                {
                    dataGridView1.RowCount = j;

                    //рисуем ячейки
                    cells = new NandMRectangleCells(FreeClass.body);

                    cells.SetAccuracy(6);
                    cells.SetCellsV(FreeClass.body.GetV() * partOfVolume / 100);

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

                    ResearchActions(cellsDraw, i, j);
                }
            }



            //На случай, если нужно будет поменять условия циклического построения
            //чтобы приложение не обращалось по нулевой ссылке
            research = new Research(FreeClass.sldManager, FreeClass.bodyDrawer.GetFacesArray());
        }