[vtkusers] python: GetNumberOfScalarsInFile identify only one scalar instead of four in binary Legacy vtk

David E DeMarle dave.demarle at kitware.com
Thu Dec 17 09:47:42 EST 2015


Instead of GetNumberOfScalarsInFile() try
reader.GetOutput().GetPointData().GetNumberOfArrays() and
GetCellData().GetNumberOfArrays(). You can also get the number of single
component arrays.

In VTK the scalar designation (see vtkDataSetAttributes) is sort of an
anachronism. The "Active" Scalar array designation marks one array as the
default that filters will operate on if they aren't told specifically what
array to work with.



David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Thu, Dec 17, 2015 at 8:45 AM, Jean-Christophe <loiseau at mech.kth.se>
wrote:

> Hej,
>
> I have tried to look through the archives of the mailing-list but couldn't
> find an answer to my problem.
>
> A colleague of mine gave me a bunch of binary Legacy vtk files. They are
> structured points with 4 scalars. Here is how I try to read them in python
>
> import numpy as np
> import vtk
>
> reader = vtk.vtkStructuredPointReader()
> reader.SetFileName(filename)
> reader.ReadAllScalarsOn()
> reader.Update()
> reader.GetNumberOfScalarsInFile()
>
>
> When I execute the last command, it returns that there is only one single
> scalar in my file though I actually have four of them. Would anyone have an
> idea of what is going on and how I could fix this?
>
> Regards,
> JC
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151217/e4030ff7/attachment.html>


More information about the vtkusers mailing list