In general you can't assume that extent[0] = extent[2] = extent[4] = 0. Maybe it is for your data sets but it is not required.
I didn't fully go through your code to debug but I am working on a filter that does a similar operation in either the x, y, or z topological direction. It also works in parallel as well as for both image data and rectilinear grids. It still needs some tweaking before it goes into paraview (right now it averages in each direction instead of sums but that's an easy tweak to allow the user to do either). It also does it for all of the point and cell arrays. I hope to have it in paraview in the next couple of weeks. Andy On Thu, Oct 27, 2011 at 1:41 AM, Mr FancyPants <[email protected]> wrote: > 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 > > _______________________________________________ > 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 ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Follow this link to subscribe/unsubscribe: > http://www.paraview.org/mailman/listinfo/paraview > >
_______________________________________________ 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 ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
