[Paraview-developers] Passing values between filters

Moreland, Kenneth kmorel at sandia.gov
Thu Mar 24 10:51:15 EDT 2016


Oliver,

One way to pass this type of information is through the unassociated field data. vtkDataObject (from which vtkUnstructuredGrid inherits) has a method named GetFieldData() (http://www.vtk.org/doc/nightly/html/classvtkDataObject.html#a72f64ab58126f72e048410751091011b). This returns a vtkFieldData object, which is a superclass of vtkCellData and vtkPointData. You can store your data there in the same way you are storing in CellData or PointData, but it should cause less problems.

-Ken


From: Paraview-developers <paraview-developers-bounces at paraview.org<mailto:paraview-developers-bounces at paraview.org>> on behalf of Oliver Fernandes <Oliver.Fernandes at visus.uni-stuttgart.de<mailto:Oliver.Fernandes at visus.uni-stuttgart.de>>
Date: Thursday, March 24, 2016 at 2:56 AM
To: "paraview-developers at paraview.org<mailto:paraview-developers at paraview.org>" <paraview-developers at paraview.org<mailto:paraview-developers at paraview.org>>
Subject: [EXTERNAL] [Paraview-developers] Passing values between filters

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/ffaa88d3/attachment-0001.html>


More information about the Paraview-developers mailing list