Ejemplo n.º 1
0
        /// <summary>
        /// Рисует тело, в котором будут отверстия
        /// </summary>
        /// <returns>Возвращает объект, на котором будут сделаны ячейки</returns>
        public void drawBody()
        {
            //получем ссылку на интерфейс, ответственный за рисование
            swSketchManager = application.swModel.SketchManager;
            application.swModel.Extension.SelectByID2("Сверху", "PLANE", 0, 0, 0, false, 0, null, 0); //выбрал плоскость

            swSketchManager.InsertSketch(false);
            sketch = application.swModel.GetActiveSketch2();
            //создать основание
            var rect = swSketchManager.CreateCenterRectangle(0, 0, 0, body.GetWidth() / acc / 2.0, body.GetHeight() / acc / 2.0, 0);

            //очистить буфер выбранных элементов
            application.swModel.ClearSelection();

            //вытянуть бобышку
            Feature feature = featureExtrusion(body.GetLenght() / acc);

            application.swModel.ClearSelection();

            body3d = feature;
        }
Ejemplo n.º 2
0
        public void KCalculation()
        {
            double A, B, C;

            //Вычисляем элементы кубического уравнения
            //x^3 + Ax^2 + Bx + C = 0
            if (iterCheck())
            {
                double t = Math.Sqrt(Math.Pow(2, iterationNumber));
                A  = ((body.GetWidth() + body.GetHeight()) / (t + 1) + body.GetLenght()) * (-1);
                B  = body.GetWidth() * body.GetHeight() + body.GetLenght() * (t + 1) * (body.GetWidth() + body.GetHeight());
                B /= Math.Pow(t + 1, 2);
                C  = (body.GetWidth() * body.GetHeight() * body.GetLenght()) - ((VCells * Math.Pow(t, 2)) / Math.Pow(2, iterationNumber));
                C /= Math.Pow(t + 1, 2) * (-1);
            }
            else
            {
                double p = Math.Sqrt(Math.Pow(2, iterationNumber - 1));
                A  = ((body.GetWidth() / (2 * p + 1)) + (body.GetHeight() / (p + 1)) + body.GetLenght()) * (-1);
                B  = body.GetWidth() * body.GetHeight() + body.GetHeight() * body.GetLenght() * (2 * p + 1) + body.GetWidth() * body.GetLenght() * (p + 1);
                B /= (2 * p + 1) * (p + 1);
                C  = body.GetWidth() * body.GetHeight() * body.GetLenght() - (VCells * 2 * Math.Pow(p, 2) / Math.Pow(2, iterationNumber));
                C /= (2 * p + 1) * (p + 1) * (-1);
            }
            //////////////////////

            //Получаем корни уравнения
            rootsList = GetRoots(A, B, C);
            k         = -1.0;

            foreach (Complex element in rootsList)
            {
                if (element.Real < 0)
                {
                    continue;
                }
                if (element.Real == -1.0)
                {
                    k = -1.0;
                    break;
                }

                k = element.Real;
                double buff1, buff2, buff3;

                //Вычисляем предположительные значения сторон отверстия
                if (iterCheck())
                {
                    double t = Math.Sqrt(Math.Pow(2, iterationNumber));
                    SetCellsWidthOddIteration(); SetCellsHeightOddIteration(); SetCellsLenght();
                    if (cellWidth < 0 || cellHeight < 0 || cellLenght < 0)
                    {
                        continue;
                    }
                    buff1 = t * cellWidth + (t + 1) * k;
                    buff2 = t * cellHeight + (t + 1) * k;
                    buff3 = k + cellLenght;
                }
                else
                {
                    double p = Math.Sqrt(Math.Pow(2, iterationNumber - 1));
                    SetCellsWidthNotOddIteration(); SetCellsHeightNotOddIteration(); SetCellsLenght();
                    if (cellWidth < 0 || cellHeight < 0 || cellLenght < 0)
                    {
                        continue;
                    }
                    buff1 = 2 * p * cellWidth + (2 * p + 1) * k;
                    buff2 = p * cellHeight + (p + 1) * k;
                    buff3 = k + cellLenght;
                }

                if (Comporation(buff1, body.GetWidth()) && Comporation(buff2, body.GetHeight()) &&
                    Comporation(buff3, body.GetLenght()))
                {
                    SetCellsNum();
                    SetVCellsFactical();
                    return;
                }
                else
                {
                    k = -1.0;
                }
            }
        }