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

Cory Quammen cory.quammen at kitware.com
Mon Jan 4 15:45:24 EST 2016


Hi Amit,

Thanks for reporting what worked.

I'm puzzled, though, because ParaView uses vtkPolyDataReader for poly data
legacy files, so there should be no difference between what ParaView can
read and what VTK can read.

I wonder if you need to call

reader1->ReadAllScalarsOn();

to ensure all scalars defined with the SCALARS declaration are read? It is
off by default in VTK, but ParaView sets this to on.

- Cory

On Mon, Jan 4, 2016 at 4:30 AM, amit112amit <amit112amit at yahoo.co.in> wrote:

> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160104/5330bc89/attachment.html>


More information about the vtkusers mailing list