-
-
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
Add clouds/meshes file format converter #1442
Add clouds/meshes file format converter #1442
Conversation
A first review would be appreciated, the program is working fine though I have not extensively tested it. |
if (pcl::console::find_switch (argc, argv, "-h") != 0 || pcl::console::find_switch (argc, argv, "--help") != 0) | ||
{ | ||
displayHelp (argc, argv); | ||
return (-1); |
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.
I would return 0 here.
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.
Agreed
Looking forward to see this merged :) |
I think I fixed everything above, the program is now "finished". Give it a test and tell me if something is wrong! |
//TODO: Support precision | ||
//FIXME: Color is lost during conversion (OBJ supports color) | ||
if (output_type == BINARY || output_type == BINARY_COMPRESSED) | ||
PCL_WARN ("OBJ file format supports only ASCII.\n"); |
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.
This warning will also be printed in saveMesh()
better to just remove it. This branch of your if statement can pretty much disappear and be moved to the else branch with ply and vtk.
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.
True, I fixed that. Interestingly savePolygonFile
does not allow to save OBJ files.
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.
Looked at the source and it definitely looks like bug, especially given the fact that you can load OBJ files in the function above :D
If you patched it you could even move L155-165 into L174-188 adding the additional check for the output_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.
Forget about my last suggestion. I just noticed that there are seemingly close functionalities implemented in pcl::io::save
and pcl::io::savePolygonFile
. This should probably be addressed in another pull request. Thanks for you effort!
I've just added an option to transform a mesh into a point cloud using the |
Oh that's right I must have not read the right lines when reading your comment 😄 |
@jspricke Friendly pi(n)g 🐷 |
/* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2009, Willow Garage, Inc. |
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.
Can you update the copyright?
Victor, great work! I find the filename argument handling to be unnecessary verbose though. Instead of lines 213-217, 223-228, 247-265 we can write something like (untested): const std::vector<std::string> supported_extensions = {".obj", ".pcd", ".ply", ".stl", ".vtk"};
std::vector<int> file_args;
for (int i = 1; i < argc; ++i)
for (size_t j = 0; j < supported_extensions.size (); ++j)
if (boost::algorithm::ends_with (argv[i], supported_extensions[j])
{
file_args.push_back (i);
break;
}
if (file_args.size () != 2)
// error message, return
std::string input = argv[file_args[0]];
std::string output = argv[file_args[1]]; |
I've done it your way Sergey, it's shorter and still very readable. I did not use the C++11 vector initializer because C++11 is not enabled in PCL. |
Yeah, right, I suspected that line would not compile with the old standard :) What about the name of the tool, maybe just |
Now it's named |
Thanks! I haven't tried it, but the code looks good for me. Do we want to merge this before the release or immediately after? |
I don't mind; I think it's a useful tool so I would merge before. |
Agree with Victor on both statements. Kudos for your massive changelog Sergey ;) |
Thanks guys. |
Add clouds/meshes file format converter
Aims to replace:
This will also add STL format converter.