Since this type of function exists, I'd imagine it would be possible to determine the type of an array array in a polydata based only on it's name and declare an array of the correct type to read the data.<br><br>void GetUnknownArrayType(const std::string &InputFilename, const std::string &ArrayName)<br>
{<br> vtkSmartPointer<vtkXMLPolyDataReader> reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();<br> reader->SetFileName(InputFilename.c_str());<br> reader->Update();<br> vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();<br>
<br> <br> vtkSmartPointer<UNKNOWN_TYPE> Array = UNKNOWN_TYPE::SafeDownCast(polydata->GetPointData()->GetArray(ArrayName.c_str()));<br> UNKNOWN_TYPE element[3];<br> Array->GetTupleValue(0, element);<br>
<br>}<br><br>I guess the idea is you could make a template function which returned an appropriate type based on the type of the array, rather than having a GetIntArrayFromPolyData(), and GetDoubleArrayFromPolyData(), and GetUnsignedCharArrayFromPolyData()... etc.<br>
<br>How would I go about doing this? <br><br>Also, I was looking for the GetArray() documentation. I started at vtkPointData and searched for GetArray with no results. I went up to the parent class, vtkDataSetAttributes and searched again, and again no match. The parent class of vtkDataSetAttributes is vtkFieldData, in which there does exist a GetArray function, but it's probably not the same as the GetPointData->GetArray()? <br>
<br clear="all">Thanks,<br><br>David<br>