public void TestValueRetrievalAcrossBorder() { 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) => { var v00 = input[((i - 1) + ox) + ((j - 1) + oy)*width + (k + oz)*width*height]; var v01 = input[((i - 1) + ox) + ((j + 0) + oy)*width + (k + oz)*width*height]; var v02 = input[((i - 1) + ox) + ((j + 1) + oy)*width + (k + oz)*width*height]; var v10 = input[((i + 0) + ox) + ((j - 1) + oy)*width + (k + oz)*width*height]; var v11 = input[((i + 0) + ox) + ((j + 0) + oy)*width + (k + oz)*width*height]; var v12 = input[((i + 0) + ox) + ((j + 1) + oy)*width + (k + oz)*width*height]; var v20 = input[((i + 1) + ox) + ((j - 1) + oy)*width + (k + oz)*width*height]; var v21 = input[((i + 1) + ox) + ((j + 0) + oy)*width + (k + oz)*width*height]; var 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 = this.CreateRuntimeLayer(inputA); var runtimeTest = this.CreateRuntimeLayer(test); runtimeTest.SetInput(0, runtimeInput); // Test this stuff. for (var i = -10; i < 10; i++) { int computations; runtimeTest.GenerateData(i, i, i, 10, 10, 10, out computations); } }
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); } }
public void TestForOCXOddAdjustmentShutterBug() { int computations; var input = new AlgorithmDebuggingInitialDelegate { ValueShouldBePlacedAt = (x, y, z) => true, ShowAs2D = true }; var zoom = new AlgorithmZoom2D { Mode = ZoomType.Square }; var runtimeInput = this.CreateRuntimeLayer(input); var runtimeZoom = this.CreateRuntimeLayer(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] == 1, "OCX odd adjustment shutter bug is present, where every odd row is blank when main adjustment is an odd number."); }
public void TestYSkew() { int computations; var input = new AlgorithmDebuggingInitialDelegate { ValueShouldBePlacedAt = (x, y, z) => (x == 0 && z == 0) }; var passthrough = new AlgorithmPassthrough(); var runtimeInput = this.CreateRuntimeLayer(input); var runtimePassthough = this.CreateRuntimeLayer(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)."); } }
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)."); } } } } }