コード例 #1
0
        public Path GeneratePath(IEnumerable <Layer> layers)
        {
            var complete = new Path();

            // set from configuration
            var lookBehind = 2;
            var lookAhead  = 2;

            for (var current = 0; current < layers.Count(); current++)
            {
                var layer = layers.ElementAt(current);

                var prevLayers = new List <Layer>();
                var nextLayers = new List <Layer>();

                for (var offset = 1; offset <= lookBehind; offset++)
                {
                    var prev = current - offset;
                    if (prev >= 0)
                    {
                        prevLayers.Add(layers.ElementAt(prev));
                    }
                }

                for (var offset = 1; offset <= lookAhead; offset++)
                {
                    var next = current + offset;
                    if (next < layers.Count())
                    {
                        prevLayers.Add(layers.ElementAt(next));
                    }
                }

                complete = _pathHelper.AppendPaths(complete, GeneratePathForLayer(layer, prevLayers, nextLayers));
            }

            return(complete);
        }