jfjoch_writer: Grid scan Y was not saved properly

This commit is contained in:
2025-11-19 13:43:00 +01:00
parent 94f1b85fce
commit 4c8dd62613
2 changed files with 114 additions and 1 deletions

View File

@@ -420,3 +420,116 @@ TEST_CASE("GridScanSettings::Rearrange functionality tests", "[gridscan][rearran
}
}
}
TEST_CASE("GridScanSettings GetXContainer_m", "[GridScanSettings][container]") {
// Standard horizontal scan, step +2um X, +3um Y, 4 fast, 3 slow (12 total)
GridScanSettings grid_horiz(4, 2.0f, 3.0f, false, false);
grid_horiz.ImageNum(12); // 3 rows of 4
auto x_m = grid_horiz.GetXContainer_m(12);
REQUIRE(x_m.size() == 12);
// 0..3 should be X=0,2,4,6 um, Y=0
REQUIRE(x_m[0] == Catch::Approx(0.0));
REQUIRE(x_m[1] == Catch::Approx(2.0e-6));
REQUIRE(x_m[2] == Catch::Approx(4.0e-6));
REQUIRE(x_m[3] == Catch::Approx(6.0e-6));
// 4..7 should be X=0,2,4,6 um, Y=3 um
REQUIRE(x_m[4] == Catch::Approx(0.0));
REQUIRE(x_m[7] == Catch::Approx(6.0e-6));
// Last row
REQUIRE(x_m[8] == Catch::Approx(0.0));
REQUIRE(x_m[11] == Catch::Approx(6.0e-6));
// Snake raster test (horizontal, 3x2, fast +1um, slow +10um)
GridScanSettings grid_snake(3, 1.0f, 10.0f, true, false);
grid_snake.ImageNum(6); // 2 rows of 3
auto x_snake = grid_snake.GetXContainer_m(6);
// 0,1,2: left-to-right, 3,4,5: right-to-left
REQUIRE(x_snake[0] == Catch::Approx(0.0e-6));
REQUIRE(x_snake[1] == Catch::Approx(1.0e-6));
REQUIRE(x_snake[2] == Catch::Approx(2.0e-6));
REQUIRE(x_snake[3] == Catch::Approx(2.0e-6));
REQUIRE(x_snake[4] == Catch::Approx(1.0e-6));
REQUIRE(x_snake[5] == Catch::Approx(0.0e-6));
// Vertical scan, step X = 20um, fast Y = 5um, 2 fast, 3 slow (6 total)
GridScanSettings grid_vert(3, 20.0f, 5.0f, false, true);
grid_vert.ImageNum(6); // 2 columns, 3 rows (vertical fast)
auto x_vert = grid_vert.GetXContainer_m(6);
// First col: X=0, Y=0,5,10
REQUIRE(x_vert[0] == Catch::Approx(0.0));
REQUIRE(x_vert[1] == Catch::Approx(0.0));
REQUIRE(x_vert[2] == Catch::Approx(0.0));
// Second col: X=20um, Y=0,5,10
REQUIRE(x_vert[3] == Catch::Approx(20.0e-6));
REQUIRE(x_vert[5] == Catch::Approx(20.0e-6));
// Negative steps test
GridScanSettings grid_neg(3, -2.0f, -7.5f, false, false);
grid_neg.ImageNum(6); // 2 rows of 3
auto x_neg = grid_neg.GetXContainer_m(6);
REQUIRE(x_neg[0] == Catch::Approx(4.0e-6)); // 2*(3-1)
REQUIRE(x_neg[1] == Catch::Approx(2.0e-6));
REQUIRE(x_neg[2] == Catch::Approx(0.0));
}
TEST_CASE("GridScanSettings GetYContainer_m", "[GridScanSettings][container]") {
// Standard horizontal scan, step +2um X, +3um Y, 4 fast, 3 slow (12 total)
GridScanSettings grid_horiz(4, 2.0f, 3.0f, false, false);
grid_horiz.ImageNum(12); // 3 rows of 4
auto y_m = grid_horiz.GetYContainer_m(12);
REQUIRE(y_m.size() == 12);
for (int i = 0; i < 4; ++i)
REQUIRE(y_m[i] == Catch::Approx(0.0));
// 4..7 should be X=0,2,4,6 um, Y=3 um
REQUIRE(y_m[4] == Catch::Approx(3.0e-6));
REQUIRE(y_m[7] == Catch::Approx(3.0e-6));
// Last row
REQUIRE(y_m[8] == Catch::Approx(6.0e-6));
REQUIRE(y_m[11] == Catch::Approx(6.0e-6));
// Snake raster test (horizontal, 3x2, fast +1um, slow +10um)
GridScanSettings grid_snake(3, 1.0f, 10.0f, true, false);
grid_snake.ImageNum(6); // 2 rows of
auto y_snake = grid_snake.GetYContainer_m(6);
// 0,1,2: left-to-right, 3,4,5: right-to-left
// Both rows Y
for (int i = 0; i < 3; ++i)
REQUIRE(y_snake[i] == Catch::Approx(0.0));
for (int i = 3; i < 6; ++i)
REQUIRE(y_snake[i] == Catch::Approx(10.0e-6));
// Vertical scan, step X = 20um, fast Y = 5um, 2 fast, 3 slow (6 total)
GridScanSettings grid_vert(3, 20.0f, 5.0f, false, true);
grid_vert.ImageNum(6); // 2 columns, 3 rows (vertical fast)
auto y_vert = grid_vert.GetYContainer_m(6);
// First col: X=0, Y=0,5,10
REQUIRE(y_vert[0] == Catch::Approx(0.0));
REQUIRE(y_vert[1] == Catch::Approx(5.0e-6));
REQUIRE(y_vert[2] == Catch::Approx(10.0e-6));
// Second col: X=20um, Y=0,5,10
REQUIRE(y_vert[3] == Catch::Approx(0.0));
REQUIRE(y_vert[5] == Catch::Approx(10.0e-6));
// Negative steps test
GridScanSettings grid_neg(3, -2.0f, -7.5f, false, false);
grid_neg.ImageNum(6); // 2 rows of 3
auto y_neg = grid_neg.GetYContainer_m(6);
REQUIRE(y_neg[0] == Catch::Approx(7.5e-6));
REQUIRE(y_neg[1] == Catch::Approx(7.5e-6));
REQUIRE(y_neg[2] == Catch::Approx(7.5e-6));
REQUIRE(y_neg[3] == Catch::Approx(0.0));
REQUIRE(y_neg[4] == Catch::Approx(0.0));
REQUIRE(y_neg[5] == Catch::Approx(0.0));
}