<div class="gmail_quote">On Tue, Mar 2, 2010 at 8:24 AM, Julien Gout <span dir="ltr">&lt;<a href="mailto:julien.gout@helmholtz-berlin.de">julien.gout@helmholtz-berlin.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">Hi everyone,<br>
<br>
I am trying to create voxel data from a mesh I extracted out of a blender<br>
project and save that data to a .tiff file.<br>
<br>
But apparently I fail to provide the right data format to vtkImageCast (or<br>
vtkImageWriter) resulting in the error<br>
<br>
ERROR: In /hmi/ftd/vtk/VTK/Imaging/vtkImageCast.cxx, line 149<br>
vtkImageCast (0x26114c0): Execute: Unknown input ScalarType<br>
<br>
Unfortunately the only example for the vtkVoxelModeller on the vtk Wiki<br>
pages is under the category &quot;Broken/Missing&quot;...<br>
<br>
Can anyone help with this?<br>
<br>
Here is my source code:<br>
<br>
import sys<br>
import bpy<br>
import vtk<br>
import VTKBlender<br>
<br>
print &quot;retrieve mesh data from blender&quot;<br>
appendFilter = vtk.vtkAppendPolyData()<br>
for me in bpy.data.meshes:<br>
    appendFilter.AddInput(VTKBlender.BlenderToPolyData(me))<br>
appendFilter.Update()<br>
<br>
mapper = vtk.vtkPolyDataMapper()<br>
mapper = appendFilter.GetOutput()<br>
<br>
print &quot;Voxelize mesh data&quot;<br>
x = y = z = 10<br>
xmin = ymin = zmin = -10.0<br>
xmax = ymax = zmax = 10.0<br>
voxeler = vtk.vtkVoxelModeller()<br>
voxeler.SetInput(mapper)<br>
voxeler.SetSampleDimensions(x, y, z)<br>
#voxeler.SetModelBounds(xmin, xmax, ymin, ymax, zmin, zmax)<br>
voxeler.Update()<br>
<br>
print &quot;Cast voxel data&quot;<br>
cast = vtk.vtkImageCast();<br>
cast.SetInputConnection(voxeler.GetOutputPort());<br>
cast.SetOutputScalarTypeToUnsignedChar()<br>
cast.Update()<br>
<br>
print &quot;write voxel data to .tif file&quot;<br>
aWriter = vtk.vtkImageWriter()<br>
aWriter.SetInputConnection(cast.GetOutputPort())<br>
aWriter.SetFileName(&quot;voxelModel.tif&quot;)<br>
aWriter.SetFileDimensionality(3)<br>
aWriter.Write()<br>
<br>
sys.exit(0)<br>
<br>
<br>
--<br>
Julien Gout<br>
<br>
Helmholtz-Zentrum Berlin für Materialien und Energie GmbH<br>
Institute of applied material sciences<br>
</div><div class="h5"><br></div></div></blockquote><div class="gmail_quote"><br></div>Can you describe what are you trying to get, exactly? You start with a mesh, and you want what?</div><div class="gmail_quote"><br clear="all">
Thanks,<br><br><div>David</div></div>