The attached patch for vtkPythonProgrammableFilter along with a minor tweak
to your plugin XML does the trick. I can have this cleaned up and merged in
"master" for 5.2 if that's acceptable.
Utkarsh
On Fri, Jul 15, 2016 at 3:20 PM, Utkarsh Ayachit <
[email protected]> wrote:
> Doh! I forgot that the number of ports need to set in the constructor of
> the vtkAlgorithm subclass. Grr...let me see if there's a workaround. I'll
> get back to you on it.
>
> On Fri, Jul 15, 2016 at 2:37 PM, LB <[email protected]> wrote:
>
>> Hi Utkarsh,
>>
>> Multiple input ports are exactly what I want.
>> But I can't get it to work. I've attached my last XML plugin attempt with
>> different port_index definition.
>>
>> When I try to use it, I have the following error:
>>
>> /ParaViewVTK/Common/ExecutionModel/vtkAlgorithm.cxx, line 893
>>
>> vtkPythonProgrammableFilter (0x6c7a510): Attempt to connect input port
>> index 1 for an algorithm with 1 input ports.
>>
>> Should I add something to tell ParaView that this filter has multiple
>> input ports?
>> Should I use a different class than the vtkPythonProgrammableFilter?
>>
>> Regards,
>> --
>> Loïc
>>
>> 2016-07-15 17:36 GMT+02:00 Utkarsh Ayachit <[email protected]>:
>>
>>> Sorry for chiming in late, but here are some things to note:
>>>
>>> * Both Dennis and Cory are talking about multiple connections on the
>>> same input port. This is arguably not too well supported since the
>>> order cannot be determined easily.
>>> * Seems to me you want multiple input ports, each with a single
>>> connection. That's supported. Just not by the Python Filter Generator
>>> Script. Once you have the XML for the filter, you can indeed just add
>>> another <InputProperty /> tag to it as follows (note the "port_index"
>>> attribute):
>>>
>>> <InputProperty command="SetInputConnection"
>>> name="Input2"
>>> port_index="2">
>>> <!-- fill with relevant domain information -->
>>> </InputProperty>
>>>
>>> Then, your python filter code can access data on each input port as:
>>>
>>> input1 = self.GetInputDataObject(0, 0)
>>> input2 = self.GetInputDataObject(1, 0)
>>>
>>> Here there's no confusion which data is on which input port.
>>>
>>> Hope that helps,
>>> Utkarsh
>>>
>>>
>>> On Fri, Jul 15, 2016 at 7:44 AM, Dennis Conklin
>>> <[email protected]> wrote:
>>> > LB,
>>> >
>>> >
>>> >
>>> > Yes, it is troublesome to not be able to tell which input is which
>>> inside
>>> > the Programmable filter. Something I have done in the past is
>>> > differentiate them inside the filter. I have tested for element type
>>> to
>>> > tell them apart, for example. Something else I have heard of but have
>>> not
>>> > had to use is assigning a unique variable to one input and then
>>> testing for
>>> > that inside the filter to determine which input is which.
>>> >
>>> >
>>> >
>>> > None of this may address your general problem, but here’s hoping.
>>> >
>>> >
>>> >
>>> > Dennis
>>> >
>>> >
>>> > _______________________________________________
>>> > Powered by www.kitware.com
>>> >
>>> > 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:
>>> > http://public.kitware.com/mailman/listinfo/paraview
>>> >
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> 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:
>>> http://public.kitware.com/mailman/listinfo/paraview
>>>
>>
>>
>
diff --git a/ParaViewCore/ClientServerCore/Core/vtkPythonProgrammableFilter.h b/ParaViewCore/ClientServerCore/Core/vtkPythonProgrammableFilter.h
index 6b4fe6b..4c59ea4 100644
--- a/ParaViewCore/ClientServerCore/Core/vtkPythonProgrammableFilter.h
+++ b/ParaViewCore/ClientServerCore/Core/vtkPythonProgrammableFilter.h
@@ -99,6 +99,9 @@ public:
vtkSetStringMacro(PythonPath);
vtkGetStringMacro(PythonPath);
+ void SetNumberOfInputPortsToTwo()
+ { this->SetNumberOfInputPorts(2); }
+
protected:
vtkPythonProgrammableFilter();
~vtkPythonProgrammableFilter();
<ServerManagerConfiguration>
<ProxyGroup name="filters">
<SourceProxy name="TestMuliPort" class="vtkPythonProgrammableFilter" label="estMuliPort SFE"
post_creation="SetNumberOfInputPortsToTwo">
<InputProperty name="Source" command="SetInputConnection" port_index="0">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkDataSet"/>
</DataTypeDomain>
</InputProperty>
<InputProperty name="Target" command="SetInputConnection" port_index="1">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkDataSet"/>
</DataTypeDomain>
</InputProperty>
<IntVectorProperty command="SetOutputDataSetType" default_values="8" name="OutputDataSetType" number_of_elements="1" panel_visibility="never">
</IntVectorProperty>
<StringVectorProperty
name="Script"
command="SetScript"
number_of_elements="1"
default_values="print self.GetInputDataObject(0, 0)
print self.GetInputDataObject(1, 0)
"
panel_visibility="advanced">
<Hints>
<Widget type="multi_line"/>
</Hints>
</StringVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
_______________________________________________
Powered by www.kitware.com
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:
http://public.kitware.com/mailman/listinfo/paraview