[vtkusers] Point data with vtkUnstructuredGridReader
Berk Geveci
berk.geveci at kitware.com
Fri May 10 08:58:17 EDT 2013
The vtkUnstructuredGridReader has a lot of legacy behavior associated with
it. It was developed 20 years ago when the VTK API was significantly
different. Some of that behavior stayed to preserve compatibility over
time. The XML readers don't have that problem. Note that they have an API
to control which variables to read all. But it is the newer API which is
array name based and the default is to read all arrays.
Best,
-berk
On Thu, May 9, 2013 at 8:04 PM, Justin Pogacnik
<j.pogacnik at auckland.ac.nz>wrote:
> Works like a charm Berk!
>
> Since yesterday, I've changed my original output to be xmlunstructured.
> Can you tell me why I don't need the reader.ReadAllScalarsOn() to catch all
> the arrays when the input file is xml, but I do need it in ascii?
>
> Thanks for your help!
>
> Justin
> ------------------------------
> *From:* Berk Geveci [berk.geveci at kitware.com]
> *Sent:* Friday, May 10, 2013 11:42 AM
> *To:* Justin Pogacnik
> *Cc:* vtkusers at vtk.org
> *Subject:* Re: [vtkusers] Point data with vtkUnstructuredGridReader
>
> You need something like:
>
> reader->ReadAllScalarsOn();
> reader->ReadAllVectorsOn();
> reader->ReadAllNormalsOn();
> reader->ReadAllTensorsOn();
> reader->ReadAllColorScalarsOn();
> reader->ReadAllTCoordsOn();
> reader->ReadAllFieldsOn();
>
> Translate to Python and adjust to taste.
>
> -berk
>
>
> On Wed, May 8, 2013 at 9:37 PM, Justin Pogacnik <j.pogacnik at auckland.ac.nz
> > wrote:
>
>> Hi all,
>>
>> I'm trying to use Python to read an unstructured grid file (vtk format)
>> that I wrote for output from a research code. The vtk file loads fine in
>> Paraview, so it should be in order.
>>
>> The vtk file has 7 scalar arrays of point data and one vector array of
>> point data. However, when I print the point data, only 2 arrays are found
>> -- the first scalar array (elementID) and the last (only) vector array
>> (permeability).
>>
>> Here is the essential part of my python script:
>> from vtk import *
>>
>> filename = 'VTKoutput/FEHM_mesh4_2.vtk'
>>
>> vtkgrid = vtkUnstructuredGridReader()
>> name = vtkgrid.SetFileName(filename)
>> vtkgrid.Update()
>>
>> print vtkgrid.GetOutput().GetPointData()
>>
>> I'm happy to pass along the small test vtk file too if it'd be helpful.
>> Also, I'm running vtk-5.10 on Mac OSX 10.7.5.
>>
>> Thanks in advance,
>>
>> Justin
>>
>> _______________________________________________
>> 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
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130510/ddf640ed/attachment.htm>
More information about the vtkusers
mailing list