# Examples from pyvista.DataSetFilters.voxelize
# =============================================

# Create a voxelized mesh with uniform spacing.
import numpy as np
import pyvista as pv
from pyvista import examples
mesh = examples.download_bunny_coarse()
vox = mesh.voxelize(spacing=0.01)
vox.plot(show_edges=True)

# Create a voxelized mesh using non-uniform spacing.
vox = mesh.voxelize(spacing=(0.01, 0.005, 0.002))
vox.plot(show_edges=True)

# The bounds of the voxelized mesh always match the bounds of the input.
mesh.bounds

vox.bounds

# Create a voxelized mesh with `3 x 4 x 5` cells. Since `dimensions` is the
# number of points, not cells, we need to add `1` to get the number of desired cells.
mesh = pv.Box()
cell_dimensions = np.array((3, 4, 5))
vox = mesh.voxelize(dimensions=cell_dimensions + 1)
vox.plot(show_edges=True)

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

