Пример #1
0
        private void TestRuntimePassthrough(int xBorder, int yBorder)
        {
            int computations1, computations2;
            int width = 16, height = 16, depth = 16;
            var gradient    = new RuntimeLayer(new AlgorithmGradientInitial());
            var passthrough = new RuntimeLayer(new AlgorithmPassthrough {
                XBorder = xBorder, YBorder = yBorder
            });

            passthrough.SetInput(0, gradient);
            var i1 = gradient.GenerateData(0, 0, 0, width, height, depth, out computations1);
            var i2 = passthrough.GenerateData(0, 0, 0, width, height, depth, out computations2);

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    for (var z = 0; z < depth; z++)
                    {
                        Assert.Equal(i1[x + y * width + z * width * height], i2[x + y * width + z * width * height]);
                    }
                }
            }
            //, "Value differs in passthrough (" + xBorder + ", " + yBorder + ").");
        }
        public void TestPositiveDoubling()
        {
            var inputA = new AlgorithmDebuggingInitialValueDelegate
            {
                GetValueForPosition = (x, y, z, i, j, k) =>
                {
                    return((int)(1));
                }
            };

            int computations;
            var increment = new AlgorithmIncrementWaterDistance();

            var runtimeInput = new RuntimeLayer(inputA);
            var runtimeTest  = new RuntimeLayer(increment);

            runtimeTest.SetInput(0, runtimeInput);

            var result = runtimeTest.GenerateData(0, 0, 0, 16, 16, 16, out computations);


            for (var i = 0; i < 16; i++)
            {
                for (var j = 0; j < 16; j++)
                {
                    for (var k = 0; k < 16; k++)
                    {
                        Assert.True(
                            result[i + j * 16 + k * 16 * 16] == 2);
                    }
                }
            }
        }
Пример #3
0
        public void TestCompileGradient()
        {
            int computations1, computations2;
            int width = 16, height = 16, depth = 16;
            var gradient    = new RuntimeLayer(new AlgorithmGradientInitial());
            var passthrough = new RuntimeLayer(new AlgorithmPassthrough());

            passthrough.SetInput(0, gradient);
            var i1 = gradient.GenerateData(0, 0, 0, width, height, depth, out computations1);

            var c1 = LayerCompiler.Compile(gradient).GenerateData(0, 0, 0, width, height, depth, out computations1);

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    for (var z = 0; z < depth; z++)
                    {
                        Assert.Equal(
                            i1[x + y * width + z * width * height],
                            c1[x + y * width + z * width * height],
                            "Value differs in gradient compare.");
                    }
                }
            }
        }
Пример #4
0
        public void TestForOCXOddAdjustmentShutterBug()
        {
            int computations;
            var input = new AlgorithmDebuggingInitialDelegate
            {
                ValueShouldBePlacedAt = (x, y, z) => true
            };
            var zoom = new AlgorithmZoom2D
            {
                Mode = AlgorithmZoom2D.ZoomType.Square
            };
            var runtimeInput = new RuntimeLayer(input);
            var runtimeZoom  = new RuntimeLayer(zoom);

            runtimeZoom.SetInput(0, runtimeInput);
            var result = runtimeZoom.GenerateData(1, 0, 0, 32, 32, 32, out computations);

            // We have filled the entire block, therefore this bug can be detected by checking
            // every odd row.
            for (var x = 1; x < 32; x += 2)
            {
                Assert.True(result[x + 0 * 32 + 0 * 32 * 32] == 1);
            }
            //, "OCX odd adjustment shutter bug is present, where every odd row is blank when main adjustment is an odd number.");
        }
Пример #5
0
        public void ZoomSquareTest()
        {
            int computations1, computations2;
            int width = 16, height = 16, depth = 16;
            var gradient = new RuntimeLayer(new AlgorithmGradientInitial());
            var zoom     = new RuntimeLayer(new AlgorithmZoom2D {
                Mode = AlgorithmZoom2D.ZoomType.Square
            });

            zoom.SetInput(0, gradient);
            var i1 = gradient.GenerateData(0, 0, 0, width, height, depth, out computations1);
            var i2 = zoom.GenerateData(0, 0, 0, width, height, depth, out computations2);

            for (var i = 0; i < width; i++)
            {
                for (var j = 0; j < height; j++)
                {
                    for (var k = 0; k < depth; k++)
                    {
                        Assert.Equal(
                            i1[i / 2 + j / 2 * width + k / 2 * width * height],
                            i2[i + j * width + k * width * height]);
                    }
                }
            }
            //,
            //               "Square zoom is not working for (" + i + ", " + j + ", " + k + ").");
        }
Пример #6
0
        public void TestValueRetrievalAcrossBorder()
        {
            int computations;
            var inputA = new AlgorithmDebuggingInitialDelegate
            {
                ValueShouldBePlacedAt = (x, y, z) => (x >= 4 && x <= 6 && y >= 4 && y <= 6)
            };
            var test = new AlgorithmDebuggingDelegate
            {
                Delegate = (context, input, output, x, y, z, i, j, k, width, height, depth, ox, oy, oz) =>
                {
                    int v00 = input[((i - 1) + ox) + ((j - 1) + oy) * width + (k + oz) * width * height];
                    int v01 = input[((i - 1) + ox) + ((j + 0) + oy) * width + (k + oz) * width * height];
                    int v02 = input[((i - 1) + ox) + ((j + 1) + oy) * width + (k + oz) * width * height];
                    int v10 = input[((i + 0) + ox) + ((j - 1) + oy) * width + (k + oz) * width * height];
                    int v11 = input[((i + 0) + ox) + ((j + 0) + oy) * width + (k + oz) * width * height];
                    int v12 = input[((i + 0) + ox) + ((j + 1) + oy) * width + (k + oz) * width * height];
                    int v20 = input[((i + 1) + ox) + ((j - 1) + oy) * width + (k + oz) * width * height];
                    int v21 = input[((i + 1) + ox) + ((j + 0) + oy) * width + (k + oz) * width * height];
                    int v22 = input[((i + 1) + ox) + ((j + 1) + oy) * width + (k + oz) * width * height];

                    Assert.True(v00 == ((5 <= x && x <= 7 && 5 <= y && y <= 7) ? 1 : 0), "v00 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v01 == ((5 <= x && x <= 7 && 4 <= y && y <= 6) ? 1 : 0), "v01 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v02 == ((5 <= x && x <= 7 && 3 <= y && y <= 5) ? 1 : 0), "v02 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v10 == ((4 <= x && x <= 6 && 5 <= y && y <= 7) ? 1 : 0), "v10 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v11 == ((4 <= x && x <= 6 && 4 <= y && y <= 6) ? 1 : 0), "v11 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v12 == ((4 <= x && x <= 6 && 3 <= y && y <= 5) ? 1 : 0), "v12 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v20 == ((3 <= x && x <= 5 && 5 <= y && y <= 7) ? 1 : 0), "v20 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v21 == ((3 <= x && x <= 5 && 4 <= y && y <= 6) ? 1 : 0), "v21 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                    Assert.True(v22 == ((3 <= x && x <= 5 && 3 <= y && y <= 5) ? 1 : 0), "v22 != 1 when x == " + x + " && y == " + y + " && i == " + i + " && j == " + j);
                }
            };
            var runtimeInput = new RuntimeLayer(inputA);
            var runtimeTest  = new RuntimeLayer(test);

            runtimeTest.SetInput(0, runtimeInput);

            // Test this stuff.
            for (int i = -10; i < 10; i++)
            {
                runtimeTest.GenerateData(i, i, i, 10, 10, 10, out computations);
            }
        }
Пример #7
0
        public void TestValues()
        {
            int computations;

            for (int v = -50; v < 50; v++)
            {
                var gradient = new RuntimeLayer(new AlgorithmConstant {
                    Constant = v
                });
                var result = gradient.GenerateData(-1, -1, -1, 3, 3, 3, out computations);

                for (var i = 0; i < 3; i++)
                {
                    for (var j = 0; j < 3; j++)
                    {
                        for (var k = 0; k < 3; k++)
                        {
                            Assert.Equal(result[i + j * 3 + k * 3 * 3], v);
                        }
                    }
                }
            }
        }
Пример #8
0
        public void TestRange()
        {
            int computations;
            var gradient = new RuntimeLayer(new AlgorithmInitialBool());
            var result   = gradient.GenerateData(0, 0, 0, 16, 16, 16, out computations);

            for (var i = 0; i < 16; i++)
            {
                for (var j = 0; j < 16; j++)
                {
                    for (var k = 0; k < 16; k++)
                    {
                        if (result[i + j * 16 + k * 16 * 16] == 0)
                        {
                            continue;
                        }

                        Assert.True(
                            result[i + j * 16 + k * 16 * 16] == 0 ||
                            result[i + j * 16 + k * 16 * 16] == 1);
                    }
                }
            }
        }
Пример #9
0
        private void ValidateLayer(RuntimeLayer runtime)
        {
            Assert.DoesNotThrow(() =>
            {
                var compiled = LayerCompiler.Compile(runtime);

                int computations;
                var runtimeData = runtime.GenerateData(-10, -10, -10, 20, 20, 20, out computations);
                var compiledData = compiled.GenerateData(-10, -10, -10, 20, 20, 20, out computations);
                for (var x = 0; x < 20; x++)
                    for (var y = 0; y < 20; y++)
                        for (var z = 0; z < 20; z++)
                            Assert.Equal(runtimeData[x + y*20 + z*20*20], compiledData[x + y*20 + z*20*20]);
            });
        }
Пример #10
0
        private static void ProvideBlocksToChunk(ProvideTask task)
        {
            if (m_ResultLayer == null)
            {
                throw new InvalidOperationException("No 3D store result layer was found in the world configuration.");
            }
            if (task == null)
            {
                return;
            }
            DateTime start = DateTime.Now;

            FilteredConsole.WriteLine(FilterCategory.OptimizationTiming, "Started with 0ms.");

            if (m_CurrentProvideState == null)
            {
                ProvideState ps = new ProvideState();
                ps.Blocks  = task.Blocks;
                ps.RawData = task.RawData;
                ps.Info    = task.Info;
                //ps.Z = task.Chunk.GlobalZ;
                ps.ProvideTask          = task;
                ps.OnSkipCallback       = task.OnSkipCallback;
                ps.OnGenerationCallback = task.OnGenerationCallback;
                m_CurrentProvideState   = ps;
            }

            // Generate or load data.
            int[] data = null;
            int   computations;

            if (m_CurrentProvideState.ProvideTask.Info.LevelDisk == null || !m_CurrentProvideState.ProvideTask.Info.LevelDisk.HasRegion(
                    m_CurrentProvideState.Info.Bounds.X,
                    m_CurrentProvideState.Info.Bounds.Y,
                    m_CurrentProvideState.Info.Bounds.Z,
                    m_CurrentProvideState.Info.Bounds.Width,
                    m_CurrentProvideState.Info.Bounds.Height,
                    m_CurrentProvideState.Info.Bounds.Depth))
            {
                data = m_ResultLayer.GenerateData(
                    m_CurrentProvideState.Info.Bounds.X,
                    m_CurrentProvideState.Info.Bounds.Y,
                    m_CurrentProvideState.Info.Bounds.Z,
                    (int)m_CurrentProvideState.Info.Bounds.Width,
                    (int)m_CurrentProvideState.Info.Bounds.Height,
                    (int)m_CurrentProvideState.Info.Bounds.Depth,
                    out computations);
            }
            else
            {
                data = m_CurrentProvideState.ProvideTask.Info.LevelDisk.ProvideRegion(
                    m_CurrentProvideState.Info.Bounds.X,
                    m_CurrentProvideState.Info.Bounds.Y,
                    m_CurrentProvideState.Info.Bounds.Z,
                    m_CurrentProvideState.Info.Bounds.Width,
                    m_CurrentProvideState.Info.Bounds.Height,
                    m_CurrentProvideState.Info.Bounds.Depth);
            }

            // Set up block mappings.
            for (int i = 0; i < m_CurrentProvideState.Info.Bounds.Width; i++)
            {
                for (int j = 0; j < m_CurrentProvideState.Info.Bounds.Height; j++)
                {
                    for (int k = 0; k < m_CurrentProvideState.Info.Bounds.Depth; k++)
                    {
                        int id = data[i + j * m_CurrentProvideState.Info.Bounds.Width + k * m_CurrentProvideState.Info.Bounds.Width * m_CurrentProvideState.Info.Bounds.Height];
                        m_CurrentProvideState.RawData[i + j * m_CurrentProvideState.Info.Bounds.Width + k * m_CurrentProvideState.Info.Bounds.Width * m_CurrentProvideState.Info.Bounds.Height] = id;
                        if (id == -1)
                        {
                            m_CurrentProvideState.Blocks[i, j, k] = null;
                        }
                        else
                        {
                            try
                            {
                                m_CurrentProvideState.Blocks[i, j, k] = Block.BlockIDMapping[data[i + j * m_CurrentProvideState.Info.Bounds.Width + k * m_CurrentProvideState.Info.Bounds.Width * m_CurrentProvideState.Info.Bounds.Height]];
                            }
                            catch (KeyNotFoundException)
                            {
                                m_CurrentProvideState.Blocks[i, j, k] = null;
                            }
                        }
                    }
                }
            }

            FilteredConsole.WriteLine(FilterCategory.OptimizationTiming, "Provided " + /*zcount +*/ " levels to chunk in " + (DateTime.Now - start).TotalMilliseconds + "ms.");

            // Signal finish.
            m_CurrentProvideState.OnGenerationCallback();
            m_CurrentProvideState = null;
        }
        private static Bitmap Regenerate3DImageForLayer(RuntimeLayer runtimeLayer, long ox, long oy, long oz, int width, int height, int depth, IGenerator compiledLayer = null)
        {
            int owidth  = width;
            int oheight = height;

            width  = 128;
            height = 192; // this affects bitmaps and rendering and stuff :(
            depth  = 128;

            // ARGHGHG FIXME
            Bitmap   b = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(b);

            g.Clear(Color.White);
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
            int     computations = 0;
            dynamic data;

            if (compiledLayer != null)
            {
                data = compiledLayer.GenerateData(ox, oy, oz, RenderWidth, RenderHeight, RenderDepth, out computations);
            }
            else
            {
                data = runtimeLayer.GenerateData(ox, oy, oz, RenderWidth, RenderHeight, RenderDepth, out computations);
            }

            StorageLayer parent;

            if (runtimeLayer.GetInputs().Length == 0)
            {
                parent = null;
            }
            else
            {
                parent = StorageAccess.FromRuntime(runtimeLayer.GetInputs()[0]);
            }

            int[] render  = GetCellRenderOrder(RenderToNE, RenderWidth, RenderHeight);
            int   ztop    = runtimeLayer.Algorithm.Is2DOnly ? 1 : RenderDepth;
            int   zbottom = 0;

            for (int z = zbottom; z < ztop; z++)
            {
                int rcx = width / 2 - 1;
                int rcy = height / 2 - 31;
                int rw  = 2;
                int rh  = 1;
                for (int i = 0; i < render.Length; i++)
                {
                    // Calculate the X / Y of the tile in the grid.
                    int x = render[i] % RenderWidth;
                    int y = render[i] / RenderWidth;

                    // Calculate the render position on screen.
                    int rx = rcx + (int)((x - y) / 2.0 * rw);// (int)(x / ((RenderWidth + 1) / 2.0) * rw);
                    int ry = rcy + (x + y) * rh - (rh / 2 * (RenderWidth + RenderHeight)) - (z - zbottom) * 1;

                    while (true)
                    {
                        try
                        {
                            Color lc = runtimeLayer.Algorithm.GetColorForValue(
                                parent,
                                data[x + y * owidth + z * owidth * oheight]);
                            SolidBrush sb = new SolidBrush(Color.FromArgb(lc.A, lc.R, lc.G, lc.B));
                            g.FillRectangle(
                                sb,
                                new Rectangle(rx, ry, rw, rh)
                                );
                            break;
                        }
                        catch (InvalidOperationException)
                        {
                            // Graphics can be in use elsewhere, but we don't care; just try again.
                        }
                    }
                }
            }

            return(b);
        }
Пример #12
0
        private static Bitmap RenderPartial3D(RuntimeLayer layer, int sx, int sy, int sz, int width, int height, int depth)
        {
            var bitmap   = new Bitmap(width * 2, height * 3);
            var graphics = Graphics.FromImage(bitmap);

            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
            int[] data;
            try
            {
                int computations;
                data = layer.GenerateData(TemporaryCrapBecauseIDidNotReallyDesignThingsVeryWell.X + sx, TemporaryCrapBecauseIDidNotReallyDesignThingsVeryWell.Y + sy, TemporaryCrapBecauseIDidNotReallyDesignThingsVeryWell.Z + sz, width, height, depth, out computations);

                var render  = GetCellRenderOrder(RenderToNE, width, height);
                var ztop    = layer.Algorithm.Is2DOnly ? 1 : depth;
                var zbottom = 0;
                for (var z = zbottom; z < ztop; z++)
                {
                    var rcx = width / 2 - 1 + 16;
                    var rcy = height / 2 - 15 + 32;
                    var rw  = 2;
                    var rh  = 1;
                    for (var i = 0; i < render.Length; i++)
                    {
                        // Calculate the X / Y of the tile in the grid.
                        var x = render[i] % width;
                        var y = render[i] / width;

                        // Calculate the render position on screen.
                        var rx = rcx + (int)((x - y) / 2.0 * rw);// (int)(x / ((RenderWidth + 1) / 2.0) * rw);
                        var ry = rcy + (x + y) * rh - (rh / 2 * (width + height)) - (z - zbottom) * 1;

                        while (true)
                        {
                            try
                            {
                                Color lc;
                                if (layer.GetInputs().Length > 0)
                                {
                                    lc = layer.Algorithm.GetColorForValue(
                                        StorageAccess.FromRuntime(layer.GetInputs()[0]),
                                        data[x + y * width + z * width * height]);
                                }
                                else
                                {
                                    lc = layer.Algorithm.GetColorForValue(
                                        null,
                                        data[x + y * width + z * width * height]);
                                }
                                var sb = new SolidBrush(Color.FromArgb(lc.A, lc.R, lc.G, lc.B));
                                graphics.FillRectangle(
                                    sb,
                                    new Rectangle(rx, ry, rw, rh)
                                    );
                                break;
                            }
                            catch (InvalidOperationException)
                            {
                                // Graphics can be in use elsewhere, but we don't care; just try again.
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            return(bitmap);
        }
Пример #13
0
        public void TestYSkew()
        {
            int computations;
            var input = new AlgorithmDebuggingInitialDelegate
            {
                ValueShouldBePlacedAt = (x, y, z) => (x == 0 && z == 0)
            };
            var passthrough       = new AlgorithmPassthrough();
            var runtimeInput      = new RuntimeLayer(input);
            var runtimePassthough = new RuntimeLayer(passthrough);

            runtimePassthough.SetInput(0, runtimeInput);

            // We need to check with various borders.
            for (var i = 0; i < 2; i++)
            {
                for (var j = 0; j < 2; j++)
                {
                    for (var k = 0; k < 2; k++)
                    {
                        passthrough.XBorder = i;
                        passthrough.YBorder = j;
                        passthrough.ZBorder = k;
                        var result = runtimePassthough.GenerateData(-16, 0, -16, 32, 32, 32, out computations);

                        // Test the area where we should be filled.
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.True(result[16 + y * 32 + 16 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value missing.");
                        }

                        // Test the areas where we should not be filled.
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[17 + y * 32 + 15 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (1, " + y + ", -1).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[16 + y * 32 + 15 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (0, " + y + ", -1).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[15 + y * 32 + 15 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (-1, " + y + ", -1).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[17 + y * 32 + 16 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (1, " + y + ", 0).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[15 + y * 32 + 16 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (-1, " + y + ", 0).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[17 + y * 32 + 17 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (1, " + y + ", 1).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[16 + y * 32 + 17 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (0, " + y + ", 1).");
                        }
                        for (var y = 0; y < 32; y += 1)
                        {
                            Assert.False(result[15 + y * 32 + 17 * 32 * 32] == 1, "Skew present on the Y axis with borders (" + i + ", " + j + ", " + k + "), value present at (-1, " + y + ", 1).");
                        }
                    }
                }
            }
        }
Пример #14
0
        public static void Main(string[] args)
        {
            var algorithmInitial                 = new AlgorithmInitialBool();
            var algorithmZoom2DIteration1        = new AlgorithmZoom2D();
            var algorithmZoom2DIteration2        = new AlgorithmZoom2D();
            var algorithmZoom2DIteration3        = new AlgorithmZoom2D();
            var algorithmZoom2DIteration4        = new AlgorithmZoom2D();
            var algorithmIncrementWaterDistance1 = new AlgorithmIncrementWaterDistance()
            {
                Initial = true
            };
            var algorithmIncrementWaterDistance2 = new AlgorithmIncrementWaterDistance();
            var algorithmIncrementWaterDistance3 = new AlgorithmIncrementWaterDistance();
            var algorithmIncrementWaterDistance4 = new AlgorithmIncrementWaterDistance();
            var runtimeInitial                 = new RuntimeLayer(algorithmInitial);
            var runtimeZoom2DIteration1        = new RuntimeLayer(algorithmZoom2DIteration1);
            var runtimeZoom2DIteration2        = new RuntimeLayer(algorithmZoom2DIteration2);
            var runtimeZoom2DIteration3        = new RuntimeLayer(algorithmZoom2DIteration3);
            var runtimeZoom2DIteration4        = new RuntimeLayer(algorithmZoom2DIteration4);
            var runtimeIncrementWaterDistance1 = new RuntimeLayer(algorithmIncrementWaterDistance1);
            var runtimeIncrementWaterDistance2 = new RuntimeLayer(algorithmIncrementWaterDistance2);
            var runtimeIncrementWaterDistance3 = new RuntimeLayer(algorithmIncrementWaterDistance3);
            var runtimeIncrementWaterDistance4 = new RuntimeLayer(algorithmIncrementWaterDistance4);

            runtimeZoom2DIteration1.SetInput(0, runtimeInitial);
            runtimeIncrementWaterDistance1.SetInput(0, runtimeZoom2DIteration1);
            runtimeZoom2DIteration2.SetInput(0, runtimeIncrementWaterDistance1);
            runtimeIncrementWaterDistance2.SetInput(0, runtimeZoom2DIteration2);
            runtimeZoom2DIteration3.SetInput(0, runtimeIncrementWaterDistance2);
            runtimeIncrementWaterDistance3.SetInput(0, runtimeZoom2DIteration3);
            runtimeZoom2DIteration4.SetInput(0, runtimeIncrementWaterDistance3);
            runtimeIncrementWaterDistance4.SetInput(0, runtimeZoom2DIteration4);

            runtimeInitial.Userdata                 = "runtimeInitial";
            runtimeZoom2DIteration1.Userdata        = "runtimeZoom2DIteration1";
            runtimeIncrementWaterDistance1.Userdata = "runtimeIncrementWaterDistance1";
            runtimeZoom2DIteration2.Userdata        = "runtimeZoom2DIteration2";
            runtimeIncrementWaterDistance2.Userdata = "runtimeIncrementWaterDistance2";
            runtimeZoom2DIteration3.Userdata        = "runtimeZoom2DIteration3";
            runtimeIncrementWaterDistance3.Userdata = "runtimeIncrementWaterDistance3";
            runtimeZoom2DIteration4.Userdata        = "runtimeZoom2DIteration4";
            runtimeIncrementWaterDistance4.Userdata = "runtimeIncrementWaterDistance4";

            EnableHandler = () =>
            {
                runtimeInitial.DataGenerated                 += HandleDataGenerated;
                runtimeZoom2DIteration1.DataGenerated        += HandleDataGenerated;
                runtimeIncrementWaterDistance1.DataGenerated += HandleDataGenerated;
                runtimeZoom2DIteration2.DataGenerated        += HandleDataGenerated;
                runtimeIncrementWaterDistance2.DataGenerated += HandleDataGenerated;
                runtimeZoom2DIteration3.DataGenerated        += HandleDataGenerated;
                runtimeIncrementWaterDistance3.DataGenerated += HandleDataGenerated;
                runtimeZoom2DIteration4.DataGenerated        += HandleDataGenerated;
                runtimeIncrementWaterDistance4.DataGenerated += HandleDataGenerated;
            };

            DisableHandler = () =>
            {
                runtimeInitial.DataGenerated                 -= HandleDataGenerated;
                runtimeZoom2DIteration1.DataGenerated        -= HandleDataGenerated;
                runtimeIncrementWaterDistance1.DataGenerated -= HandleDataGenerated;
                runtimeZoom2DIteration2.DataGenerated        -= HandleDataGenerated;
                runtimeIncrementWaterDistance2.DataGenerated -= HandleDataGenerated;
                runtimeZoom2DIteration3.DataGenerated        -= HandleDataGenerated;
                runtimeIncrementWaterDistance3.DataGenerated -= HandleDataGenerated;
                runtimeZoom2DIteration4.DataGenerated        -= HandleDataGenerated;
                runtimeIncrementWaterDistance4.DataGenerated -= HandleDataGenerated;
            };

            EnableHandler();

            var s = 64;
            var o = 10000000;
            int computations;

            runtimeIncrementWaterDistance4.GenerateData(-s + o, -s + o, -s + o, s * 2, s * 2, s * 2, out computations);
        }