[Paraview] PythonProgrammableFilters Multiple Input Ports

Bane Sullivan banesulli at gmail.com
Fri Jun 8 13:07:01 EDT 2018


Utkarsh,

Using the  `input_ports="2"` attribute did the trick!

The changes in your merge request have me really excited! Would this make
it possible to make a class like `class
PythonSuperquadricSource(VTKPythonAlgorithmBase)` in a .py file and load
that as a plugin at runtime? If so AWESOME!

Thank you for you help,

Bane

On June 8, 2018 at 6:19:53 AM, Utkarsh Ayachit (utkarsh.ayachit at kitware.com)
wrote:

Bane,

In your XML, instead of using `post_creation` and `argument`
attributes, just add a `input_ports="2"` attribute.

BTW, on-going work on Python algorithm will make this much easier. In
this example [1], one could simply pass in `nInputPorts=2` to require
two input ports. I plan to add example with multiple input ports
before this MR [2] gets merged.

Utkarsh

[1]
https://gitlab.kitware.com/paraview/paraview/merge_requests/2501/diffs#10631fdaabfeaf00bdc465f8bb442c9aa862eae7_0_22
[2] https://gitlab.kitware.com/paraview/paraview/merge_requests/2501
On Fri, Jun 8, 2018 at 12:20 AM Bane Sullivan <banesulli at gmail.com> wrote:
>
> Hi Gaël,
>
> Thank you for your help! I was aware of this way to add multiple inputs
to a programmable filter and FYI if you would like to have a dialog appear
in the PV GUI to select the inputs in a non-arbitrary order then try making
several InputProperty attributes in the XML rather than using the
multiple_input variable.
>
> Unfortunately, this still does not address my original issue. I need the
inputs to each be on their own port rather than multiple connections on a
single port. This is because I will implement the ability to select input
arrays from each port via drop down menus.
>
> Does anyone know how to give the vtkPythonProgrammableFilter multiple
input ports or a means to select input arrays to process when having
multiple connections on one port? I have a robust means of selecting input
arrays for just one input but I cannot get it to work for more than one
input.
>
> Thank you,
>
> Bane
>
> On June 1, 2018 at 1:33:02 AM, Gaël Grail (gael.grail at gmail.com) wrote:
>
> Hi Bane,
>
> I'm using the binary version of Paraview available in Kitware's website,
so I don't know much about what should be written in the C code.
> But in the xml, I'm using this and it works perfectly:
>
> <ServerManagerConfiguration>
> <ProxyGroup name="filters">
> <SourceProxy class="vtkPythonProgrammableFilter"
> label="toto"
> name="To To">
> <InputProperty clean_command="RemoveAllInputs"
> command="AddInputConnection"
> multiple_input="2"
> name="Inputs">
> <ProxyGroupDomain name="groups">
> <Group name="sources" />
> <Group name="filters" />
> </ProxyGroupDomain>
> </InputProperty>
> ...
>
> Hope this helps,
>
> Gaël
>
> 2018-06-01 2:40 GMT+02:00 Bane Sullivan <banesulli at gmail.com>:
>>
>> Hi there,
>>
>> I see an old thread here:
https://paraview.markmail.org/thread/z7cy73444s7fjadk about setting
multiple input ports for python programmable filters but I cannot get this
to work.
>>
>> I want to declare multiple input ports in a ServerManagerConfiguration
XML plugin but I have been unable to successfully add more than one input
port to the vtkPythonProgrammableFilter.
>>
>> I see that in
`paraview/ParaViewCore/ClientServerCore/Core/vtkPythonProgrammableFilter.h`
the following is declared:
>>
>> /**
>> * Set the number of input ports
>> * This function is explicitly exposed to enable a
vtkClientServerInterpreter to call it
>> */
>> void SetNumberOfInputPorts(int numberOfInputPorts) VTK_OVERRIDE
>> {
>> this->Superclass::SetNumberOfInputPorts(numberOfInputPorts);
>> }
>>
>>
>> This leads me to believe that the functionality is there, but how
exactly would I set the number of input ports from an XML plugin for a
Programmable Filter? I have tried the following with no luck:
>>
>> <ServerManagerConfiguration>
>> <ProxyGroup name="filters">
>> <SourceProxy
>> name="TestMuliPort”
>> class="vtkPythonProgrammableFilter”
>> label=“TestMuliPort”
>> post_creation=“SetNumberOfInputPorts"
>> arguments="2”>
>> ……..
>>
>>
>> I get the following ERROR:
>>
>> ERROR: In
/Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/ParaViewCore/ServerImplementation/Core/vtkPVSessionCore.cxx,
line 371
>> vtkPVSessionCore (0x60c0000d4510): Object type:
vtkPythonProgrammableFilter, could not find requested method:
"SetNumberOfInputPorts"
>> or the method was called with incorrect arguments.
>>
>> while processing
>> Message 0 = Invoke
>> Argument 0 = vtk_object_pointer {vtkPythonProgrammableFilter
(0x60c0003abde0)}
>> Argument 1 = string_value {SetNumberOfInputPorts}
>>
>>
>>
>> Any help would be greatly appreciated,
>>
>> Bane
>>
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> ParaView discussion is moving! Please visit
https://discourse.paraview.org/ for future posts.
>>
>> Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
>>
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> https://public.kitware.com/mailman/listinfo/paraview
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> ParaView discussion is moving! Please visit
https://discourse.paraview.org/ for future posts.
>
> Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview/attachments/20180608/dc6a54ac/attachment.html>


More information about the ParaView mailing list