Hello,
I’m trying to make a ParaView Reader Plugin using python that can read HDF files. I started working on this code by stripping down a filter template to the bare minimum and tried to turn it into a reader by looking at other reader plugin examples. However, while the stripped down filter works fine when put into ParaView as a filter, when I changed the filter specific lines to turn it into a reader I kept getting the same error.
Whenever I would change the first line from .filter to .reader it wouldn’t work.
@smproxy.filter
@smproxy.reader
This is the error I get.
This is the code I have so far.
from paraview.util.vtkAlgorithm import *
from vtkmodules.numpy_interface import dataset_adapter as dsa
from vtkmodules.vtkCommonDataModel import vtkDataSet
import numpy as np
@smproxy.reader(name="MyWRFReader", label="My WRF Reader")
@smproperty.input(name="Input", port_index=0)
@smdomain.datatype(dataTypes=["vtkPointSet"])
@smdomain.xml("""<InputArrayDomain attribute_type="point" name="input_normal" number_of_components="3" />""")
@smhint.filechooser(extensions="csv", file_description="Numpy CSV files")
class MyWRFReader(VTKPythonAlgorithmBase):
def __init__(self):
VTKPythonAlgorithmBase.__init__(self, nInputPorts=0, nOutputPorts=1, outputType="vtkPointSet")
self._filename = None
# def RequestData(self, request, inInfoVec, outInfoVec):
"""inData = self.GetInputData(inInfo, 0, 0)
outData = self.GetOutputData(outInfo, 0)
assert inData is not None
if outData is None or (not outData.IsA(inData.GetClassName())):
outData = inData.NewInstance()
outInfo.GetInformationObject(0).Set(outData.DATA_OBJECT(), outData)
return super().RequestDataObject(request, inInfo, outInfo)"""
@smproperty.stringvector(name="Normal")
def SetNormalArray(self, name):
if name != self.NormalArray:
self.NormalArray = name
self.Modified()
@smproperty.doublevector(name="Factor", default_values="1")
@smdomain.doublerange(min=0, max=10)
def SetFactor(self, i):
if i != self.WarpFactor:
self.WarpFactor = i
self.Modified()
def RequestData(self, request, inInfo, outInfo):
from vtkmodules.vtkCommonDataModel import imageToVTK
from vtkmodules.numpy_interface import dataset_adapter as dsa
output = vtkPolyData.GetData(outInfo)
return 1
MyWRFReader.py (1.8 KB)
This is my first time working with python on a ParaView Plugin so I might be missing other stuff. Is there something wrong or missing with the code for it to not work?
Thanks.