[Paraview] AttributeError when transforming vector field

ccattani at caltech.edu ccattani at caltech.edu
Tue Aug 3 18:02:40 EDT 2010


Hi,

I am new to Paraview, and I need to write a programmable filter to
transform a vector field. My filter (below) works when applied to a 2D
slice extracted from the data, but when I change the input to the original
3D dataset, I get the error:

AttributeError: 'NoneType' object has no attribute 'SetPoints'.

Any idea of why this happens, and how to fix it?
Thank you in advance for your help!

Camilla

---------------here's my script:------------------------------------

import math
tX=math.radians(5.67)
tY=math.radians(-107.761)
tZ=math.radians(-49.432)

r11=math.cos(tY)*math.cos(tZ)+math.sin(tX)*math.sin(tY)*math.sin(tZ)
r12=math.sin(tZ)*math.cos(tX)
r13=-math.sin(tY)*math.cos(tZ)+math.sin(tX)*math.sin(tZ)*math.cos(tY)
r21=-math.sin(tZ)*math.cos(tY)-math.cos(tZ)*math.sin(tX)*math.sin(tY)
r22=math.cos(tX)*math.cos(tZ)
r23=math.sin(tY)*math.sin(tZ)+math.cos(tZ)*math.cos(tY)*math.sin(tX)
r31=math.cos(tX)*math.sin(tY)
r32=-math.sin(tX)
r33=math.cos(tY)*math.cos(tX)

pdi = self.GetUnstructuredGridInput()
pdo =  self.GetPolyDataOutput()
newPoints = vtk.vtkPoints()
numPoints = pdi.GetNumberOfPoints()
vel0=pdi.GetPointData().GetArray('velocity')
vel=vtk.vtkFloatArray()
vel.SetNumberOfComponents(3)
vel.SetName('TransfVelocity')
vel.SetNumberOfTuples(numPoints)

for i in range(0, numPoints):
     coord = pdi.GetPoint(i)
     x,y,z=coord[:3]
     newPoints.InsertPoint(i, x, y, z)
     vx=vel0.GetValue(i*3)
     vy=vel0.GetValue(i*3+1)
     vz=vel0.GetValue(i*3+2)
     vxt= r11*vx + r12*vy + r13*vz
     vyt= r21*vx + r22*vy + r23*vz
     vzt= r31*vx + r32*vy + r33*vz
     vel.SetTuple3(i,vxt,vyt,vzt)

pdo.SetPoints(newPoints)
pdo.GetPointData().AddArray(vel)




More information about the ParaView mailing list