There are often cases when I am not sure if an array is going to be a vtkDoubleArray or a vtkFloatArray.<div><br></div><div>Take this code for example:<div><br></div><div><div>#include &lt;vtkSmartPointer.h&gt;</div><div>#include &lt;vtkPointData.h&gt;</div>
<div>#include &lt;vtkSphereSource.h&gt;</div><div>#include &lt;vtkPolyDataNormals.h&gt;</div><div>#include &lt;vtkDataArray.h&gt;</div><div>#include &lt;vtkDoubleArray.h&gt;</div><div>#include &lt;vtkFloatArray.h&gt;</div>
<div><br></div><div>int main(int, char *[])</div><div>{</div><div>  vtkSmartPointer&lt;vtkSphereSource&gt; sphereSource =</div><div>    vtkSmartPointer&lt;vtkSphereSource&gt;::New();</div><div>  sphereSource-&gt;Update();</div>
<div><br></div><div>  vtkSmartPointer&lt;vtkPolyDataNormals&gt; polyDataNormals =</div><div>    vtkSmartPointer&lt;vtkPolyDataNormals&gt;::New();</div><div>  polyDataNormals-&gt;SetInputConnection(sphereSource-&gt;GetOutputPort());</div>
<div>  polyDataNormals-&gt;Update();</div><div><br></div><div>  vtkDoubleArray* doubleNormals =</div><div>    vtkDoubleArray::SafeDownCast(polyDataNormals-&gt;GetOutput()-&gt;GetPointData()-&gt;GetNormals());</div><div><br>
</div><div>  if(doubleNormals)</div><div>    {</div><div>    std::cout &lt;&lt; &quot;Has double normals&quot; &lt;&lt; std::endl;</div><div>    }</div><div>    </div><div>  vtkFloatArray* floatNormals =</div><div>    vtkFloatArray::SafeDownCast(polyDataNormals-&gt;GetOutput()-&gt;GetPointData()-&gt;GetNormals());</div>
<div>  if(floatNormals)</div><div>    {</div><div>    std::cout &lt;&lt; &quot;Has float normals&quot; &lt;&lt; std::endl;</div><div>    }</div><div><br></div><div>  vtkDataArray* dataNormals =</div><div>    vtkDataArray::SafeDownCast(polyDataNormals-&gt;GetOutput()-&gt;GetPointData()-&gt;GetNormals());</div>
<div>  if(dataNormals)</div><div>    {</div><div>    std::cout &lt;&lt; &quot;Has data normals&quot; &lt;&lt; std::endl;</div><div>    double n[3];</div><div>    //dataNormals-&gt;GetTupleValue(0,n); //this does not work</div>
<div>    }</div><div>    </div><div>// the following code will work whether the array was doubles or floats, I just need to be able to call GetTupleValue (and get a float or a double, I don&#39;t care which)</div><div><br>
</div><div>// ....</div><div><br></div><div>  return EXIT_SUCCESS;</div><div>}</div></div><div><br></div><div>The normals are a vtkFloatArray, so the vtkDoubleArray cast fails. Since both vtkDoubleArray and vtkFloatArray derive from vtkDataArray, I thought I could get the array as a vtkDataArray, but then GetTupleValue function is not defined because it doesn&#39;t know what type the array is!</div>
<div><br></div><div>Can anyone share how you handle situations like this?</div><div><br></div><div>Thanks,<br><br>David<br>
</div></div>