[vtkusers] GetNumberOfScalarsInFile method fails with Binary VTK data

Bill Sherman shermanw at indiana.edu
Sat Jul 26 19:37:43 EDT 2014


Hello,

This is something I noticed a long time ago, but wasn't sufficiently
motivated to report it, but today I am motivated.  I just tried again
with VTK version 6.1.0 (as it comes with ParaView 4.1.0), and it
still exhibits the same behavior.

Specifically, this is a problem when reading legacy VTK files (using the
TCL or Python interface) that are stored in Binary format.  When stored
in ASCII format, there is no problem.

For instance, the "blow.vtk" file is an example of an ASCII legacy VTK
file with 10 scalars and 10 vectors.  So I can query (with for example
vtkpython):
     >>> dr = vtk.vtkDataSetReader()
     >>> dr.SetFileName("blow.vtk")
     >>> dr.Update()
     >>> dr.GetFileType()
     1
     >>> dr.GetNumberOfScalarsInFile()
     10
     >>> dr.GetNumberOfVectorsInFile()
     10
     >>> dr.GetNumberOfFieldDataInFile()
     0

But if I try the same for a Binary formatted legacy VTK file, then
it will report either 0 or 1 scalar or 0 or 1 vector.


As a secondary question -- I was trying to convert the ASCII blow.vtk
file to a Binary VTK file to provide as an example for demonstrating
the issue abvoe, but I'm having trouble doing an ASCII to Binary
conversion using the VTK scripting interface in a way that keeps the
scalars in the scalar list.  I can get them all read, but then writing
them causes most of them to be shifted down as "FieldData" rather than
Scalars.  So my other question is:
           A) How to read a file and write it back out in the same 
structure?
              (perhaps switching only the ASCII flag to Binary)

and/or    B) How to write multiple scalar entries using VTK scripting.

Of course, I can create these files with an AWK script, but I'd like
to be able to do it completely within the VTK scripting environment.


(Binary file with multiple scalars available upon request.)

     Thanks,
     Bill

-- 
Bill Sherman
Sr. Technology Advisor
Advanced Visualization Lab
Pervasive Technology Inst
Indiana University
shermanw at iu.edu


More information about the vtkusers mailing list