[vtkusers] Using multiple Vectors

Uwe Rempler rempler at mechbau.uni-stuttgart.de
Wed Feb 25 12:41:13 EST 2004


Amy Henderson wrote:

> Hi Uwe,
>
> You could do this with a branching pipeline. You'll need two instances 
> of vtkAssignAttribute, vtkGlyph3D, vtkMapper, and vtkActor. The code 
> would look something like the following.
>
> attribute1 = vtkAssignAttribute()
> attribute2 = vtkAssignAttribute()
> glyph1 = vtkGlyph3D()
> glyph2 = vtkGlyph3D()
> mapper1 = vtkPolyDataMapper()
> mapper2 = vtkPolyDataMapper()
> actor1 = vtkActor()
> actor2 = vtkActor()
>
> # glyph using vector 1
> attribute1.SetInput(unstructGrid)
> attribute1.Assign('FIRST', 'VECTORS', 'POINT_DATA')
> glyph1.SetInput(attribute1.GetOutput())
> glyph1.SetSource(arrow.GetOutput())
> mapper1.SetInput(glyph1.GetOutput())
> actor1.SetMapper(mapper1)
>
> # glyph using vector 2
> attribute2.SetInput(unstructGrid)
> attribute2.Assign('SECOND', 'VECTORS', 'POINT_DATA')
> glyph2.SetInput(attribute2.GetOutput())
> glyph2.SetSource(arrow.GetOutput())
> mapper2.SetInput(glyph2.GetOutput())
> actor2.SetMapper(mapper2)
>
> - Amy
>
> At 10:56 AM 2/25/2004, Uwe Rempler wrote:
>
>> hi list,
>>
>> i'm looking for a way to visualize more than one vectorarrow per 
>> point (displacement-vector / another-vector) - for example somehow 
>> like this:
>>
>> #------------------------------------------------------------------------------- 
>>
>> firstVectorArray = vtkFloatArray()
>> firstVectorArray.SetName('FIRST')
>> secondVectorArray = vtkFloatArray()
>> secondVectorArray.SetName('SECOND')
>> unstructGrid = vtkUnstructuredGrid()
>> attribute = vtkAssignAttribute()
>> arrow = vtkArrowSource()
>> glyph = vtkGlyph3D()
>> mapper = vtkPolyDataMapper()
>> actor = vtkActor()
>> # just imagine the grid and the vetorarrays are filled with lots of 
>> data ;-)
>>
>> unstructGrid.GetPointData().AddArray(firstVectorArray)
>> unstructGrid.GetPointData().AddArray(secondVectorArray)
>>
>> attribute.SetInput(unstructGrid.GetOutput())
>> attribute.Assign('FIRST', 'VECTORS',  'POINT_DATA')      << here's 
>> the problem: either 'FIRST' or 'SECOND'
>> attribute.Assign('SECOND', 'VECTORS',  'POINT_DATA')      << array 
>> but not both at the same time...
>> attribute.Update()
>>
>> glyph.SetInput(attribute.GetOutput())
>> glyph.SetSource(arrow.GetOutput())
>>
>> mapper.SetInput(glyph.GetOutput())
>> actor.SetMapper(mapper)
>> etc...
>> #------------------------------------------------------------------------------- 
>>
>>
>> i know that this isn't working cause there was already a question 
>> about how to handle more than one vector simultaneous:
>> http://public.kitware.com/pipermail/vtkusers/2002-June/011932.html
>> and the answer said that "there can be only one active "attribute" of 
>> each type (scalar, vector, normal etc.) at one time" when using 
>> AddArray()...
>> does anybody know a way of showing two vectors at the same time? or 
>> should i just add another actor showing the second vector array 
>> arrows...?
>>
>> greetings
>> uwe
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages 
>> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
hi amy,

thank you very very much for your hint / solution - just implemented 
successfully the second vector arrow array ;-)

greetings
uwe





More information about the vtkusers mailing list