# Conversion of STL files to 3D Images

I am trying to convert some stl files to 3d images in MMA 11.3. I came across this post that contained some code making use of parallelization to speed up the process, as follows:

voxelify[region_?RegionQ, res_?NumericQ] :=

Module[{f, bounds, boxsize, voxsize, data, d2},
f = RegionDistance[region];
bounds = RegionBounds[region];
boxsize = -Subtract @@ # & /@ bounds;
voxsize = Max[boxsize]/res;
data = ParallelArray[f[{##}] &, Round[boxsize/voxsize], bounds];
d2 = HeavisideTheta[data - voxsize];
2 - ReplaceAll[WatershedComponents[Image3D[1 - d2]], {0 -> 2}]
]


Very nice. Unfortunately it doesnt work, but produces an error message:

It then proceeds with a very slow sequential evaluation taking several minutes, rather than seconds.

Thinking that perhaps this was due to changes in the functionality of ParallelArray, I reinstalled MMA10.0, then MMA10.3, but they both produced the same error. I have no idea how the OP got the code to work originally.

Is anyone able to suggest a fix for this code? Or an alternative approach that is equally efficient?