Beispiel #1
0
        public BmObj(BmObj bmObj, int nParts, int numOfPart)
        {
            this.xAxis  = bmObj.xAxis;
            this.yAxis  = bmObj.yAxis;
            this.zAxis  = bmObj.zAxis;
            this.xElPos = bmObj.xElPos;
            this.yElPos = bmObj.yElPos;
            this.zElPos = bmObj.zElPos;
            int countOfPointInPart     = (int)Math.Floor((double)(bmObj.points.Count() / nParts));
            int countOfExtendentPoints = bmObj.points.Count() % nParts;
            int countPointBefore;

            if (numOfPart <= countOfExtendentPoints)
            {
                countPointBefore = (numOfPart - 1) * (countOfPointInPart + 1);
            }
            else
            {
                countPointBefore = countOfExtendentPoints + ((numOfPart - 1) * countOfPointInPart);
            }
            int itemFrom = countPointBefore;
            int itemTo   = numOfPart != nParts ?
                           countPointBefore + (numOfPart <= countOfExtendentPoints ?  countOfPointInPart + 1
                                                                                                        :  countOfPointInPart)
                                             :
                           bmObj.points.Count();

            points = new Point[itemTo - itemFrom];
            int k = 0;

            for (int i = itemFrom; i < itemTo; i++)
            {
                this.points[k++] = new Point(bmObj.points[i]);
            }
        }
Beispiel #2
0
        public Ellipse[] startCalculation(DhBmObj data)
        {
            inData_ = data;
            BmObj[] bmObjs = new BmObj[nTread_];
            theBestEllipseOfPoint_ = new TheBestEllipseOfPoint[nTread_];
            Thread[] threads = new Thread[nTread_];
            Counter  counter = new Counter(inData_.bm.points.Count());

            if (Environment.UserInteractive)
            {
                Console.WriteLine("Количество параллельных потоков: " + nTread_);
            }
            for (int i = 0; i < nTread_; i++)
            {
                threads[i] = new Thread(startThread);
                bmObjs[i]  = new BmObj(inData_.bm, nTread_, i + 1);
                log.DebugFormat("Объявлем класс TheBestEllipseOfPoint (поток {6}): кол-во скважин - {0},кол-во ячеек БМ - {1},размер полуосей:{2}-{3}-{4} кол-во эллипсов вокруг: X - {5}," +
                                "Y - {6}, Z - {7}", inData_.dh.points.Count(), bmObjs[i].points.Count(), bmObjs[i].xAxis, bmObjs[i].yAxis, bmObjs[i].zAxis, bmObjs[i].xElPos, bmObjs[i].yElPos, bmObjs[i].zElPos, i);

                theBestEllipseOfPoint_[i] = new TheBestEllipseOfPoint(inData_.dh.points, bmObjs[i].points, bmObjs[i].xAxis, bmObjs[i].yAxis, bmObjs[i].zAxis, bmObjs[i].xElPos, bmObjs[i].yElPos, bmObjs[i].zElPos, counter);
                threads[i].IsBackground   = true;
                threads[i].Start(theBestEllipseOfPoint_[i]);
            }



            for (int i = 0; i < nTread_; i++)
            {
                threads[i].Join();
            }
            ellipses_ = theBestEllipseOfPoint_[0].getTheBestEllipses().ToArray();
            for (int i = 1; i < nTread_; i++)
            {
                ellipses_ = ellipses_.Concat(theBestEllipseOfPoint_[i].getTheBestEllipses()).ToArray();
            }

            for (int i = 0; i < data.bm.points.Count(); i++)
            {
                if (
                    !(ellipses_[i].point.x == data.bm.points[i].x ||
                      ellipses_[i].point.y == data.bm.points[i].y ||
                      ellipses_[i].point.z == data.bm.points[i].z
                      )
                    )
                {
                    log.Error("Координаты входной БМ не соответствуют координатам результата");
                    logCon.Error("Координаты входной БМ не соответствуют координатам результата");
                    return(null);
                }
            }

            log.InfoFormat("Возвращено в вызывающий модуль {0} ячеек БМ с параметрами эллипсов", ellipses_.Count());
            if (Environment.UserInteractive)
            {
                Console.WriteLine();
                Console.WriteLine(String.Format("Возвращено в вызывающий модуль {0} ячеек БМ с параметрами эллипсов", ellipses_.Count()));
            }

            double[] dd = new double[ellipses_.Count()];
            double[] d  = new double[ellipses_.Count()];
            for (int i = 0; i < ellipses_.Count(); i++)
            {
                dd[i] = ellipses_[i].trDipDir;
                d[i]  = ellipses_[i].trDip;
            }

            return(ellipses_);
        }