Closed GuillaumeBroggi closed 1 month ago
Thank you for your suggestion. How about add it as an new option first? If the new method is better, we can make anothor breaking-change and make it the default. Pull requests are always welcome.
In that case, I can start with the following signature that will not break anything:
voxelize(mesh, density=None, check_surface=True, enclosed=False, include_end_bound=False)
Maybe it could be made into a more generic function in the future, something like (just writing down some ideas):
voxelize(mesh, density=None, check_surface=True, range=["include", "exclude"])
where the behavior are defined for each bound:
float
: explicit value for the bound"exclude"
: exclude the bound "include"
: include the bound"enclosed"
: pad the mesh to ensure the bound is enclosedThe current behavior would be achieved with range=["include", "exclude"]
. Using range=[float, float]
or range=["include", "include"]
would update the density
if required to accommodate both bounds.
Awesome. Let's try it!
Implemented in both #6610 and #6611
Describe the feature you would like to be added.
Voxelizing a mesh with
pv.voxelize()
orpv.voxelize_volume()
will crop the mesh.For instance, for a simple cube with the default parameters, the mesh bounds are
[-0.5, 0.5]
:After voxelization, the mesh bounds are
[-0.5, 0.3]
, the missing0.2
corresponding to a missing row of cells:One could expect the cube mesh to remain whole. Even if cropping is the intended behavior, there is no straightforward method to obtain a complete voxelized mesh of the cube.
As mentioned in https://github.com/pyvista/pyvista/issues/4312#issuecomment-1516994440, using
np.linspace()
instead ofnp.arange()
would implement the proposed feature. Would a PR implementing this be welcome, or would it bring unwanted side effects?Note
https://github.com/pyvista/pyvista/pull/6514 does not implement this behavior, instead the mesh is padded to enclose the cube: