[Paraview-developers] Passing values between filters

Oliver Fernandes Oliver.Fernandes at visus.uni-stuttgart.de
Thu Mar 24 04:56:54 EDT 2016


Hello all,

So I wrote a couple of ParaView filters in C++, namely a reader A for a custom file format deriving from vtkUnstructuredGridAlgorithm, and a filter B that takes two of these outputs as input and does some calculation on them.

Everything is working fine, but now I noticed that I need to pass a single string value (and 3-4 numbers) from each reader to the actual filter B doing stuff.
A use case would be, for example, passing the input data filename from a reader to a filter on to a writer plugin, which can use it to come up with an appropriate output filename.

Now the work-around I'm using at the moment to pass these data to the filter B is abusing CellData or PointData arrays of the vtkUnstructuredGrid generated in A. Needles to say this is not very elegant and creates other problems too (memory issues), and I'm fairly sure there is a better way to do it.

I think that somehow I need to create an appropriate vtkInformationKey storing the data.
However, everything I tried seems to be wrong, the key seems to disappear in the pipeline between the filters.

Here is some pseudocode snippet to show what I tried to add a value to an vtkInformation.
Here the reader class A:
<code>
class A : vtkUnstructuredGridAlgorithm {
  static vtkInformationStringKey* MYSTRING();
   ...
}

vtkInformationKeyMacro(A, MYSTRING, String);

A::RequestInformation(...) {
  vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0);
  outInfo->Set(A::MYSTRING(),"test");
}
</code>
And the filter class B:
<code>
#include "classA.h"
class B : vtkUnstructuredGridAlgorithm {
   ...
}

B::RequestInformation(...) {
  vtkSmartPointer<vtkInformation> inInfo = inputVector[0]->GetInformationObject(0);
  if (!inInfo->Has(A::MYSTRING()))
     std::cout << "fail" std::endl;

}
</code>
I keep getting fails printed to my console :(

So here is the question(s):
A colleague of mine mentioned to check out the python interface, but I assume this can be done within vtk?
Is this the correct approach using vtkInformation?

-If yes, what am I doing wrong? I derived my code from an example which I can't seem to find anymore...
Can someone give me a detailed explanation of the steps necessary, or a well commented example?

-If no,is there a better, or more paraviewesque way to do it (not the python way), and can I get hint at what I need to look at please?
Any other comments on how to pass user defined data along the pipeline?

Thanks a lot for the help,
Oli

P.S.: I'm using ParaView 5.0.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20160324/bb99a61d/attachment.html>


More information about the Paraview-developers mailing list