[Paraview] python programmable filter via xml with multiple input

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Tue Sep 30 22:22:19 EDT 2014


Ah, sorry I missed that. Yea, if you want to simply use the
vtkPythonProgrammableFilter, I'm afraid you'll have to stick with 1
input port accepting multiple connections, rather than separate input
ports. Thus, you'll need to change your XML to just have 1
<InputProperty>, however you can set the "multiple_input" attribute to
make to accept multiple input connections on the same port.

  <InputProperty clean_command="RemoveAllInputs"
                     command="AddInputConnection"
                     multiple_input="1"
                     name="Input">
     ...
  </InputProperty>

Hope that helps.

Utkarsh


On Mon, Sep 29, 2014 at 6:35 PM, Fraser Callaghan
<fraser.callaghan at sydney.edu.au> wrote:
> Thanks for the clarification. I had tried this with the following error:
> vtkPythonProgrammableFilter (0x5458a60): Attempt to connect input port
> index 1 for an algorithm with 1 input ports.
>
> I gather that 'SetNumberOfInputPorts()' should be called in the
> constructor of the filter, which I gather is governed by the xml file?
>
> If so, how can I expose editing of the algorithm constructor via the xml
> file?
>
> Thanks,
> Fraser
>
>
>
>
> On Mon, 2014-09-29 at 08:48 -0400, Utkarsh Ayachit wrote:
>> In your example, your XML is setup to provide the inputs on multiple
>> "ports", while you're code is expecting multiple "connections" on same
>> port. Use the following script, instead.
>>
>>     print self.GetInputDataObject(0, 0).GetNumberOfPoints()
>>     print self.GetInputDataObject(1, 0).GetNumberOfPoints()
>>
>> Utkarsh
>>
>> On Sat, Sep 27, 2014 at 8:10 AM, Fraser Callaghan
>> <fraser.callaghan at sydney.edu.au> wrote:
>> > Hi,
>> >
>> > I am able to run a python programmable filter accessing multiple inputs selected from the pipe line e.g:
>> > #
>> > numInputs = self.GetNumberOfInputConnections(0)
>> > for i in range(numInputs):
>> >          print self.GetInputDataObject(0,i).GetNumberOfPoints()
>> > ##
>> >
>> > I am able to use the xml format to define multiple inputs in a cleaner way, but can not access the input data (example below).
>> > Changing "command" value does not help.
>> > How should I be accessing the inputs available from the xml setup?
>> >
>> > Thanks for the help,
>> > Fraser
>> >
>> > xml file:
>> >
>> > <ServerManagerConfiguration>
>> >   <ProxyGroup name="filters">
>> >     <!-- ================================================================== -->
>> >     <SourceProxy name="MyFilter" class="vtkPythonProgrammableFilter" label="MyFilter">
>> >       <Documentation
>> >          long_help="long help."
>> >          short_help="short help.">
>> >       </Documentation>
>> >
>> >       <InputProperty
>> >          name="Input0"
>> >                port_index="0"
>> >          command="SetInputConnection">
>> >         <ProxyGroupDomain name="groups">
>> >           <Group name="sources"/>
>> >           <Group name="filters"/>
>> >         </ProxyGroupDomain>
>> >         <DataTypeDomain name="input_type">
>> >           <DataType value="vtkPolyData"/>
>> >         </DataTypeDomain>
>> >         <Documentation>
>> >           Input data 0.
>> >         </Documentation>
>> >       </InputProperty>
>> >
>> >       <InputProperty
>> >          name="Input1"
>> >                port_index="1"
>> >          command="SetInputConnection">
>> >         <ProxyGroupDomain name="groups">
>> >           <Group name="sources"/>
>> >           <Group name="filters"/>
>> >         </ProxyGroupDomain>
>> >         <DataTypeDomain name="input_type">
>> >           <DataType value="vtkPolyData"/>
>> >         </DataTypeDomain>
>> >         <Documentation>
>> >           Input data 1
>> >         </Documentation>
>> >       </InputProperty>
>> >
>> >       <!-- Output data type: "vtkPolyData" -->
>> >       <StringVectorProperty
>> >         name="Script"
>> >         command="SetScript"
>> >         number_of_elements="1"
>> >         default_values="print 'Filter Working'&#xA;print self.GetInputDataObject(0,0)&#xA;#prints polydata&#xA;print self.GetInputDataObject(0,1)&#xA;#prints None&#xA;&#xA;"
>> >         panel_visibility="advanced">
>> >         <Hints>
>> >          <Widget type="multi_line"/>
>> >        </Hints>
>> >       <Documentation>This property contains the text of a python program that
>> >       the programmable source runs.</Documentation>
>> >       </StringVectorProperty>
>> >
>> >     </SourceProxy>
>> >     <!-- End LandmarkTransformFilter -->
>> >   </ProxyGroup>
>> >   <!-- End Filters Group -->
>> > </ServerManagerConfiguration>
>> >
>> >
>> >
>> > Error on loading:
>> >
>> > ERROR: In /home/utkarsh/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/VTK/Common/ExecutionModel/vtkAlgorithm.cxx, line 893
>> > vtkPythonProgrammableFilter (0x56aff30): Attempt to connect input port index 1 for an algorithm with 1 input ports.
>> > _______________________________________________
>> > 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
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://public.kitware.com/mailman/listinfo/paraview
>
> --
> Dr Fraser Callaghan
> Research Fellow
> Sydney Translational Imaging Laboratory
> Charles Perkins Centre
> The University of Sydney
> NSW 2006 Australia
> p: 02 8627 1700
> e: fraser.callaghan at sydney.edu.au


More information about the ParaView mailing list