[Paraview] Programmable filter issue with modifying grid data

Mr FancyPants stofem at gmail.com
Thu Oct 27 01:41:13 EDT 2011


Hi there,

I am trying to write a programmable filter which will take my
RectilinearGrid data and modify one of the data arrays. Specifically I want
to sum over one dimension. I have written something to do this, but my data
comes out garbled.

Below is my code. Basically all I am doing is extracting all the data, doing
my sum over the z direction and then putting this data into another
rectilinear grid.


*data=self.GetInput()*
*out=self.GetOutput()*
*extent=data.GetExtent()*
*vtkVarray=data.GetPointData().GetArray('velocity')*
*
*
*import numpy*
*pyVarray_x = numpy.zeros([extent[1]+1,extent[3]+1,extent[5]+1])*
*pyVarray_y = numpy.zeros([extent[1]+1,extent[3]+1,extent[5]+1])*
*pyVarray_z = numpy.zeros([extent[1]+1,extent[3]+1,extent[5]+1])*
*
*
*for i in range(0,extent[1]+1):*
* for j in range(0,extent[3]+1):*
* for k in range(0,extent[5]+1):*
* tup=vtkVarray.GetTuple(i+j*(extent[1]+1)+k*(extent[1]+1)*(extent[3]+1))*
* pyVarray_x[i,j,k]=tup[0]*
* pyVarray_y[i,j,k]=tup[1]*
* pyVarray_z[i,j,k]=tup[2] *
*
*
*
*
*
*
*pyVarray_x_noz = numpy.zeros([extent[1]+1,extent[3]+1,1])*
*pyVarray_y_noz = numpy.zeros([extent[1]+1,extent[3]+1,1])*
*pyVarray_z_noz = numpy.zeros([extent[1]+1,extent[3]+1,1])*
*
*
*for i in range(0,extent[1]+1):*
* for j in range(0,extent[3]+1):*
* pyVarray_x_noz[i,j]=pyVarray_x[i,j,:].sum()*
* pyVarray_y_noz[i,j]=pyVarray_y[i,j,:].sum()*
* pyVarray_z_noz[i,j]=pyVarray_z[i,j,:].sum()*
*
*
*newArray=vtk.vtkDoubleArray()*
*newArray.SetName("test")*
*newArray.SetNumberOfComponents(3)*
*
*
*print newArray*
*
*
*for k in range(0,extent[5]+1):*
* for j in range(0,extent[3]+1):*
* for i in range(0,extent[1]+1):*
* tup0=pyVarray_x_noz[i,j]*
* tup1=pyVarray_y_noz[i,j]*
* tup2=pyVarray_z_noz[i,j]*
* tup=(tup0,tup1,tup2)*
* newArray.InsertNextTuple((tup0,tup1,tup2))*
*
*
*print newArray*
*print vtkVarray*
*
*
*out.GetCellData().AddArray(newArray)*
*
*
I have no idea whats going wrong with this. Any help is much appreciated,
new to using paraview.

Thanks, James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20111027/cf45efca/attachment.htm>


More information about the ParaView mailing list