Description
Is your feature request related to a problem? Please describe.
Raised while refactoring VoxelGrid #4829 (review)
As we are upgrading point hash datatype from int
to size_t
, the API std::vector<int> getLeafLayout()
is not compatible anymore
Context
Reasons to upgrade to size_t
: #4365 #585
Expected behavior
Users can query the voxel index using point coordinate or point hash
Current Behavior
We can query the voxel index using point coordinate with int getCentroidIndexAt(const Eigen::Vector3i&)
.
But if we wanted to query using point hash, we will need to first get a large vector with std::vector<int> getLeafLayout()
, and query with the vector
Describe the solution you'd like
Use the following functions to replace getLeafLayout()
to avoid return large vector when we upgrade to size_t
.
leaf_layout_
will be a unordered_map
// int -> size_t
size_t getCentroidIndexAt(const Eigen::Vector3i& pt) { return leaf_layout_[hashPoint(pt)]; }
// new function
size_t getCentroidIndexAtLeafIdx(const size_t idx) { return leaf_layout_[idx]; }
Describe alternatives you've considered
Same as above, but leaf_layout_
is avector<size_t>