[vtkusers] GetDataType usage
David Doria
daviddoria at gmail.com
Wed Apr 22 11:15:27 EDT 2009
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.
void GetUnknownArrayType(const std::string &InputFilename, const std::string
&ArrayName)
{
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(InputFilename.c_str());
reader->Update();
vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();
vtkSmartPointer<UNKNOWN_TYPE> Array =
UNKNOWN_TYPE::SafeDownCast(polydata->GetPointData()->GetArray(ArrayName.c_str()));
UNKNOWN_TYPE element[3];
Array->GetTupleValue(0, element);
}
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.
How would I go about doing this?
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()?
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090422/88c04d7d/attachment.htm>
More information about the vtkusers
mailing list