I have a vtk polydata file - and I am writing a Python code that reads this polydata file as follows:
fullDirPath = os.getcwd()
fullFileName = fullDirPath+'/'+fileName
reader = vtkPolyDataReader()
reader.SetFileName(vtkFileName)
reader.ReadAllScalarsOn()
reader.ReadAllVectorsOn()
reader.Update()
data = reader.GetOutput()
velArray = vtk_to_numpy(data.GetPointData().GetArray('velocity'))
where I have omitted all the relevant library import statements for vtk libraries.
I would now like to operate on this velocity data velArray
, and create a new scalar field velParam
, and then write a new VTK polydata file that has velParam
as an additional scalar field. I unfortunately have so far not been able to come up with the correct way to manipulate the vtkPolyDataWriter
object and its functions in Python - and I did not find many examples to do the same. I was wondering as to what would be a good way of writing a vtk Polydata file from a given set of point-coordinates, a vector data field, and a scalar data field.
Thanks a lot.