Allow the pcl_uniform_sampling tool to deal with several formats (PCD, PLY and VTK) as input or output point cloud - #2348
Conversation
73957ca to
e17505f
Compare
taketwo
left a comment
There was a problem hiding this comment.
But actually, I don't see why we need an enum at all. The logic that determines the output part (lines 186 through 199) can be moved directly inside the save function.
| Eigen::Vector4f translation; | ||
| Eigen::Quaternionf orientation; | ||
| /** \brief File type for saving and loading files. */ | ||
| typedef enum FileType |
There was a problem hiding this comment.
In C++ you don't need to typedef enumerations. You can safely remove typedef and the second FileType.
| void | ||
| saveCloud (const string &filename, const pcl::PCLPointCloud2 &output) | ||
| saveCloud (const string &filename, const pcl::PCLPointCloud2 &output, | ||
| const FileType &output_file_type) |
There was a problem hiding this comment.
enum is an integral type, so better passed by value.
|
You're right, the The logic I had in mind when I do it is that I don't want to launch any computation without a minimal checking of the argument:
So this is done in the beginning of the main function and will save time with a try/error approach around this tool. The |
| extension.push_back (".vtk"); | ||
| p_file_indices = parse_file_extension_argument (argc, argv, extension); | ||
|
|
||
| if (p_file_indices.size () != 2) |
There was a problem hiding this comment.
if the ouput format at least is supported.
This line effectively checks that. If the format of the output file is not supported, then we won't have two file names parsed.
There was a problem hiding this comment.
You're right. So I'll make a proposition soon.
| std::string input_filename = argv[p_file_indices[0]]; | ||
| ifstream ifile (input_filename.c_str ()); | ||
| if (!ifile) { | ||
| print_error ("Cannot found input file name (%s).\n", input_filename.c_str ()); |
There was a problem hiding this comment.
We can move this to line 75, where pcl::io::load returns read status. Otherwise we are opening input file two times.
pcl_uniform_sampling tool to deal with several formats (PCD, PLY and VTK) as input or output point cloud
Warning: this PR is based onto #2347
Allow the
pcl_uniform_samplingtool to deal with several formats (PCD, PLY and VTK) as input or output point cloud.