[vtkusers] Unable to read all scalars from Cell Data in a VTK file

amit112amit amit112amit at yahoo.co.in
Mon Jan 4 04:30:24 EST 2016


I think I figured out my problem. My LEGACY VTK file structure looked like
following:

************ File starts *******************
# vtk DataFile Version 2.0
Test example
ASCII
DATASET POLYDATA
POINTS  3  double
...
POLYGONS  1  4
...
CELL_DATA    1
SCALARS    strainEnergy    double    1
...
SCALARS    bendingEnergy    double    1
...
SCALARS    curvature    double    1
...
POINT_DATA 3
VECTORS displacements double
...
VECTORS forces double
...
*************** File Ends *************

Paraview has no problem opening this file. But when reading this file by
code, we can fetch only the first scalar or vector from a cell data or point
data. The same file can be restructured as follows to be able to retain all
the information when reading using VTK library functions:

 ************** File Starts ************
# vtk DataFile Version 2.0
Test example
ASCII
DATASET POLYDATA
POINTS  3  double
...

POLYGONS  1  4
...

CELL_DATA    1
SCALARS    strainEnergy    double    1
...

FIELD FieldData 2
bendingEnergy  1 1  double
...
curvature 1 1 double
...

POINT_DATA 3
VECTORS displacements double
...

FIELD FieldData 1
forces 3 1 double
...
****************** File Ends ****************
 
What is the difference?
1. Cell data and point data can have only one active scalar or vector at a
time. 
2. All other scalars and vectors should be written under FIELD as field data
respectively for cell and point data sections. The format is FIELD FieldData
<number of arrays>
3. Field data arrays have a name, number of components, number of tuple and
data-type
4. With the corrected file format a code like
                 polyData->GetPointData()->GetScalar(<array_name>)
gives desired output without any loss of information.

To figure it out I had to look at the source code and the data-manipulation
example code from vtk documentation website was helpful.

Hope this post somebody some time and effort and give some clarity about
LEGACY VTK file formats.

Regards,
Amit




--
View this message in context: http://vtk.1045678.n5.nabble.com/Unable-to-read-all-scalars-from-Cell-Data-in-a-VTK-file-tp5735720p5735754.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list