[vtkusers] updating vtkImageData ?

David Doria daviddoria at gmail.com
Fri Feb 10 13:32:58 EST 2012


On Fri, Feb 10, 2012 at 1:27 PM, Anders Wallin
<anders.e.e.wallin at gmail.com>wrote:

> Hi All,
> Id like to have 2D bitmap that I update as an algorithm runs, and
> produce an animation with VTK that shows the changing bitmap.
>
> In python I am doing it roughly like this:
> vol = vtk.vtkImageData()
> # .. set dimension,spacing,origin, allocate scalars
> scalars = vtk.vtkCharArray()
> # .. populate scalars with InsertTuple1(id,color)
> vol.GetPointData().SetScalars(scalars)
> vol.Update()
> ia = vtk.vtkImageActor()
> ia.SetInput(vol)
> ren.addActor(ia)
> renWin.render()
>
> This shows an initial image. Now I want to call functions that modify
> the bitmap, and then get an updated rendered scene.
> I am trying with:
> scalars.SetValue( id , new_color  )
> vol.Update()
>
> But this does not seem to update my image. If I move these two lines
> to before the "ren.addActor(ia)"  then I do see that my image-updating
> function works, and I get the second frame of my animation. However it
> seems after  "ren.addActor(ia)"  the image data is locked, and
> scalars.SetValue( id , new_color  ) has no effect?
>
> any ideas?
> thanks,
> Anders
>

After you call Update(), does it work if you wiggle the scene (i.e. just
click and drag once)? If so, just add a renderWindow->Render() call.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120210/d3a69440/attachment.htm>


More information about the vtkusers mailing list