[vtkusers] image reader problems - enforcing persistance of data after delete

dean.inglis at camris.ca dean.inglis at camris.ca
Mon Dec 10 17:08:23 EST 2007

In my app, I read in 3D image data from either
vtkGdcmReader, vtkXMLImageDataReader, vtkStructuredPointsReader or

This is done in a two stage process:

stage 1:
  determine the file type based on extension read from a file open dialogue
  set the reader's ReleaseDataFlag to On
  add a progress observer 
  allocate the appropriate reader, set a generic reference pointer to it as a vtkAlgorithm*  
  delete the reader

stage 2:
  downcast the correct type of reader from the vtkAlgorithm and get the output
      vtkImageData* input = reader->GetOutput();
 the application "this" maintains a pointer to the output by reference counting
      if (this->ImageData)
         this->ImageData->UnRegister(this);  // release hold on any previous data
      this->ImageData  = input; 
      this->ImageData->UnRegister(this);  // hold onto the new data  
 display the data    

This all works fine for vtkGdcmReader and for vtkMetaImageReader but not vtkXMLImageDataReader or vtkStructuredPointsReader.  With these
readers, scrolling through the image slices causes the data to be re-read
from disk, as evidenced by reappearance of a progress meter.  Are there
known issues with these classes?  Why would their output behave differently than
that obtained with the other two readers? Is there a way to force the reader
to destroy but leave its output intact without copying the output to a new


More information about the vtkusers mailing list