-
Notifications
You must be signed in to change notification settings - Fork 9
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 checked attribute view and float generic in compute centroid #24
base: main
Are you sure you want to change the base?
add checked attribute view and float generic in compute centroid #24
Conversation
It would probably be better to take an I am happy to go in that direction though. |
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 agree that algorithms over attribute views would probably be better (though some algorithms might require multiple attributes or even mutate data, these would have to take a PointBuffer
). If you want to implement it as a PoC for the compute_centroid
function that would be fine for me, with the suggested changes (len
and is_empty
for the views). If not, I'm also fine with merging the changes as is.
Apart from that, for completeness there should be _checked
functions for the other view accessors as well, i.e. view
, view_attribute_with_conversion
and the mutable ones view_mut
and view_attribute_mut
. Would be great if you could add those.
What do you think about making Regardless, I removed that part of PR so that this one is focused on We can handle view_attribute_checked vs unchecked in a separate issue. |
778a1f1
to
94c1e43
Compare
if point_cloud.is_empty() { | ||
panic!("The point cloud is empty!"); | ||
pub fn compute_centroid<'a, 'b, T, F>( | ||
attribute_view: &AttributeView<'a, 'b, T, Vector3<F>> |
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.
AttributeView
is Copy
, so you can pass by value here. This prevents you from having to implement IntoIterator
for &AttributeView
#23
Downside of this approach is that it requires the user to specify if their pointcloud has f32 or f64 precision.
If it's important, we can maintain backwards compatibility with some clever naming.
\Edit: for centroid, which I used as an example, we could get around that with a private generic function and a public function that always returns f64 and checks the data_type of the point cloud attribute at runtime. I am not crazy about that solution though.