/// <summary>
        /// Рассчитывает шаги слоёв справа от центрального слоя
        /// </summary>
        /// <param name="currentLayer"></param>
        /// <param name="forwards1Layer"></param>
        /// <param name="forwards2Layer"></param>
        /// <param name="forwards3Layer"></param>
        void InitForwardsSteps(GridLayer currentLayer,
                               GridLayer forwards1Layer,
                               GridLayer forwards2Layer,
                               GridLayer forwards3Layer)
        {
            if (currentLayer == null)
            {
                return;
            }

            if (forwards1Layer == null)
            {
                return;
            }
            Step1F = forwards1Layer.Coordinate - currentLayer.Coordinate;

            if (forwards2Layer == null)
            {
                return;
            }
            Step2F = forwards2Layer.Coordinate - forwards1Layer.Coordinate;

            if (forwards3Layer == null)
            {
                return;
            }
            Step3F = forwards3Layer.Coordinate - forwards2Layer.Coordinate;
        }
        /// <summary>
        /// Рассчитывает шаги слоёв слева от центрального слоя
        /// </summary>
        /// <param name="backwards3Layer"></param>
        /// <param name="backwards2Layer"></param>
        /// <param name="backwards1Layer"></param>
        /// <param name="currentLayer"></param>
        void InitBackwardsSteps(GridLayer backwards3Layer,
                                GridLayer backwards2Layer,
                                GridLayer backwards1Layer,
                                GridLayer currentLayer)
        {
            if (currentLayer == null)
            {
                return;
            }

            if (backwards1Layer == null)
            {
                return;
            }
            Step1B = currentLayer.Coordinate - backwards1Layer.Coordinate;

            if (backwards2Layer == null)
            {
                return;
            }
            Step2B = backwards1Layer.Coordinate - backwards2Layer.Coordinate;

            if (backwards3Layer == null)
            {
                return;
            }
            Step3B = backwards2Layer.Coordinate - backwards3Layer.Coordinate;
        }
        /// <summary>
        /// Формирование объекта по переданным слоям
        /// </summary>
        /// <param name="backwards3Layer">Третий слой слева</param>
        /// <param name="backwards2Layer">Второй слой слева</param>
        /// <param name="backwards1Layer">Первый слой слева</param>
        /// <param name="currentLayer">Центральный слой</param>
        /// <param name="forwards1Layer">Первый слой справа</param>
        /// <param name="forwards2Layer">Второй слой справа</param>
        /// <param name="forwards3Layer">Третий слой справа</param>
        public GridLayerParameters(GridLayer backwards3Layer,
                                   GridLayer backwards2Layer,
                                   GridLayer backwards1Layer,
                                   GridLayer currentLayer,
                                   GridLayer forwards1Layer,
                                   GridLayer forwards2Layer,
                                   GridLayer forwards3Layer)
        {
            if (currentLayer == null)
            {
                return;
            }
            if (forwards1Layer == null && backwards1Layer == null)
            {
                return;
            }

            InitBackwardsSteps(backwards3Layer, backwards2Layer,
                               backwards1Layer, currentLayer);
            InitForwardsSteps(currentLayer, forwards1Layer,
                              forwards2Layer, forwards3Layer);
            InitH();
            InitAlfa();
            InitDerivatives();
        }
Esempio n. 4
0
        /// <summary>
        /// Создаёт список слоёв на основе переданного списка переходов
        /// </summary>
        /// <param name="stepTransitionList">Список переходов (список List объектов StepTransition)</param>
        /// <returns>Список объектов GridLayer</returns>
        public static List <GridLayer> GenerateGridLayerListFromStepTransitionList(List <StepTransition> stepTransitionList)
        {
            var  resultGridLayerList          = new List <GridLayer>();
            uint resultGridLayerListItemIndex = 0;

            if (stepTransitionList == null)
            {
                return(resultGridLayerList);
            }
            if (stepTransitionList.Count == 0)
            {
                return(resultGridLayerList);
            }

            StepTransition prevStepTransition = new StepTransition(0, 0, 0);
            GridLayer      prevLayer          = new GridLayer();

            prevLayer.Index      = 0;
            prevLayer.Coordinate = 0;
            resultGridLayerList.Add(prevLayer);
            for (int stepTransitionCounter = 0; stepTransitionCounter < stepTransitionList.Count; stepTransitionCounter++)
            {
                StepTransition currentStepTransition           = stepTransitionList[stepTransitionCounter];
                decimal        distanceBetweenStepTransitions  = currentStepTransition.Coordinate - prevStepTransition.Coordinate;
                uint           numLayersBetweenStepTransitions = Convert.ToUInt32(distanceBetweenStepTransitions / currentStepTransition.StepValue);
                for (int layerCounter = 0; layerCounter < numLayersBetweenStepTransitions; layerCounter++)
                {
                    GridLayer curLayer = new GridLayer();
                    curLayer.Index      = ++resultGridLayerListItemIndex;
                    curLayer.Coordinate = prevLayer.Coordinate + currentStepTransition.StepValue;
                    resultGridLayerList.Add(curLayer);

                    prevLayer = curLayer;
                }
                prevStepTransition = currentStepTransition;
            }

            return(resultGridLayerList);
        }
Esempio n. 5
0
        /// <summary>
        /// Объединяет списки слоёв
        /// </summary>
        /// <param name="gridLayerList1"></param>
        /// <param name="gridLayerList2"></param>
        /// <returns></returns>
        protected List <GridLayer> MergeGridLayerLists(List <GridLayer> gridLayerList1, List <GridLayer> gridLayerList2)
        {
            if (gridLayerList1 == null || gridLayerList1.Count == 0)
            {
                return(gridLayerList2);
            }
            if (gridLayerList2 == null || gridLayerList2.Count == 0)
            {
                return(gridLayerList1);
            }

            var gridLayerListResult        = new List <GridLayer>();
            int gridLayerList1Counter      = gridLayerList1.Count;
            int gridLayerList2Counter      = gridLayerList2.Count;
            int gridLayerList1CurrentIndex = 0;
            int gridLayerList2CurrentIndex = 0;

            List <GridLayer> leftList;
            List <GridLayer> rightList;

            uint addingGridLayerIndex = 0;

            while (gridLayerList1Counter > 0 || gridLayerList2Counter > 0)
            {
                // Если первый список уже пуст, добавляем элементы из второго списка
                if (gridLayerList1Counter == 0)
                {
                    var addingGridLayer = new GridLayer();
                    addingGridLayer.Index      = addingGridLayerIndex;
                    addingGridLayer.Coordinate = gridLayerList2[gridLayerList2CurrentIndex].Coordinate;
                    gridLayerListResult.Add(addingGridLayer);

                    addingGridLayerIndex++;
                    gridLayerList2Counter--;
                    gridLayerList2CurrentIndex++;
                    continue;
                }

                // Если второй список уже пуст, добавляем элементы из первого списка
                if (gridLayerList2Counter == 0)
                {
                    var addingGridLayer = new GridLayer();
                    addingGridLayer.Index      = addingGridLayerIndex;
                    addingGridLayer.Coordinate = gridLayerList1[gridLayerList1CurrentIndex].Coordinate;
                    gridLayerListResult.Add(addingGridLayer);

                    addingGridLayerIndex++;
                    gridLayerList1Counter--;
                    gridLayerList1CurrentIndex++;
                    continue;
                }

                // Если координаты в обоих списках одинаковые - добавляем только один элемент и изменяем счетчики у обоих списков
                if (gridLayerList1[gridLayerList1CurrentIndex].Coordinate == gridLayerList2[gridLayerList2CurrentIndex].Coordinate)
                {
                    var addingGridLayer = new GridLayer();
                    addingGridLayer.Index      = addingGridLayerIndex;
                    addingGridLayer.Coordinate = gridLayerList1[gridLayerList1CurrentIndex].Coordinate;
                    gridLayerListResult.Add(addingGridLayer);

                    addingGridLayerIndex++;
                    gridLayerList1Counter--;
                    gridLayerList2Counter--;
                    gridLayerList1CurrentIndex++;
                    gridLayerList2CurrentIndex++;
                    continue;
                }
                // Если координаты отличаются, устанавливаем левый и правый списки
                if (gridLayerList1[gridLayerList1CurrentIndex].Coordinate < gridLayerList2[gridLayerList2CurrentIndex].Coordinate)
                {
                    leftList  = gridLayerList1;
                    rightList = gridLayerList2;

                    while (leftList[gridLayerList1CurrentIndex].Coordinate < rightList[gridLayerList2CurrentIndex].Coordinate)
                    {
                        var addingGridLayer = new GridLayer();
                        addingGridLayer.Index      = addingGridLayerIndex;
                        addingGridLayer.Coordinate = leftList[gridLayerList1CurrentIndex].Coordinate;
                        gridLayerListResult.Add(addingGridLayer);

                        addingGridLayerIndex++;
                        gridLayerList1Counter--;
                        gridLayerList1CurrentIndex++;

                        if (gridLayerList1Counter <= 0 || gridLayerList1CurrentIndex >= gridLayerList1.Count)
                        {
                            gridLayerList1Counter = 0;
                            break;
                        }
                    }
                }
                else
                {
                    leftList  = gridLayerList2;
                    rightList = gridLayerList1;

                    while (leftList[gridLayerList2CurrentIndex].Coordinate < rightList[gridLayerList1CurrentIndex].Coordinate)
                    {
                        var addingGridLayer = new GridLayer();
                        addingGridLayer.Index      = addingGridLayerIndex;
                        addingGridLayer.Coordinate = leftList[gridLayerList2CurrentIndex].Coordinate;
                        gridLayerListResult.Add(addingGridLayer);

                        addingGridLayerIndex++;
                        gridLayerList2Counter--;
                        gridLayerList2CurrentIndex++;

                        if (gridLayerList2Counter <= 0 || gridLayerList2CurrentIndex >= gridLayerList2.Count)
                        {
                            gridLayerList2Counter = 0;
                            break;
                        }
                    }
                }
            }
            return(gridLayerListResult);
        }