# Conservative voxelization in gptoolbox

## Alec Jacobson

## November 03, 2015

A while ago I implemented a function to voxelize a given triangle mesh in matlab as part of gptoolbox. Rather than use 3D-Bresenham-style rasterization, I needed a *conservative* voxelization: where every point (not just vertex) on the mesh is contained inside the voxelization. In other words, output all voxels that intersect the triangle mesh.

Here's a little snippet to produce the following meshes:

```
for k = [10 20 40 80]
[W,BC,DV,Q] = voxelize(V,F,k,'Pad',1);
[DV,I] = remove_unreferenced(DV,Q);
Q = I(Q);
d = render_in_cage(V,F,DV,Q,'ColorIntersections',false);
d.tc.LineWidth = 2;
end
```