[vtk-developers] Possible bug in vtkDataSetMapper?

Berk Geveci berk.geveci at kitware.com
Sat Sep 1 15:45:28 EDT 2007


This is not a bug. You are not supposed to be modifying data objects
internal to a pipeline. If you do, you shouldn't expect the pipeline
to update. You can insert a vtkAssignAttribute filter in the pipeline
to do this.

-berk

On 9/1/07, Prabhu Ramachandran <prabhu_r at users.sf.net> wrote:
> Hello,
>
> I just ran into an issue and am not sure if I'm doing something wrong
> or if it is a VTK bug.  Attached is a simple Python script that uses
> standard VTKData to demonstrate the problem.
>
> To summarize the issue, I have some data in a VTK XML file
> (multicomb_1.vts).  There are two scalar data arrays (named
> StagnationEnergy and Density).  The data is viewed using a
> vtkDataSetMapper.  If I change the active scalar, the mapper does not
> seem to update to show the new data.  If you look at the output of:
>
> print m.GetPolyDataMapper().GetInput().GetPointData().GetScalars().GetName()
>
> You get "StagnationEnergy" and not "Density" as it should be.  I am
> using
> vtk version 5.1.0, vtk source $Revision: 1.2785 $, $Date: 2007/05/29 09:26:33 $ (GMT)
>
> Is this a bug or am I just doing something wrong?
>
> Thanks for any clarification.
>
> cheers,
> prabhu
>
>
> import time
> from os.path import join
> import vtk
> from vtk.util.misc import vtkGetDataRoot
>
> r = vtk.vtkXMLStructuredGridReader()
> r.SetFileName(join(vtkGetDataRoot(), 'Data/multicomb_1.vts'))
> r.Update()
> r.GetOutput().GetPointData().SetActiveScalars('StagnationEnergy')
> m = vtk.vtkDataSetMapper()
> m.SetInput(r.GetOutput())
> a = vtk.vtkActor()
> a.SetMapper(m)
>
> ren = vtk.vtkRenderer()
> ren.AddActor(a)
> rw = vtk.vtkRenderWindow()
> rw.AddRenderer(ren)
>
> rw.Render()
> time.sleep(2)
> print "changing data attribute"
> r.GetOutput().GetPointData().SetActiveScalars('Density')
> # The following two don't help.
> r.GetOutput().Modified()
> m.Update()
> print m.GetPolyDataMapper().GetInput().GetPointData().GetScalars().GetName()
> # Uncomment the following to get the correct result.
> #m = vtk.vtkDataSetMapper()
> #m.SetInput(r.GetOutput())
> #a.SetMapper(m)
> rw.Render()
> time.sleep(2)
>
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list