-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
tools/uniform_sampling.cpp
Outdated
Eigen::Vector4f translation; | ||
Eigen::Quaternionf orientation; | ||
/** \brief File type for saving and loading files. */ | ||
typedef enum FileType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In C++ you don't need to typedef
enumerations. You can safely remove typedef
and the second FileType
.
tools/uniform_sampling.cpp
Outdated
|
||
// Convert data back | ||
toPCLPointCloud2 (output_, output); | ||
} | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 (".ply"); | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. So I'll make a proposition soon.
tools/uniform_sampling.cpp
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_sampling
tool to deal with several formats (PCD, PLY and VTK) as input or output point cloud.