Skip to content

Commit

Permalink
minor change on IO
Browse files Browse the repository at this point in the history
  • Loading branch information
chenweikai committed Jun 16, 2022
1 parent 890643b commit 102a9b2
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions data_generation/src/batch_generate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ int main(int argc, char** argv) {
std::string out_recon_ply_dir = "../output/PLY";
std::string todo_filename = "../data/todo.txt"; // a txt file containing the names of the subjects to be computed
std::vector<std::string> todo_list;
std::ifstream fin;
fin.open(todo_filename);
std::string name;
while (fin >> name) {
todo_list.push_back(name);
}

int octree_depth = 9;
int octree_depth = 7;
int write_ply = 0;
int write_sdf = 1;
int write_obj = 1;
Expand All @@ -33,7 +39,6 @@ int main(int argc, char** argv) {
std::cout << "usage: ./batch_generate input_mesh_dir out_sdf_dir out_recon_obj_dir out_ply_dir octree_depth flag_writeSDF [Default: 1] flag_writeOBJ [Default: 1] flag_writePLY [Default: 0] [todo_list.txt (optional)]" << std::endl;
std::cout << "Insufficient input argument. Please refer to the usage info for more details. Currently run the default setting for illustration!" << std::endl;
} else {

input_data_dir = std::string(argv[1]);
out_sdf_dir = std::string(argv[2]);
out_recon_obj_dir = std::string(argv[3]);
Expand All @@ -43,16 +48,33 @@ int main(int argc, char** argv) {
write_obj = atoi(argv[7]);
write_ply = atoi(argv[8]);

if (argc >= 10) {
todo_filename = std::string(argv[9]);
} else {
// If no todo list is provided, collect all the samples under the input data directory.
todo_list.clear();
for (const auto & entry : fs::directory_iterator(input_data_dir)) {
std::string path = entry.path();
std::string ext = path.substr(path.find_last_of("."));
// Currently only load obj files
if (ext == "obj") {
std::string base_filename = path.substr(path.find_last_of("/\\") + 1, path.find_last_of(".") - path.find_last_of("/\\") - 1);
todo_list.push_back(base_filename);
}
}
}
}

if (todo_list.empty()) {
std::ifstream fin;
fin.open(todo_filename);
std::string name;
while (fin >> name) {
todo_list.push_back(name);
}
std::cout << std::endl;
}


if (!fs::exists(input_data_dir)) {
std::cout << "Cannot find the input data directory!" << std::endl;
std::exit(0);
Expand Down Expand Up @@ -93,7 +115,7 @@ int main(int argc, char** argv) {
std::string recon_obj_name = out_recon_obj_dir + "/" + subject + ".obj";
std::string output_ply_name = out_recon_obj_dir + "/" + subject + ".ply";

GenerateOctree3psdfSamples(input_obj_name, sdf_name, recon_obj_name, output_ply_name, octree_depth, write_ply, write_obj, write_sdf);
GenerateOctree3psdfSamples(input_obj_name, sdf_name, recon_obj_name, output_ply_name, octree_depth, write_sdf, write_obj, write_ply);
}

return 1;
Expand Down

0 comments on commit 102a9b2

Please sign in to comment.