Correctly using vtkDataArraySelection in Python algorithm custom filter


I’m trying to implement a simple custom filter using the VTKPythonAlgorithmBase. I’d like to include a vtkDataArraySelection and am now struggling with how to correctly use it.
Following the tutorials (VTK Python algorithm and Python algorithm examples), in RequestData() I can simply write

input0 = dsa.WrapDataObject(vtkDataSet.GetData(inInfo[0]))

and directly inspect all the arrays from there and add them to my ArraySelection. However, it seems reasonable that array selection should be done before the actual computation. So I though of moving that functionality into the RequestInformation method. However, it appears that GetData does not work there, I get an error in that line.
So I wanted to ask if I can inspect data array names and add them to the selection at that point of pipeline execution at all and if so, how to do it. I’m really sorry if this is obvious, but I’m not that familiar with VTK and could not find information on how to do this.

Thanks in advance!

Your observations are indeed correct: RequestInformation is the space to fill up meta-data in things like vtkDataArraySelection; RequestInformation does have valid input data available.

vtkDataArraySelection is intended for readers and data-sources and not filters. Since data sources don’t have inputs, they can glean enough meta-data in RequestInformation to fill up vtkDataArraySelection.

For selection of array on filters, we instead let ParaView populate the list of available arrays in the input. This is done through domains. Before I point to an example, can you elaborate what kind of selection are you interested in? Are you letting user select a single array or choose multiple arrays? If you point to an existing filter in ParaView that supports what you want, it’d be easy to demonstrate how to do that in PythonAlgorithms.

Thank you very much for the response! I had no idea vtkDataArraySelection is only used in readers and sources.

I’d like the user to be able to select multiple arrays. Knowing all data array names in the filter’s input would be enough information. However I’d like to also be able to adjust the names of the arrays shown in the selection; these should not necessarily be identical to those in the input.
Is that possible?

Thanks in advance!