[Paraview] passing a numpy array to a programmable filter
Alessandro De Maio
demaio.a at gmail.com
Fri May 26 10:53:33 EDT 2017
Dear all,
I'm writing a pvbatch script in which I need to perform some
calculations on paraview objects (provided by a quite complex pipeline that
starts from reading vtu files and processing through reseamplewithdataset
filter and other filter manipulations) by using a programmable filter to
which I must pass some information that in the main script is representable
as a quite big float numpy ndarray. This array comes from another numerical
process that cannot be included in the same programmable filter.
I don't know how to pass this numpy array to the programmable filter.
Probably I could use the Parameters property of the programmable filter
but, if I correctly understand the use of this feature, the whole array
should be converted to a very big string (or more than one) and then
reconverted back to float values inside the PF.
I've tried to create a vtkTable object in the main script using the
following lines:
T = vtkTable()
array_vtk = numpy_support.numpy_to_vtk(array)
array_vtk.SetName("AAA")
T.AddColumn(array_vtk)
and this seems to generate a vtkTable object (by printing type(T) I get
"<type 'vtkCommonDataModelPython.vtkTable'> " ) but this is not a Paraview
class object so when I pass this as an input argument to the Programmable
Filter I obviously get the error: "vtkCommonDataModelPython.vtkTable'
object has no attribute 'SMProxy'.
Is there any way to do this? I've thought about using
servermanager.CreateProxy() but I don't know how to use it and if it could
help.
Of course the easy solution could be to write the array to the disk from
the main script and to read it from the disk inside the programmable
filter, but I would like to avoid passing through the disk writing that
could be too much slow.
Any help would be appreciated.
Thank you in advance
Alessandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170526/44f2400e/attachment.html>
More information about the ParaView
mailing list