This function polygon2function will convert a Triangulated Mesh into a Voxel Volume which will contain the discretized mesh.
Discretization of a polygon is done by splitting the polygon in smaller polygons, until the longest edge is smaller than 0.5 voxel, then the voxel beneath the vertice coordinates is set to one.
The function is fast because the main function is implemented in c-code /mex file (takes seconds on a core 2 duo with function compiled by Microsoft Visual Studio 2008.).
Try the example.
Bugs, successes and other comments are welcome!