Skip to content

Commit

Permalink
#95: fix missing output jitter file
Browse files Browse the repository at this point in the history
  • Loading branch information
tlamonthezie committed Jul 30, 2024
1 parent 8779eae commit c9b8fc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/unit/render/test_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class RenderTest :public ::testing::TestWithParam<std::string> {
}

std::unordered_map<ElementIDType, std::array<double, 3>> loadJitterDims(std::string filename) {
fmt::print("Loading jitter dimensions from {}\n", filename);
std::unordered_map<ElementIDType, std::array<double, 3>> jitter_dims;
std::ifstream infile(filename);
std::string line;
Expand Down Expand Up @@ -210,7 +211,8 @@ class RenderTest :public ::testing::TestWithParam<std::string> {
}

void saveJitterDims( std::unordered_map<ElementIDType, std::array<double, 3>> jitter_dims_, std::string filename) {
std::ofstream outfile(fmt::format("{}_{}", std::to_string(std::time(nullptr)), filename));
fmt::print("Saving jitter dimensions to {}\n", filename);
std::ofstream outfile(filename);
for (auto const& [objectID, dims] : jitter_dims_) {
outfile << fmt::format("{},{},{},{}\n", objectID, dims[0], dims[1], dims[2]);
}
Expand All @@ -235,12 +237,10 @@ TEST_P(RenderTest, test_render_from_config_with_png) {
Render render = createRender(config, info, output_dir);
std::filesystem::create_directories(output_dir);

auto object_jitter_dims_file = fmt::format("{}{}", output_dir, "object_jitter_dims.csv");
auto object_jitter_dims_file = fmt::format("{}{}", output_dir, config_file.substr(0, config_file.size()-5), "jitter_dims.csv");
if (std::filesystem::exists(object_jitter_dims_file)) {
fmt::print("Loading jitter dimensions from {}\n", object_jitter_dims_file);
render.setJitterDims(loadJitterDims(object_jitter_dims_file));
} else {
fmt::print("Saving jitter dimensions to {}\n", object_jitter_dims_file);
saveJitterDims(render.getJitterDims(), object_jitter_dims_file);
}

Expand Down

0 comments on commit c9b8fc5

Please sign in to comment.