[vtkusers] how to create vtkDataArrays of an unknown type?
Alexandre Guimond
guimond at bwh.harvard.edu
Thu Jun 28 14:03:01 EDT 2001
Hi. It seems that the new way of adding data to vtkDataSetAttributes
is to use vtkDataArray instead of vtkAttributeData. What I'm
wondering is the way to select the data type of the data array if I
don't know it at compile time. For example, how can I convert this
type of code to the new convention:
void vtkclass::create_tensors(vtkImageData* res)
{
vtkAttributeData* ad=vtkAttributeData::New();
ad->SetDataType(res->GetScalarType());
...
res->GetPointData()->SetTensors(ad);
}
I came up with doing an exhaustive "switch" on res's scalar type, or
creating a vtkAttributeData, setting the proper type and retrieving
the resulting data array. Both solutions don't sound very good. Any
good ideas?
--
Alexandre Guimond, Ph.D. guimond at bwh.harvard.edu Phone:(617) 278-0800
http://spl.bwh.harvard.edu:8000/~guimond/ Fax:(617) 264-5154
Brigham and Women's Hospital, Harvard Medical School
CNI, RF396, 221 Longwood Av, Boston, MA 02115
More information about the vtkusers
mailing list