[vtkusers] vtkImageData: How to set the scalar pointer

Steve Boyd skboyd at ucalgary.ca
Tue Aug 26 22:57:32 EDT 2003


Hi,

How can I modify the pointer to the scalar data in vtkImageData?  In a
reader class I'm working on, the image data is already in memory (from a
C function).  Previously, I've been allocating memory in my vtkImageData
class and then copying to that allocated memory, but this requires two
copies of the image data in memory at the same time.  Can't I just set
the vtkImageData pointer to point at the data already in memory (taking
care to set extents, dim, etc)?

I want to do something like this:

  vtkImageData *data = this->GetOutput();
  data->SetScalarTypeToChar();
  data->SetDimensions(10,10,10);
  data->SetScalarPointer( *mydata );		// SetScalarPointer() does not
exist

  WHERE: mydata is an array of 1000 char.

I know there is a function to "GetScalarPointer()", but can't figure out
how to modify the pointer.

HELP Please!

Cheers,

Steve



More information about the vtkusers mailing list