[vtkusers] adding components to existing array using Phython Programable Filter

Mich Aelo michael.tum.92 at gmail.com
Mon Jun 30 12:41:21 EDT 2014


Hello,

I am new to Paraview as well as Phython.
Currently I am working on some tensor representation issues.

Right now, I am dealing with a symetric tensor dataset. As the the tensor
is symetric only 6 values are stored in the data array.
Some filters I would like to apply, however, demand input arrays with 9
components.
So my guess was, it would be easiest to use "Phyton Programmabe Filter" and
add the missing entries.

Here is what i tried after viewing some examples on the paraview-wiki:

//////////////////////////////////////////////////////////////////////////////////
from paraview import numpy_support as NS
import numpy as N
pdi = self.GetInputDataObject(0,0)
pdo = self.GetOutputDataObject(0)
pdo.ShallowCopy(pdi)

import math

m = pdi.GetPointData().GetArray('tensor6_array')
m2 = N.mat([[m.GetValue(0), m.GetValue(1), m.GetValue(2)], [m.GetValue(1),
m.GetValue(3), m.GetValue(4)], [m.GetValue(2), m.GetValue(4),
m.GetValue(5)]])


m3 = NS.numpy_to_vtk(m2)
m3.SetName('tensor9_array')
pdo.GetPointData().AddArray(m3)
//////////////////////////////////////////////////////////////////////////////////

This however results in a 3 component array, with only zeros in it.

Its quite clear to me, that there must be some fundamental mistake in it,
and would be very gratefull if someone could point it out to me!

Regards,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140630/718839e9/attachment.html>


More information about the vtkusers mailing list