Dear David,

Thank you very much for your hint. I am not completely familiar with 
python shell access to paraview (but have some experience with vtk +
python).  I naively tried this:

  ViewProxy = paraview.servermanager.vtkSMRenderViewProxy()
  RenWin = ViewProxy.GetRenderWindow
  zb = RenWin.GetZBufferData()
  Traceback (most recent call last):
    File "<console>", line 1, in <module>
  AttributeError: 'builtin_function_or_method' object has no attribute 
'GetZBufferData'

But as you see, GetZBufferData does not seem to be available.  I 
probably did something stupid here, but if anybody could correct me, 
I'd appreciate.


Furthermore, from what I saw in the documentation, if GetZBufferData was
available, it has to be used slightly differently, I think something 
like this:

  from libvtkCommonPython import vtkFloatArray
  z = vtkFloatArray()
  RenWin.GetZbufferData(0,0,300,300,z)

Now if I got this to work, how would I go about writing the data in the
vtkFloatArray z to an image file?


I think I found an alternative way which seems to work. It uses more 
VTK functionalities (vtkWindowToImageFilter in particular) as follows:

  from libvtkRenderingPython import vtkWindowToImageFilter
  from libvtkIOPython import vtkTIFFWriter

  view = GetActiveView().GetRenderWindow()

  w2i = vtkWindowToImageFilter()
  w2i.SetInputBufferTypeToZBuffer ()
  w2i.SetInput(view)
  w2i.Update()

  writer = vtkTIFFWriter()
  writer.SetInputConnection(w2i.GetOutputPort())
  writer.SetFileName("/scratch/depthmap.tif")

  view.Render()
  writer.Write()

Slight inconveniences are that I actually expected inverse color scheme 
(eg black for far away, white for closeup), but here it is the other 
way round. Also, I cannot write this to a PNG using vtkPNGWriter instead
of the TIFF writer (error is: PNGWriter only supports unsigned char and
unsigned short inputs).
Any suggestions?

Thanks again,
  Marc


[email protected] said:
>> I'ld try this path:
>> from the python shell get a hold of the current render view proxy
>> http://www.paraview.org/ParaQ/Doc/Nightly/html/classvtkSMRenderViewPro
>> xy.html

>> from that get a hold of the vtkRenderWindow http://www.vtk.org/doc/
>> nightly/html/classvtkRenderWindow.html

>> on that call GetZBufferData

>> David E DeMarle


-- 
 Dr. Marc Baaden  - Institut de Biologie Physico-Chimique, Paris
 mailto:[email protected]      -      http://www.baaden.ibpc.fr
 FAX: +33 15841 5026  -  Tel: +33 15841 5176  ou  +33 609 843217


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to