[Paraview] Set/GetInputArrayToProcess with 2 input ports

Winters, Kevin D. ERDC-CHL-MS Kevin.D.Winters at usace.army.mil
Tue Jan 4 17:43:44 EST 2011


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20110104/5c516998/attachment-0001.htm>


More information about the ParaView mailing list