<HTML>
<HEAD>
<TITLE>Set/GetInputArrayToProcess with 2 input ports</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>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.<BR>
<BR>
XML:<BR>
</SPAN></FONT><FONT COLOR="#9B3510"><FONT SIZE="1"><FONT FACE="Menlo Regular"><SPAN STYLE='font-size:8.5pt'><</SPAN></FONT></FONT></FONT><FONT SIZE="1"><FONT FACE="Menlo Regular"><SPAN STYLE='font-size:8.5pt'>InputProperty name=<FONT COLOR="#7F33BE">"Input"<BR>
</FONT> port_index="0"<BR>
command="SetInputConnection"<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>ProxyGroupDomain name=<FONT COLOR="#7F33BE">"groups"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Group name=<FONT COLOR="#7F33BE">"sources"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Group name=<FONT COLOR="#7F33BE">"filters"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>ProxyGroupDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>DataTypeDomain name=<FONT COLOR="#7F33BE">"input_type"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>DataType value=<FONT COLOR="#7F33BE">"vtkDataSet"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>DataType value=<FONT COLOR="#7F33BE">"vtkCompositeDataSet"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>DataTypeDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>InputArrayDomain name=<FONT COLOR="#7F33BE">"input_array"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Property name=<FONT COLOR="#7F33BE">"SelectInputScalars"<BR>
</FONT> function="FieldDataSelection"<FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>InputArrayDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> Set the first input.<BR>
<FONT COLOR="#9B3510"></</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>InputProperty<FONT COLOR="#9B3510">><BR>
</FONT> <BR>
<FONT COLOR="#9B3510"><</FONT>InputProperty name=<FONT COLOR="#7F33BE">"Input2"<BR>
</FONT> port_index="1"<BR>
command="SetInputConnection"<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>ProxyGroupDomain name=<FONT COLOR="#7F33BE">"groups"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Group name=<FONT COLOR="#7F33BE">"sources"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Group name=<FONT COLOR="#7F33BE">"filters"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>ProxyGroupDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>DataTypeDomain name=<FONT COLOR="#7F33BE">"input_type"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>DataType value=<FONT COLOR="#7F33BE">"vtkDataSet"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>DataType value=<FONT COLOR="#7F33BE">"vtkCompositeDataSet"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>DataTypeDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>InputArrayDomain name=<FONT COLOR="#7F33BE">"input_array"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Property name=<FONT COLOR="#7F33BE">"SelectInput2Scalars"<BR>
</FONT> function="FieldDataSelection"<FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>InputArrayDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> Set the second input.<BR>
<FONT COLOR="#9B3510"></</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>InputProperty<FONT COLOR="#9B3510">><BR>
</FONT> <BR>
<FONT COLOR="#9B3510"><</FONT>StringVectorProperty name=<FONT COLOR="#7F33BE">"SelectInputScalars"<BR>
</FONT> command="SetInputArrayToProcess"<BR>
number_of_elements="5"<BR>
element_types="0 0 0 0 2"<BR>
label="Input Array"<BR>
animateable="0"<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>ArrayListDomain name=<FONT COLOR="#7F33BE">"array_list"<BR>
</FONT> attribute_type=<FONT COLOR="#7F33BE">"Scalars"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Property name=<FONT COLOR="#7F33BE">"Input"</FONT> function=<FONT COLOR="#7F33BE">"Input"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>ArrayListDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>FieldDataDomain name=<FONT COLOR="#7F33BE">"field_list"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Property name=<FONT COLOR="#7F33BE">"Input"</FONT> function=<FONT COLOR="#7F33BE">"Input"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>FieldDataDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> Select the array.<BR>
<FONT COLOR="#9B3510"></</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>StringVectorProperty<FONT COLOR="#9B3510">><BR>
</FONT> <BR>
<FONT COLOR="#9B3510"><</FONT>StringVectorProperty name=<FONT COLOR="#7F33BE">"SelectInput2Scalars"<BR>
</FONT> command="SetInputArrayToProcess"<BR>
number_of_elements="5"<BR>
element_types="0 0 0 0 2"<BR>
default_values="0 1"<BR>
label="Input 2 Array"<BR>
animateable=<FONT COLOR="#7F33BE">"0"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>ArrayListDomain name=<FONT COLOR="#7F33BE">"array_list"<BR>
</FONT> attribute_type=<FONT COLOR="#7F33BE">"Scalars"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Property name=<FONT COLOR="#7F33BE">"Input2"</FONT> function=<FONT COLOR="#7F33BE">"Input"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>ArrayListDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>FieldDataDomain name=<FONT COLOR="#7F33BE">"field_list"</FONT><FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Property name=<FONT COLOR="#7F33BE">"Input2"</FONT> function=<FONT COLOR="#7F33BE">"Input"</FONT><FONT COLOR="#9B3510">/><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>RequiredProperties<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>FieldDataDomain<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"><</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> Select the array.<BR>
<FONT COLOR="#9B3510"></</FONT>Documentation<FONT COLOR="#9B3510">><BR>
</FONT> <FONT COLOR="#9B3510"></</FONT>StringVectorProperty<FONT COLOR="#9B3510">><BR>
<BR>
</FONT></SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>C++:<BR>
<BR>
</SPAN></FONT><FONT COLOR="#4A820F"><FONT SIZE="1"><FONT FACE="Menlo Regular"><SPAN STYLE='font-size:8.5pt'>// get the info objects<BR>
</SPAN></FONT></FONT></FONT><FONT SIZE="1"><FONT FACE="Menlo Regular"><SPAN STYLE='font-size:8.5pt'> vtkInformation* inInfo1 = inputVector[<FONT COLOR="#2B21D5">0</FONT>]->GetInformationObject(<FONT COLOR="#2B21D5">0</FONT>);<BR>
vtkInformation* inInfo2 = inputVector[<FONT COLOR="#2B21D5">1</FONT>]->GetInformationObject(<FONT COLOR="#2B21D5">0</FONT>);<BR>
<BR>
<FONT COLOR="#4A820F">// get the input objects (should be of the same type)<BR>
</FONT> vtkDataObject *inObj1 = inInfo1->Get(vtkDataObject::DATA_OBJECT());<BR>
vtkDataObject *inObj2 = inInfo2->Get(vtkDataObject::DATA_OBJECT());<BR>
<BR>
<FONT COLOR="#9F35A1">if</FONT> (inObj1->GetDataObjectType() != inObj2->GetDataObjectType())<BR>
{<BR>
vtkErrorMacro(<< <FONT COLOR="#B23D25">"Inputs are different types."</FONT>);<BR>
<FONT COLOR="#9F35A1">return</FONT> <FONT COLOR="#2B21D5">1</FONT>;<BR>
}<BR>
<BR>
<FONT COLOR="#4A820F">// cast inputs to correct type<BR>
</FONT> <FONT COLOR="#9F35A1">if</FONT> (vtkDataSet::SafeDownCast(inObj1))<BR>
{<BR>
vtkDataSet* input1 = vtkDataSet::SafeDownCast(inObj1);<BR>
vtkDataSet* input2 = vtkDataSet::SafeDownCast(inObj2);<BR>
<BR>
vtkDataArray* inArray1 = <FONT COLOR="#9F35A1">this</FONT>->GetInputArrayToProcess(<FONT COLOR="#2B21D5">0</FONT>, input1);<BR>
vtkDataArray* inArray2 = <FONT COLOR="#9F35A1">this</FONT>->GetInputArrayToProcess(<FONT COLOR="#2B21D5">0</FONT>, input2);<BR>
<BR>
<FONT COLOR="#9F35A1">if</FONT> (!inArray1)<BR>
{<BR>
vtkErrorMacro(<< <FONT COLOR="#B23D25">"Bad inArray1."</FONT>);<BR>
<FONT COLOR="#9F35A1">return</FONT> <FONT COLOR="#2B21D5">1</FONT>;<BR>
}<BR>
vtkDebugMacro(<< <FONT COLOR="#B23D25">"Array 1: "</FONT> << inArray1->GetName());<BR>
<FONT COLOR="#9F35A1">if</FONT> (!inArray2)<BR>
{<BR>
vtkErrorMacro(<< <FONT COLOR="#B23D25">"Bad inArray2."</FONT>);<BR>
<FONT COLOR="#9F35A1">return</FONT> <FONT COLOR="#2B21D5">1</FONT>;<BR>
}<BR>
vtkDebugMacro(<< <FONT COLOR="#B23D25">"Array 2: "</FONT> << inArray2->GetName());<BR>
<FONT COLOR="#9B3510"><BR>
</FONT> ...<BR>
}<BR>
<BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>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?<BR>
<BR>
Thanks in advance for any insight,<BR>
Kevin<BR>
</SPAN></FONT>
</BODY>
</HTML>