Closed rwbot closed 3 years ago
Can you describe your use case a bit more? What do you want to do with the voxels? Do you e.g. want to put something into the voxels? Usually, leaving the unused parts of the space empty makes the octree more efficient.
Can you describe your use case a bit more?
+1
But based on your description, does getLeafLayout
, getCentroidIndexAt
and getLeafLayout
in VoxelGrid
look right to you? getCentroidIndexAt
returns point index if the voxel is occupied or -1 if empty
@mvieth @tin1254 I'm working on the 3D tetris problem, and need an efficient way of representing the state of each voxel in order to know which voxels to place the next piece, and ultimately how much space was wasted after each attempt.
Can you describe your use case a bit more?
+1
But based on your description, does
getLeafLayout
,getCentroidIndexAt
andgetLeafLayout
inVoxelGrid
look right to you?getCentroidIndexAt
returns point index if the voxel is occupied or -1 if empty
@tin1254 so this is with VoxelGrid
, not with an Octree
type?
@tin1254 so this is with
VoxelGrid
, not with anOctree
type?
Yes. I guess both VoxelGrid
and Octree
can achieve your goal.
For Octree
you can look at isVoxelOccupiedAtPoint
in OctreePointCloud
(base of OctreePointCloudOccupancy
), if all you want is to query a voxel is empty or not
@rwbot Have you considered using a simple 3D array, maybe something like std::uint8_t voxels[100][100][100]
, or similar with std::array
or std::vector
, or even with std::vectory<bool>
if you want a very space-efficient solution and only care about occupied/not-occupied? Since you work on a discretized grid, not with continuous points, and don't need/want the adaptive voxelization that an octree gives, VoxelGrid
and Octree
seem to be more than necessary and maybe not the optimal datatype for you.
@tin1254 so this is with
VoxelGrid
, not with anOctree
type?Yes. I guess both
VoxelGrid
andOctree
can achieve your goal.For
Octree
you can look atisVoxelOccupiedAtPoint
inOctreePointCloud
(base ofOctreePointCloudOccupancy
), if all you want is to query a voxel is empty or not
@mvieth I do need the points for finding free space regions for different box sizes and orientations @tin1254 thanks i'll be using that
My goal is to take a point cloud of a space with volume 1m^3^ and discretize it in 1cm^3^ voxels and have a data structure containing each and every 1cm^3^ voxel, regardless if it's empty or occupied, so quite literally a grid of voxels, like the image below.
I've tried using the VoxelGrid class, but it returns only the occupied voxels. I've looked at the Spatial Partitioning and Search Operations with Octrees tutorial, and noticed there are other Octree types in the Additional Details section:
However, I'm having trouble understanding the use cases for the different types and interpreting their documentation. Specifically, the OctreePointCloudOccupancy class seems most suitable for my application, however, there are only two functions
setOccupiedVoxelAtPoint
andsetOccupiedVoxelsAtPointsFromCloud
, and while I see it inheritsgetOccupiedVoxelCenters
, I'm unable to find a function that returns the voxels that are empty.If this is an implemented functionality, could you point me to the documentation? If not, what are some suggestions to creating this functionality?