Skip to content

Allow the pcl_uniform_sampling tool to deal with several formats (PCD, PLY and VTK) as input or output point cloud - #2348

Merged
taketwo merged 2 commits into
PointCloudLibrary:masterfrom
frozar:uniform_sampling
Jul 4, 2018
Merged

Allow the pcl_uniform_sampling tool to deal with several formats (PCD, PLY and VTK) as input or output point cloud#2348
taketwo merged 2 commits into
PointCloudLibrary:masterfrom
frozar:uniform_sampling

Conversation

@frozar

@frozar frozar commented Jun 20, 2018

Copy link
Copy Markdown
Contributor

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

@taketwo taketwo left a comment

Copy link
Copy Markdown
Member

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.

Comment thread tools/uniform_sampling.cpp Outdated
Eigen::Vector4f translation;
Eigen::Quaternionf orientation;
/** \brief File type for saving and loading files. */
typedef enum FileType

Copy link
Copy Markdown
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.

Comment thread tools/uniform_sampling.cpp Outdated
void
saveCloud (const string &filename, const pcl::PCLPointCloud2 &output)
saveCloud (const string &filename, const pcl::PCLPointCloud2 &output,
const FileType &output_file_type)

Copy link
Copy Markdown
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

frozar commented Jun 27, 2018

Copy link
Copy Markdown
Contributor Author

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 (".vtk");
p_file_indices = parse_file_extension_argument (argc, argv, extension);

if (p_file_indices.size () != 2)

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread 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 ());

Copy link
Copy Markdown
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