[Paraview] Set/GetInputArrayToProcess with 2 input ports

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed Jan 5 08:52:33 EST 2011


The array-information indices should not be repeated. You're using
index 1 for both array informations. Just change the 2nd one to 2
(updating the xml default values as well as when you call
GetInputArrayToProcess()).

Utkarsh

On Tue, Jan 4, 2011 at 5:43 PM, Winters, Kevin D.  ERDC-CHL-MS
<Kevin.D.Winters at usace.army.mil> wrote:
> I am writing a filter that will compare array values from two objects. The
> filter is set up with two input ports. I would like the user to choose an
> array from each object for the filter to compare. I am successful in
> retrieving the two objects and the first array, but the second array is
> invalid. I’m not sure if my issue is with the XML or the code.
>
> XML:
>              <InputProperty name="Input"
>         port_index="0"
>          command="SetInputConnection">
>        <ProxyGroupDomain name="groups">
>          <Group name="sources"/>
>          <Group name="filters"/>
>        </ProxyGroupDomain>
>        <DataTypeDomain name="input_type">
>          <DataType value="vtkDataSet"/>
>          <DataType value="vtkCompositeDataSet"/>
>        </DataTypeDomain>
>        <InputArrayDomain name="input_array">
>          <RequiredProperties>
>            <Property name="SelectInputScalars"
>              function="FieldDataSelection"/>
>          </RequiredProperties>
>        </InputArrayDomain>
>        <Documentation>
>          Set the first input.
>         </Documentation>
>      </InputProperty>
>
>       <InputProperty name="Input2"
>         port_index="1"
>          command="SetInputConnection">
>        <ProxyGroupDomain name="groups">
>          <Group name="sources"/>
>          <Group name="filters"/>
>        </ProxyGroupDomain>
>        <DataTypeDomain name="input_type">
>          <DataType value="vtkDataSet"/>
>          <DataType value="vtkCompositeDataSet"/>
>        </DataTypeDomain>
>        <InputArrayDomain name="input_array">
>          <RequiredProperties>
>            <Property name="SelectInput2Scalars"
>              function="FieldDataSelection"/>
>          </RequiredProperties>
>        </InputArrayDomain>
>        <Documentation>
>          Set the second input.
>         </Documentation>
>      </InputProperty>
>
>       <StringVectorProperty name="SelectInputScalars"
>         command="SetInputArrayToProcess"
>          number_of_elements="5"
>          element_types="0 0 0 0 2"
>          label="Input Array"
>          animateable="0">
>        <ArrayListDomain name="array_list"
>           attribute_type="Scalars">
>          <RequiredProperties>
>            <Property name="Input" function="Input"/>
>          </RequiredProperties>
>        </ArrayListDomain>
>        <FieldDataDomain name="field_list">
>          <RequiredProperties>
>            <Property name="Input" function="Input"/>
>          </RequiredProperties>
>        </FieldDataDomain>
>        <Documentation>
>          Select the array.
>         </Documentation>
>      </StringVectorProperty>
>
>       <StringVectorProperty name="SelectInput2Scalars"
>         command="SetInputArrayToProcess"
>          number_of_elements="5"
>          element_types="0 0 0 0 2"
>          default_values="0 1"
>          label="Input 2 Array"
>          animateable="0">
>        <ArrayListDomain name="array_list"
>           attribute_type="Scalars">
>          <RequiredProperties>
>            <Property name="Input2" function="Input"/>
>          </RequiredProperties>
>        </ArrayListDomain>
>        <FieldDataDomain name="field_list">
>          <RequiredProperties>
>            <Property name="Input2" function="Input"/>
>          </RequiredProperties>
>        </FieldDataDomain>
>        <Documentation>
>          Select the array.
>         </Documentation>
>      </StringVectorProperty>
>
> C++:
>
>     // get the info objects
>  vtkInformation* inInfo1 = inputVector[0]->GetInformationObject(0);
>   vtkInformation* inInfo2 = inputVector[1]->GetInformationObject(0);
>
>   // get the input objects (should be of the same type)
>  vtkDataObject *inObj1 = inInfo1->Get(vtkDataObject::DATA_OBJECT());
>   vtkDataObject *inObj2 = inInfo2->Get(vtkDataObject::DATA_OBJECT());
>
>   if (inObj1->GetDataObjectType() != inObj2->GetDataObjectType())
>     {
>     vtkErrorMacro(<< "Inputs are different types.");
>     return 1;
>     }
>
>   // cast inputs to correct type
>  if (vtkDataSet::SafeDownCast(inObj1))
>     {
>     vtkDataSet* input1 = vtkDataSet::SafeDownCast(inObj1);
>     vtkDataSet* input2 = vtkDataSet::SafeDownCast(inObj2);
>
>     vtkDataArray* inArray1 = this->GetInputArrayToProcess(0, input1);
>     vtkDataArray* inArray2 = this->GetInputArrayToProcess(0, input2);
>
>     if (!inArray1)
>       {
>       vtkErrorMacro(<< "Bad inArray1.");
>       return 1;
>       }
>     vtkDebugMacro(<< "Array 1: " << inArray1->GetName());
>     if (!inArray2)
>       {
>       vtkErrorMacro(<< "Bad inArray2.");
>       return 1;
>       }
>     vtkDebugMacro(<< "Array 2: " << inArray2->GetName());
>
>    ...
>     }
>
> Am I using the Set/GetInputArrayToProcess functions correctly with regards
> to the input ports? Should I instead use helper functions that pass the
> names of the two selected arrays and retrieve them from the objects?
>
> Thanks in advance for any insight,
> Kevin
>
> _______________________________________________
> 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://www.paraview.org/mailman/listinfo/paraview
>
>


More information about the ParaView mailing list