Skip to content

Commit fc5599f

Browse files
committed
Use std::filesystem::path in scm-to-cereal
We set the cxxopts type to std::string, and then read it into a filesystem::path. Due to jarro2783/cxxopts#439 we don't use filesystem::path with cxxopts directly. Like this, we can read paths with spaces using "\...path with space\" in launch.vs.json, and paths without spaces without the extra quotes.
1 parent 67a6d34 commit fc5599f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

utils/scm-to-cereal.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <string>
2626
#include <iostream>
27+
#include <filesystem>
2728

2829
/**
2930
* Reads a CVSSP .scm Morphable Model file and converts it
@@ -46,7 +47,7 @@ int main(int argc, char* argv[])
4647
cxxopts::value<std::string>()->default_value("converted_model.bin"), "filename");
4748
// clang-format on
4849

49-
std::string scmmodelfile, outputfile;
50+
std::filesystem::path scmmodelfile, outputfile;
5051
std::optional<std::string> isomapfile;
5152
bool save_shape_only;
5253

@@ -77,18 +78,18 @@ int main(int argc, char* argv[])
7778

7879
// Load the .scm Morphable Model and save it as cereal model:
7980
morphablemodel::MorphableModel morphable_model =
80-
morphablemodel::load_scm_model(scmmodelfile, isomapfile);
81+
morphablemodel::load_scm_model(scmmodelfile.string(), isomapfile);
8182

8283
if (save_shape_only)
8384
{
8485
// Save only the shape model - to generate the public sfm_shape_3448.bin
8586
const morphablemodel::MorphableModel shape_only_model(morphable_model.get_shape_model(),
8687
morphablemodel::PcaModel(), std::nullopt,
8788
morphable_model.get_texture_coordinates());
88-
morphablemodel::save_model(shape_only_model, outputfile);
89+
morphablemodel::save_model(shape_only_model, outputfile.string());
8990
} else
9091
{
91-
morphablemodel::save_model(morphable_model, outputfile);
92+
morphablemodel::save_model(morphable_model, outputfile.string());
9293
}
9394

9495
std::cout << "Saved converted model as " << outputfile << "." << std::endl;

0 commit comments

Comments
 (0)