Esempio n. 1
0
        private void drawBody_Click(object sender, EventArgs e)
        {
            cubeRadioButton.Enabled = false; paralRadioButton.Enabled = false;
            drawBody.Visible        = false; deleteBody.Visible = true;
            checkUseSolid.Enabled   = false;
            possibilities.Visible   = true;

            if (checkUseSolid.Checked)
            {
                possibilities.TabPages[1].Enabled = true;
                possibilities.TabPages[2].Enabled = true;
                possibilities.TabPages[3].Enabled = true;
            }
            else
            {
                possibilities.TabPages[1].Enabled = false;
                possibilities.TabPages[2].Enabled = false;
                possibilities.TabPages[3].Enabled = false;
            }

            //заблокировать изменение величин
            if (cubeRadioButton.Checked)
            {
                bodyWidthText.Enabled = false;
            }

            if (paralRadioButton.Checked)
            {
                bodyWidthText.Enabled  = false;
                bodyHeightText.Enabled = false;
                bodyLenghtText.Enabled = false;
            }

            //рисование тела
            double bodyWidth, bodyHeight, bodyLenght;

            if (cubeRadioButton.Checked)
            {
                bodyWidth  = Convert.ToDouble(bodyWidthText.Text.Replace('.', ','));
                bodyHeight = bodyWidth; bodyLenght = bodyWidth;
            }
            else
            {
                bodyWidth  = Convert.ToDouble(bodyWidthText.Text.Replace('.', ','));
                bodyHeight = Convert.ToDouble(bodyHeightText.Text.Replace('.', ','));
                bodyLenght = Convert.ToDouble(bodyLenghtText.Text.Replace('.', ','));
            }

            body = new BodyParam(bodyWidth, bodyHeight, bodyLenght);

            if (checkUseSolid.Checked)
            {
                //Запустить рисование тела ... добавить проверки
                application = new SLDManager(); application.GetSolidworks();

                bodyDrawer = new BodyDrawer(application, body);
                bodyDrawer.drawBody();
                body.SetFaces(bodyDrawer.GetFacesArray());
            }
            else
            {
                bodyDrawer = null; application = null;
            }
        }
Esempio n. 2
0
        private void button6_Click(object sender, EventArgs e)
        {
            startResearch4.Visible = false; deleteResearch4.Visible = true;
            diagramButton.Visible  = true;

            dataStress       = null;  dataStress = new List <object[]>();
            dataDisplacement = null; dataDisplacement = new List <object[]>();

            if (!loopRadioButton2.Checked)
            {
                MessageBox.Show("Для циклического исследования необходимо выбрать \"Циклическое построение\"" +
                                " в разделе \"Вычисление и конструирование\"");
                return;
            }

            // подготовка объекта cells
            preparationCalculation(accuracyTextBox2, iterationTextBox2, multiplierRadioButton2,
                                   multiplierTextBox2, denominatorTextBox2);

            cellsDrawer = new CellsDrawer(application, body, bodyDrawer);

            int start, end, step;

            start = Convert.ToInt16(iterationTextBox2.Text); end = Convert.ToInt16(rowTextBox2.Text);
            //Проверка шага
            if (columnTextBox2.Text == "" || columnTextBox2.Text == "0" || Convert.ToInt16(columnTextBox2.Text) < 0)
            { //шаг по умолчанию ( 1 )
                step = 1;
            }
            else
            { //заданный шаг
                step = Convert.ToInt16(columnTextBox2.Text);
            }

            for (int i = start; i <= end; i = i + step)
            {
                //рисуем ячейки
                cells.SetIterationNumber(i); cells.KCalculation();
                cellsDrawer.SetCells(cells); cellsDrawer.drawCells();

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

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

                researchLoop.CreateMesh(); researchLoop.MaterialSet();
                researchLoop.RunAnalysis();

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

                object[] buff1 = new object[2]; //[кол-во ячеек, напряжение]
                buff1[0] = Math.Pow(2, i); buff1[1] = stress;
                dataStress.Add(buff1);

                object[] buff2 = new object[2]; //[кол-во ячеек, перемещение]
                buff2[0] = Math.Pow(2, i); buff2[1] = displacement;
                dataDisplacement.Add(buff2);

                //
                //
                //
                //
                //
                //Create ResearchResult AND Add in DataBase
                ResearchResult researchResult = new ResearchResult(detail.Id, logTextBox4.Text, i, stress, displacement);
                data.AddNewResearchResultAndUpdateDetails(researchResult);
                //Create ResearchResult AND Add in DataBase
                //
                //
                //
                //
                //


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

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

                // Очищаем
                researchLoop.deleteStudy(); researchLoop = null;
                application.swModel.ClearSelection2(true);

                if (i != end)
                {
                    cellsDrawer.deleteCells();
                }
            }
        }