[Paraview-developers] Passing values between filters
Oliver Fernandes
Oliver.Fernandes at visus.uni-stuttgart.de
Fri Mar 25 08:26:43 EDT 2016
Ok good, thats exactly what I wanted to hear :)
Thanks again to Cory and Kenneth!
-Oli
________________________________________
Von: Cory Quammen <cory.quammen at kitware.com>
Gesendet: Donnerstag, 24. März 2016 14:23
An: Oliver Fernandes
Cc: paraview-developers at paraview.org
Betreff: Re: [Paraview-developers] Passing values between filters
vtkInformation is mainly used within the pipeline execution and I
would mostly consider it to be part of the internal implementation of
VTK/ParaView that is subject to change. I have gotten by in 10+ years
of VTK usage/development without really needing to do much with
vtkInformation, so you may not benefit from learning about it.
Cory
On Thu, Mar 24, 2016 at 8:19 AM, Oliver Fernandes
<Oliver.Fernandes at visus.uni-stuttgart.de> wrote:
> Thanks for the help, Cory! I will try out vtkFieldData member.
> Just for educational reasons, is there a reason to learn about vtkInformation?
> Or what would be a use case for that?
> (No details, just want to know what it's intended use is)
>
> Thanks again for the quick reply!
> -Oli
>
> ________________________________________
> Von: Cory Quammen <cory.quammen at kitware.com>
> Gesendet: Donnerstag, 24. März 2016 14:03
> An: Oliver Fernandes
> Cc: paraview-developers at paraview.org
> Betreff: Re: [Paraview-developers] Passing values between filters
>
> Oliver,
>
> I often pass these kinds of values through the vtkUnstructuredGrid's
> field data. Field data consists of data arrays, just like point or
> cell data, but the number of elements in the arrays is not expected to
> correspond to the number of points or cells, as is the case with point
> and cell data arrays.
>
> You can get the field data with
>
> vtkUnstructuredGrid::GetFieldData()
>
> Docs for vtkFieldData are here:
>
> http://www.vtk.org/doc/nightly/html/classvtkFieldData.html
>
> The nice thing with this approach is that the field data gets passed
> automatically through most filters, so you'll be able to pick up the
> values set by your reader in your writer, for example.
>
> HTH,
> Cory
>
> On Thu, Mar 24, 2016 at 3:56 AM, Oliver Fernandes
> <Oliver.Fernandes at visus.uni-stuttgart.de> wrote:
>> 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
>>
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Search the list archives at:
>> http://markmail.org/search/?q=Paraview-developers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>
>
>
>
> --
> Cory Quammen
> R&D Engineer
> Kitware, Inc.
--
Cory Quammen
R&D Engineer
Kitware, Inc.
More information about the Paraview-developers
mailing list