I am just trying to run an example from Paraview 5.6.0 guide section 12.4 :
from vtkmodules.vtkCommonDataModel import vtkDataSet
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from vtkmodules.numpy_interface import dataset_adapter as dsa
# new module for ParaDiew-specific decorators.
from paraview.util.vtkAlgorithm import smproxy, smproperty, smdomain
@smproxy.filter(label =" Half -D Filter ")
@smproperty.input(name =" Input ")
class HalfDFilter(VTKPythonAlgorithmBase):
# the rest of the code here is unchanged.
def __init__(self):
VTKPythonAlgorithmBase.__init__(self)
def RequestData(self, request, inInfo, outInfo):
# get the first input.
input0 = dsa.WrapDataObject(vtkDataSet.GetData(inInfo [0]))
# compute a value.
data = input0.PointData ["D"] / 2.0
# add to output
output = dsa.WrapDataObject(vtkDataSet.GetData(outInfo))
output.PointData.append(data, "D_half");
return(1)
with D instead of V to fit my data, which is a 256x256x256 Structered Grid, not a PolyData, maybe that’s the problem…
The problem is that the append
function doesn’t actually append the data, just the name !
Some outputs :
output (BEFORE append) :
type : <class 'vtkmodules.numpy_interface.dataset_adapter.PolyData'> <class 'vtkmodules.numpy_interface.dataset_adapter.DataSetAttributes'>
keys : []
values : <vtkmodules.numpy_interface.dataset_adapter.VTKNoneArray object at 0x7efdc9f1b748>
data :
type : <class 'vtkmodules.numpy_interface.dataset_adapter.VTKArray'>
values : [-0.0003911 -0.00040877 -0.00042751 ... -0.00191144 -0.00189098
-0.00187079]
output (AFTER append) :
type : <class 'vtkmodules.numpy_interface.dataset_adapter.PolyData'> <class 'vtkmodules.numpy_interface.dataset_adapter.DataSetAttributes'>
keys : ['D_half']
values : []
I then got my hands a little bit dirtier and found the source of the append
function which is in /usr/lib/python3.7/site-packages/vtkmodules/numpy_interface/dataset_adapter.py
(line 686). Adding some print
here and there in the function body, I found that I actually have a AttributeError
while copying the data to the new vtk compliant object. This fails silently since the except
section only contains a pass
statement…
I am running Paraview 5.6.0-5 as can be found on Archlinux’s community repositories, and Python 3.7.3-1.
Thx for your help !