This topic appears quite often in the archives but I was not able to figure out how to do this, perhaps because I’m a total vtk/python noob.
I have a geometry file (think of the VTK cow for example) and a time series of csv files with the new centre of gravity and orientation angles. I convert the csv files to points (TableToPoints) and I am trying to use them as input for a filter to translate and rotate my geometry (cow).
The problems I have to solve are:
how to reference the TableToPoints inputs in the transformation of the cow. The python calculator requires that both datasets are equal if I want to use the input[0].* and input [1].* si I guess this is not the right method.
The transform filter through a python script is probably the way to go but I am at a loss how to reference the TableToPoin inputs. Animate polydata using programmable filter is close but the author takes a constant multiplied by the time in transform.RotateY(-5*t) and I would like see something like TableToPoints.PointData[“Pitch”]
ideally I would like to do the rotations and translations myself and simply update the coordinates of the geometry without going through the built in Transform functions, perhaps the programmable filter is the solution then. Is it possibly to simply use the inputs[0].Points[:,:] vector and rotate and translate it using custom transformations?
I would appreciate a hint how to do it. My knowledge of programming in Paraview is unfortunately close to zero.
My base script would be this (taken from the wiki):
pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()
newPoints = vtk.vtkPoints()
numPoints = pdi.GetNumberOfPoints()
for i in range(0, numPoints):
coord = pdi.GetPoint(i)
x, y, z = coord[:3]
x = x + 1
y = y + 1
z = z + 1
newPoints.InsertPoint(i, x, y, z)
pdo.SetPoints(newPoints)
I can operate on the cube’s coordinates but I have no idea how to reference the TabletoToPoints point data in the script.
input0=inputs[1]
data0=input0.PointData["DX"]
data1=input0.PointData["DY"]
data2=input0.PointData["Laser_Altitude"]
print(data0,data1,data2)
pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()
newPoints = vtk.vtkPoints()
numPoints = pdi.GetNumberOfPoints()
for i in range(0, numPoints):
coord = pdi.GetPoint(i)
x, y, z = coord[:3]
x = x + data0
y = y + data1
z = z + data2
newPoints.InsertPoint(i, x, y, z)
pdo.SetPoints(newPoints)
I am able to reference the TableToPoints. What is missing is to force the filter to update with each new time step.