[vtkusers] Unsuccessful vtkXMLUnstructuredGridReader
Chung-Kan Huang
ckhuangf at gmail.com
Thu Jun 26 17:52:32 EDT 2008
Hi,
I am working on my first vtk application (tcl) that I want to read a .vtu
file which contains several scalar data and select one of them to be drawn
in the window.
But for some reason I cannot see the effect I like so I wonder if anyone
here can give me some pointers, thank in advance.
(I have tried to open my .vtu file in Paraview and it works so I don't think
it is because of my .vtu file.)
My tcl file:
===============================================
package require vtk
vtkXMLUnstructuredGridReader greader
greader SetFileName "3dfiscr02-20-M.vtu"
vtkAssignAttribute a
a SetInput [greader GetOutput]
a Assign "P0" SCALARS POINT_DATA
vtkLookupTable table
table SetHueRange 0 1
table SetSaturationRange 0 1
vtkColorTransferFunction ctf
ctf SetColorSpaceToHSV
vtkDataSetMapper mapper
mapper SetInput [a GetOutput]
mapper SetLookupTable table
set datarange [mapper GetScalarRange]
puts $datarange
vtkActor actor
actor SetMapper mapper
vtkCamera camera
camera SetFocalPoint 1 1 1
vtkRenderer ren
ren AddActor actor
ren SetBackground 0 0 0
ren SetActiveCamera camera
ren ResetCamera
vtkRenderWindow renWin
renWin AddRenderer ren
renWin SetSize 500 500
renWin Render
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
iren Initialize
# prevent the tk window from showing up then start the event loop
wm withdraw .
The structure of my .vtu file
===============================================
<?xml version="2.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
<UnstructuredGrid>
<Piece NumberOfPoints="1718" NumberOfCells="8223">
<Points>
<DataArray type="Float64" format="ascii" NumberOfComponents="3">
x y z
...
...
...
</DataArray>
</Points>
<Cells>
<DataArray type="Int32" Name="connectivity" format="ascii">
v1 v2 v3 v4
....
....
....
</DataArray>
<DataArray type="Int32" Name="offsets" format="ascii">
4
8
12
16
.
.
.
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii">
10
10
.
.
.
</DataArray>
</Cells>
<PointData Scalar="P0 S0 ">
<DataArray type="Float32" Name="P0" format="ascii">
159.488
.
.
.
</DataArray>
<DataArray type="Float64" Name="P0" format="ascii">
0.1
.
.
.
</DataArray>
</PointData>
</Piece>
</UnstructuredGrid>
</VTKFile>
--
ckhuangf at hotmail.com
Chung.Kan.Huang at utah.edu
http://www.perc.utah.edu/Members/ckhuangf
Office: 801-585-5594
Cell: 801-651-8098
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080626/9cc1623b/attachment.htm>
More information about the vtkusers
mailing list