[vtkusers] exporting numpy array to unstructured grid

David Gobbi david.gobbi at gmail.com
Mon Jun 7 08:33:25 EDT 2010


Hi Florian,

The method you are looking for is AddArray().  From the docs:

"AddArray() -- Add an array to the array list. If an array with the
same name already exists - then the added array will replace it."

 - David


On Mon, Jun 7, 2010 at 1:31 AM, Florian Bruckner <e0425375 at gmail.com> wrote:
> hi all,
>
> i want to write a simple filter that does some calculates with an vtk
> unstructured grid input data and finally writes it again to a vtk file.
> Thanks to your help up to now i can read the unstructured grid data,
> transfrom it to a numpy array and process it:
>
> from vtk.util import numpy_support as VN
>
> data = ug.GetPointData()
> vtk_array = data.GetArray(array_id)
> numpy_array = VN.vtk_to_numpy(vtk_array)
>
> then i can process the numpy data but unfortunately vtk_to_numpy() seems
> to copy the given array so i need a method to put to the calculated data
> back in the vtk data structure. I don't see a SetArray() function that
> would correspond the the GetArray() from the upper example!? there is a
> SetVoidArray() function but this seems like a dirty solution.
>
> which method can i use for this problem? is their a possiblity to change
> the data directly without copying it?
>
> thanks
> FloB
>
>
> _______________________________________________
> 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
>



More information about the vtkusers mailing list