trimesh.voxel.creation module¶
- trimesh.voxel.creation.local_voxelize(mesh, point, pitch, radius, fill=True, **kwargs)¶
Voxelize a mesh in the region of a cube around a point. When fill=True, uses proximity.contains to fill the resulting voxels so may be meaningless for non-watertight meshes. Useful to reduce memory cost for small values of pitch as opposed to global voxelization.
- Parameters:
mesh (trimesh.Trimesh) – Source geometry
point ((3, ) float) – Point in space to voxelize around
pitch (float) – Side length of a single voxel cube
radius (int) – Number of voxel cubes to return in each direction.
kwargs (parameters to pass to voxelize_subdivide)
- Returns:
voxels – or None if the volume is empty
- Return type:
VoxelGrid instance with resolution (m, m, m) where m=2*radius+1
- trimesh.voxel.creation.voxelize(mesh, pitch, method='subdivide', **kwargs)¶
Voxelize the given mesh using the specified implementation.
See voxelizers for available implementations or to add your own, e.g. via voxelizers[‘custom_key’] = custom_fn.
custom_fn should have signature (mesh, pitch, **kwargs) -> VoxelGrid and should not modify encoding.
- Parameters:
mesh (Trimesh object (left unchanged).)
pitch (float, side length of each voxel.)
method (implementation method. Must be in fillers.)
**kwargs (additional kwargs passed to the specified implementation.)
- Return type:
A VoxelGrid instance.