Skip to content

[filters/VoxelGrid] Provide a way to override CentroidPoint or add my own Accumulators #6340

@jackjansen

Description

@jackjansen

Context

I have defined my own points, with x, y, z and color, and an extra field that is essentially a bit mask.
I have been using this for years, and it works fine everywhere, with the exception of VoxelGrid.

VoxelGrid uses CentroidPoint to combine points, and it uses a set of predefined Accumulators to combine the fields within points according to the correct semantics for those fields.

This works fine for coordinates, normals, colours and a few other attribute types that pcl support, but there does not appear to be a way to extend the field types supported by supplying my own Accumulator type for my bit mask fields (which would is essence do a bitwise or on the fields in the incoming points).

With the current code structure it is impossible to override any of the implementations without copying everything up to VoxelGrid into my own code, which seems a bit gross.

Expected behavior

I would like to have full control over the way attributes of my points are treated, especially attributes that pcl doesn't know about as distributed because they are specific to my usage, but I can also see use cases for enabling use of different combination strategies for "standard" attributed like position or color.

Current Behavior

Currently I keep the leaf layout and then make an extra pass over the source points, call getCentroidIndex() and then manually modify the field.

Describe the solution you'd like

If I could override CentroidPoint when instantiating VoxelGrid I would only need to subclass CentroidPoint to do what I want. And I think it would allow all sorts of potentially useful other uses as well (for example create a CentroidPoint that uses a completely different way of combining points. I can think of random selection, for example, or modifying some attributes based on the values of some other attributes.

Describe alternatives you've considered

An alternative that would work for my use case is if I could add my own Accumulator implementation to the Accumulator.types list, but I'm not sure that there is a construct in C++ that would allow that.

Additional context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions