-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Wip: refactor PointcloudColorHandlerGenericField to deal with any field type #6309
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
base: master
Are you sure you want to change the base?
Wip: refactor PointcloudColorHandlerGenericField to deal with any field type #6309
Conversation
I ran the formatter to put my changes in these files, but unfortunately this has resulted in a large diff, as they seemed to not have followed the clang-format style file before. |
The style file has only been added a few years ago, and most of the code is not yet formatted according to it. We are slowly formatting more and more files, but we cannot format any files that are changed in any open pull request (otherwise the pull request would have merge conflicts and basically be lost). Unfortunately, with the formatting changes mixed in, this pull request is very difficult to review, as it is very time consuming to look for the changes you wanted to make originally. Is there any way you can revert the formatting changes in this pull request?
To be honest, I am not sure, but it is probably there for a reason so I would like to keep it. However, instead of the current structure (if-condition, then two for-loops, one for each case), you could probably merge the for-loops into one, then check something like |
88d0563
to
2556e89
Compare
I have recommitted without formatting changes outside of the affected class. also added the handling of non-xyz data as suggested, but have not tested it yet. |
…lerGenericField class
b5bfae2
to
7e7f343
Compare
CI seems to pass, i guess i should add some kind of test? |
That would be great. My suggestion: create a small cloud with maybe 4-5 points (manually), pass to color handler, then check if the array returned by |
Added a test which passes for me locally, but I don't think CI builds the visualization tests. (they are also disabled on macos, because the code only checks for UNIX + DISPLAY set, which doesn't exist on macos) |
Its run on the ubuntu CI's using xvfb - so should be good 👍 |
Can I get a review? |
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Outdated
Show resolved
Hide resolved
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Outdated
Show resolved
Hide resolved
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Outdated
Show resolved
Hide resolved
|
||
|
||
// Get point step. Does not directly exist in pcl::PointCloud | ||
template <typename CloudT> inline int getPointStep(const CloudT&) |
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 add these getters to their respective classes - even though they currently only a used here, I don't see why it shouldn't belong to the point_cloud/PCLPointCloud2 classes.
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 rather not add these as getters, I don't think they would be used that often
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Show resolved
Hide resolved
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Outdated
Show resolved
Hide resolved
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.
Sorry for the delay
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Outdated
Show resolved
Hide resolved
|
||
|
||
// Get point step. Does not directly exist in pcl::PointCloud | ||
template <typename CloudT> inline int getPointStep(const CloudT&) |
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 rather not add these as getters, I don't think they would be used that often
visualization/include/pcl/visualization/impl/point_cloud_color_handlers.hpp
Outdated
Show resolved
Hide resolved
visualization/include/pcl/visualization/point_cloud_color_handlers.h
Outdated
Show resolved
Hide resolved
I've moved some functions to io.h/hpp, but not kept some where they are since there are differing opinions it seems. I'm a bit annoyed that due to the new getFields() specialization we now get many of these warnings for all code that uses it with
|
275ea83
to
230e469
Compare
virtual std::string | ||
getName () const { return ("PointCloudColorHandlerGenericField"); } | ||
/** \brief Name of the field used to create the color handler. */ | ||
std::string field_name_; |
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.
Could this be private, like before?
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.
fixed
Co-authored-by: Markus Vieth <[email protected]>
return std::distance(fields.begin(), result); | ||
} | ||
|
||
// Cloud type agnostic isXYZFinite wrappers to check if pointcloud or PCLPointCloud2 at |
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.
Should we move these XYZFinite next to the others in https://github.com/PointCloudLibrary/pcl/blob/f5fd21531b6cb19724227490949e66b5ce171075/common/include/pcl/common/point_tests.h ?
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.
Hmm, maybe not, since one of the methods require getFieldIndex, which would give circular dependency.
Resolve conflict and its 👍 from here. |
} | ||
} | ||
|
||
int point_offset = this->fields_[this->field_idx_].offset; |
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.
A rather minor thing, but could make sense to use std::size_t
here to also make it work with larger clouds (because it holds the offset in bytes, for every point).
Resolves #6306
Partially resolves #6186