Skip to content
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

Merged
merged 2 commits into from
Jul 4, 2018

Conversation

frozar
Copy link
Contributor

@frozar frozar commented Jun 20, 2018

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.

@frozar frozar force-pushed the uniform_sampling branch 4 times, most recently from 73957ca to e17505f Compare June 25, 2018 12:18
Copy link
Member

@taketwo taketwo left a 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.

Eigen::Vector4f translation;
Eigen::Quaternionf orientation;
/** \brief File type for saving and loading files. */
typedef enum FileType
Copy link
Member

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.


// 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)
Copy link
Member

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.

@frozar frozar force-pushed the uniform_sampling branch from e17505f to 8229704 Compare June 27, 2018 08:31
@frozar
Copy link
Contributor Author

frozar commented Jun 27, 2018

You're right, the enum FileType is not strictly necessary.

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:

  • if the input file at least exists,
  • if the ouput format at least is supported.

So this is done in the beginning of the main function and will save time with a try/error approach around this tool.

The enum is just there because I feel like it makes it clearer. That's my two cents.

extension.push_back (".ply");
extension.push_back (".vtk");
p_file_indices = parse_file_extension_argument (argc, argv, extension);

if (p_file_indices.size () != 2)
Copy link
Member

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.

Copy link
Contributor Author

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.

@frozar frozar force-pushed the uniform_sampling branch from 8229704 to 051a2ff Compare June 27, 2018 15:59
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 ());
Copy link
Member

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.

@frozar frozar force-pushed the uniform_sampling branch from 051a2ff to 1aafc85 Compare June 29, 2018 23:18
@taketwo taketwo merged commit 1f22654 into PointCloudLibrary:master Jul 4, 2018
@frozar frozar deleted the uniform_sampling branch July 5, 2018 12:49
@SergioRAgostinho SergioRAgostinho changed the title [TOOL] Uniform sampling Allow the pcl_uniform_sampling tool to deal with several formats (PCD, PLY and VTK) as input or output point cloud Sep 2, 2018
@SergioRAgostinho SergioRAgostinho added the changelog: enhancement Meta-information for changelog generation label Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: enhancement Meta-information for changelog generation module: tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants