[vtkusers] Multiple fields (scalars, vectors)

Eric E. Monson emonson at cs.duke.edu
Mon Apr 19 14:11:24 EDT 2010


Hey Sebastian,

For assignment you should use pointdata.AddArray(), and you can do that as many times as you want, no matter how many components your array has (scalars, vectors, ...). Then when you want to make a certain array the default attribute you can use SetActiveScalars(), SetActiveTCoords(), etc.

For coloring by a certain scalar, I think you use the mapper.SelectColorArray() method. Here's a snippet from a clipping routine (in Python, sorry):

selectMapper = vtk.vtkPolyDataMapper()
selectMapper.SetInputConnection(clipper.GetOutputPort())
selectMapper.SetScalarModeToUsePointFieldData()
selectMapper.SetColorModeToMapScalars()
selectMapper.ScalarVisibilityOn()
selectMapper.SetScalarRange(rt.GetOutputDataObject(0).GetPointData().GetArray('RTData').GetRange())
selectMapper.SelectColorArray('RTData')

(Note that the pointdata.GetScalars() method grabs the "Active" attribute. If the one you want isn't the Active one, grab by name with GetArray() as above.) 

-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Feb 26, 2010, at 3:56 AM, Sebastian Gatzka wrote:

> Hello World.
>  
> How can I assign different field values like scalars and vectors to a (structured) grid?
> Looks to me that only the last data set with ->SetScalar() or ->SetVector() is considered.
>  
> I want to use different fields for different cuts, contours etc.
> How do I tell these actors/mappers which one of the fields should be considered?
>  
> Sebastian
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100419/96f829f1/attachment.htm>


More information about the vtkusers mailing list