Skip to content

Commit

Permalink
output/reference: A proper collapse support (non-working)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Dec 28, 2024
1 parent 3f6a36b commit 69c90e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
40 changes: 24 additions & 16 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,9 @@ int F3DStarter::Start(int argc, char** argv)
f3d::log::debug("========== Configuring engine ==========");

double deltaTime = 1.0 / this->Internals->AppOptions.FrameRate;
const std::string& reference = this->Internals->AppOptions.Reference;
const std::string& output = this->Internals->AppOptions.Output;

fs::path reference(f3d::utils::collapsePath(this->Internals->AppOptions.Reference));
fs::path output(f3d::utils::collapsePath(this->Internals->applyFilenameTemplate(this->Internals->AppOptions.Output)));

if (this->Internals->AppOptions.NoRender)
{
Expand Down Expand Up @@ -1002,21 +1003,29 @@ int F3DStarter::Start(int argc, char** argv)
return EXIT_FAILURE;
}

if (!fs::exists(reference))
try
{
if (output.empty())
{
f3d::log::error("Reference image ", reference,
" does not exist, use the output option to output current rendering into an image "
"file.\n");
}
else
if (!fs::exists(reference))
{
window.renderToImage(this->Internals->AppOptions.NoBackground).save(output);
if (output.empty())
{
f3d::log::error("Reference image ", reference,
" does not exist, use the output option to output current rendering into an image "
"file.\n");
}
else
{
window.renderToImage(this->Internals->AppOptions.NoBackground).save(output);

f3d::log::error("Reference image " + reference +
" does not exist, current rendering has been outputted to " + output + ".\n");
f3d::log::error("Reference image ", reference,
" does not exist, current rendering has been outputted to ", output, ".\n");
}
return EXIT_FAILURE;
}
}
catch (const std::filesystem::filesystem_error& ex)
{
f3d::log::error("Error reading reference image: ", ex.what());
return EXIT_FAILURE;
}

Expand Down Expand Up @@ -1072,9 +1081,8 @@ int F3DStarter::Start(int argc, char** argv)
}
else
{
fs::path path = this->Internals->applyFilenameTemplate(output);
img.save(path.string());
f3d::log::debug("Output image saved to ", path);
img.save(output);
f3d::log::debug("Output image saved to ", output);
}

if (this->Internals->FilesGroups.size() > 1)
Expand Down
6 changes: 6 additions & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,12 @@ add_test(NAME f3d::TestNoFileFileNameTemplate COMMAND $<TARGET_FILE:f3d> --outpu
set_tests_properties(f3d::TestNoFileFileNameTemplate PROPERTIES PASS_REGULAR_EXPRESSION "Output image saved to \".*/Testing/Temporary/no_file.png\"")
set_tests_properties(f3d::TestNoFileFileNameTemplate PROPERTIES ENVIRONMENT "CTEST_F3D_NO_DATA_FORCE_RENDER=1")

if(NOT WIN32)
# Test output to HOME
add_test(NAME f3d::TestOutputToHOME COMMAND $<TARGET_FILE:f3d> ${F3D_SOURCE_DIR}/testing/data/suzanne.stl --output=~/Testing/Temporary/TestOutputToHOME.png --resolution=300,300)
set_tests_properties(f3d::TestOutputToHOME PROPERTIES ENVIRONMENT "HOME=${CMAKE_BINARY_DIR}")
endif()

# Test failure without a reference, please do not create a TestNoRef.png file
f3d_test(NAME TestNoRef DATA cow.vtp WILL_FAIL)

Expand Down

0 comments on commit 69c90e3

Please sign in to comment.