コード例 #1
0
ファイル: NandMForm.cs プロジェクト: EuhSaharuk/CellStructure
        private void matrixLoopCalculation()
        {
            int start, end, step;
            start = Convert.ToInt16(GetStartPoint());
            end = Convert.ToInt16(GetEndPoint());
            step = Convert.ToInt16(GetStep());
            double partOfVolume = Convert.ToDouble(GetVolume());

            for (int i = start; i <= end; i = i + step)
            {
                cells = new NandMRectangleCells(FreeClass.body);
                cells.SetAccuracy(Convert.ToInt16(GetAccuracy()));
                cells.SetCellsV(FreeClass.body.GetV() * Convert.ToDouble(textBox3.Text.Replace('.', ',')) / 100);
                cells.SetColumnsNumber(i); cells.SetRowsNumber(i);
                cells.Calculation();
                //рисуем ячейки
                if (!cells.isAvailable())
                {
                    DialogResult dialogResult = MessageBox.Show("Не удалось решить структуру при определённых условиях." +
                        " запустить следующий набор данных?",
                     "Предупреждение", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes) { continue; }
                    else if (dialogResult == DialogResult.No) { return; }
                }

                textResultsCellsRectangelNaM(resultBox);
                resultBox.Text += Environment.NewLine;
            }
        }
コード例 #2
0
ファイル: NandMForm.cs プロジェクト: EuhSaharuk/CellStructure
        private void calculateButton_Click(object sender, EventArgs e)
        {
            if (FreeClass.body == null) {
                MessageBox.Show("Тело не было задано. Невозможно произвести вычисления");
                return;
            }

            if (singleBuildRadioButton.Checked)
            {
                cells = new NandMRectangleCells(FreeClass.body);
                cells.SetAccuracy(Convert.ToInt16(textBox4.Text));
                cells.SetCellsV(FreeClass.body.GetV() * Convert.ToDouble(textBox3.Text.Replace('.', ',')) / 100);
                if (TwoInNRadioButton.Checked)
                {
                    double buff = Convert.ToInt16(textBox1.Text);
                    if (buff % 2 == 0)
                    {
                        buff = Math.Sqrt(Math.Pow(2, buff));
                        cells.SetColumnsNumber(Convert.ToInt16(buff));
                        cells.SetRowsNumber(Convert.ToInt16(buff));
                    }
                    else
                    {
                        buff = Math.Sqrt(Math.Pow(2, buff - 1));
                        cells.SetColumnsNumber(Convert.ToInt16(buff) * 2);
                        cells.SetRowsNumber(Convert.ToInt16(buff));
                    }
                }
                else if (SquareMatrixRadioButton.Checked)
                {
                    cells.SetColumnsNumber(Convert.ToInt16(textBox1.Text));
                    cells.SetRowsNumber(Convert.ToInt16(textBox1.Text));
                }
                else
                {
                    cells.SetColumnsNumber(Convert.ToInt16(textBox1.Text));
                    cells.SetRowsNumber(Convert.ToInt16(textBox2.Text));
                }

                cells.Calculation();

                if (!cells.isAvailable()) { MessageBox.Show("Решение не было найдено"); return; }

                resultBox.Clear();
                resultBox.Text += "Обьём цельного тела" + FreeClass.body.GetV(); resultBox.Text += Environment.NewLine;
                textResultsCellsRectangelNaM(resultBox);

            }
            else if (loopBuildRadioButton.Checked)
            {
                resultBox.Clear();
                resultBox.Text += "Обьём цельного тела" + FreeClass.body.GetV(); resultBox.Text += Environment.NewLine;
                if (SquareMatrixRadioButton.Checked)
                {
                    matrixLoopCalculation();
                }
                else if (TwoInNRadioButton.Checked)
                {
                    int start, end, step;
                    start = Convert.ToInt16(GetStartPoint());
                    end = Convert.ToInt16(GetEndPoint());
                    step = Convert.ToInt16(GetStep());
                    double partOfVolume = Convert.ToDouble(GetVolume());

                    for (int i = start, j = 1; i <= end; i = i + step, j++)
                    {
                        cells = new NandMRectangleCells(FreeClass.body);
                        cells.SetAccuracy(Convert.ToInt16(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));
                        }

                        cells.Calculation();
                        if (!cells.isAvailable())
                        {
                            DialogResult dialogResult = MessageBox.Show("Не удалось решить структуру при определённых условиях." +
                                " запустить следующий набор данных?",
                             "Предупреждение", MessageBoxButtons.YesNo);
                            if (dialogResult == DialogResult.Yes) { continue; }
                            else if (dialogResult == DialogResult.No) { return; }
                        }

                        textResultsCellsRectangelNaM(resultBox);

                    }

                }
                else
                {
                    int start1, start2, end, step;
                    start1 = Convert.ToInt16(GetStartPoint());
                    start2 = Convert.ToInt16(GetEndPoint());
                    end = Convert.ToInt16(GetMiddlePoint());
                    step = Convert.ToInt16(GetStep());
                    double partOfVolume = Convert.ToDouble(GetVolume());

                    //withoutIterationResearch();

                    for (int i = start1, j = 1; i <= end; i = i + step, j++, start2 = start2 + step)
                    {
                        cells = new NandMRectangleCells(FreeClass.body);

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

                        cells.SetColumnsNumber(i); cells.SetRowsNumber(start2);

                        cells.Calculation();
                        if (!cells.isAvailable())
                        {
                            DialogResult dialogResult = MessageBox.Show("Не удалось решить структуру при определённых условиях." +
                                " запустить следующий набор данных?",
                             "Предупреждение", MessageBoxButtons.YesNo);
                            if (dialogResult == DialogResult.Yes) { continue; }
                            else if (dialogResult == DialogResult.No) { return; }
                        }

                        textResultsCellsRectangelNaM(resultBox);
                    }

                }
            }
        }
コード例 #3
0
        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());
        }