[vtkusers] Re: Unstructured Grid and Glyphs

Fabien Hinault fabien.hinault at momagroup.com
Fri May 18 06:13:50 EDT 2007


I finally found the solution to my problem, so I reply to myself  for
the next one having the same problem.
The solution was:
Add

 vtkAssignAttribute attrib
   attrib SetInputConnection [reader GetOutputPort]
   attrib Assign "\[Un,Vn,Wn\]" VECTORS POINT_DATA

and replace

   glyph SetInputConnection [reader GetOutputPort]

with

   glyph SetInputConnection [attrib GetOutputPort]



Original message:
----------------------------------------------------

Hello,

I am trying to display vectors on points of an unstructured grid,
from a xml unstructured grid input file.
I wrote a small program in Tcl (at the end of the email).
All the vectors are pointing in the same wrong direction,
and have the same norm.
It seems like the source arrow is not modified using the vector
data of the input file.
The same file looks OK with Paraview.
I'm sure I'm missing something, but I can't find what.

Note: I am using version 5.0.2

Fabien.

The Tcl program, and the xml unstructured grid input file:
---------------------------------------
package require vtk
package require vtkinteraction

vtkXMLUnstructuredGridReader reader
  reader SetFileName "vtk20.vtu"

vtkArrowSource arrow

vtkGlyph3D glyph
   glyph SetInputConnection [reader GetOutputPort]
   glyph SetSource [arrow GetOutput]
   glyph SetVectorModeToUseVector
   glyph SetScaleModeToScaleByVector
   glyph OrientOn
   glyph Update

vtkPolyDataMapper mapper
   mapper SetInputConnection [glyph GetOutputPort]

vtkActor actor
   actor SetMapper mapper

vtkRenderer renderer
   renderer AddActor actor

vtkRenderWindow renWin
   renWin AddRenderer renderer
   renWin SetSize 300 300

vtkRenderWindowInteractor iren
   iren SetRenderWindow renWin

renWin Render

wm withdraw .

-----------------------------------------

<?xml version="1.0"?> <!-- Generated by freefem3d 1.0pre10 -->
<VTKFile type="UnstructuredGrid">
 <UnstructuredGrid>
   <Piece NumberOfPoints="14" NumberOfCells="24">
     <Points>
       <DataArray type="Float32" Name="Position" NumberOfComponents="3"
format="ascii">
0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 0.5 0.5 0.5 0 0.5 0.5 1
0.5 0 0.5 0.5 0.5 0.5 1 0.5 0.5 0
       </DataArray>
     </Points>
     <Cells>
       <DataArray type="Int32" Name="connectivity" NumberOfComponents="1"
format="ascii">
13 11 9 8 8 12 11 9 11 12 8 10 13 11 8 10 8 2 10 6 8 12 5 6 9 11 0 4 12 9
5 4 12 11 4 7 10 12 6 7 8 13 2 1 9 8 5 1 13 9 0 1 11 13 0 3 10 11 7 3 13
10 2 3 11 0 13 9 13 8 2 10 12 9 8 5 8 10 12 6 12 11 9 4 11 12 10 7 13 8 9
1 13 11 10 3
       </DataArray>
       <DataArray type="Int32" Name="offsets" NumberOfComponents="1"
format="ascii">
4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96
       </DataArray>
       <DataArray type="UInt8" Name="types" NumberOfComponents="1"
format="ascii">
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
       </DataArray>
     </Cells>
     <PointData>
       <DataArray type="Float32" Name="Pn" NumberOfComponents="1"
format="ascii">
0 0 0 0 0 0 0 0 0 0 0 0 0 0
       </DataArray>
       <DataArray type="Float32" Name="rhon" NumberOfComponents="1"
format="ascii">
1.625 1.625 1.625 1.625 1.24864 1.24864 1.24864 1.24864 1.24905 1.24905
1.24905 1.24905 1.24864 1.625
       </DataArray>
       <DataArray type="Float32" Name="Thetan" NumberOfComponents="1"
format="ascii">
0 0 0 0 0 0 0 0 0 0 0 0 0 0
       </DataArray>
       <DataArray type="Float32" Name="Tn" NumberOfComponents="1"
format="ascii">
0 0 0 0 301.084 301.084 301.084 301.084 300.759 300.759 300.759 300.759
301.084 0
       </DataArray>
       <DataArray type="Float32" Name="Un" NumberOfComponents="1"
format="ascii">
0 0 0 0 2.20138 2.20138 2.20138 2.20138 1.53613 1.53613 1.53613 1.53613
2.20138 0
       </DataArray>
       <DataArray type="Float32" Name="Vn" NumberOfComponents="1"
format="ascii">
-0 -0 -0 -0 -2.20138 -2.20138 -2.20138 -2.20138 -1.53613 -1.53613
-1.53613 -1.53613 -2.20138 -0
       </DataArray>
       <DataArray type="Float32" Name="Wn" NumberOfComponents="1"
format="ascii">
0 0 0 0 0 0 0 0 0 0 0 0 0 0
       </DataArray>
       <DataArray type="Float32" Name="[Un,Vn,Wn]" NumberOfComponents="3"
format="ascii">
0 -0 0 0 -0 0 0 -0 0 0 -0 0 2.20138 -2.20138 0 2.20138 -2.20138 0 2.20138
-2.20138 0 2.20138 -2.20138 0 1.53613 -1.53613 0 1.53613 -1.53613 0
1.53613 -1.53613 0 1.53613 -1.53613 0 2.20138 -2.20138 0 0 -0 0
       </DataArray>
     </PointData>
   </Piece>
 </UnstructuredGrid>
</VTKFile>
-------------------------------------------




More information about the vtkusers mailing list