[vtkusers] Need example on Custom Reader where Data extent is different than update extent

Mike Jackson imikejackson at gmail.com
Mon Feb 11 11:43:32 EST 2008

I am trying to write a custom reader (for paraview integration) and I  
think I am having a misunderstanding with some of the vtk  
terminology. Here is the basics for the reader.

The data contained in the data file is just a stack of images, each  
of which is 7334 x 8446. There are about 100 to 200 slices. trying to  
load all that data into memory is going to be a problem on "normal"  
desktop pc so I am trying to load a subvolume. The problem I am  
running into is that the RequestData method is being called 6 times  
in a row. I already checked that the Modified times are not changing  
and I am not calling any of my "Set_()" methods during the RequestData 
() method.
    So say I want a sub volume of 1296 x 968 x 2 pixels. This  
subvolume should be cut out beginning at the 0,0,100 pixel from the  
original data. How would I write my RequestInformation() and  
RequestData() methods? Should I also be implementing  
RequestUpdateExtent in my custom Reader? Do I need to set the  
WholeExtent on the outinfo? Do I need to set the UpdateExtent for the  
outInfo? Ideally, we would like the user to use a UI to set the VOI  
and then the RequestData act upon the newly set VOI to determine what  
subvolume to extract.

currently I have the following for RequestInformation()
vtkTypeInt32 vtkH5RoboMetReader::RequestInformation2(vtkInformation  
   std::cout << "#--- RequestInformation Start... " << std::endl;
   int newFile = (vtkH5RoboMetReader::StringsEqual(this->FileName,  
this->CurrentFileName) == 0);
   if ( !newFile ) //The file has NOT changed
     return 1;
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkTypeInt32 error = this->loadInformationFromMXAFile();
if (error < 0)
   return 0; // Return error Code
// Set Data Spacing and Origin
this->DataOrigin[2] = static_cast<double>(this->StartSlice);
outInfo->Set( vtkDataObject::ORIGIN(), this->DataOrigin, 3 );

// Calculate data spacing using conversion factor, slice thickness,  
and slice increment.
// Store this in the DataSpacing data member and then add it to the  
info object.
// Spacing in x and y becomes the scaling factor ( number of microns  
per pixel ) and
// spacing in z becomes the spacing in microns between slices which  
should be the value
// of SliceThickness.
this->DataSpacing[0] = this->DataSpacing[1] = 1.0; //this- 
this->DataSpacing[2] = 1.0; //this->SliceThickness;
outInfo->Set( vtkDataObject::SPACING(), this->DataSpacing, 3 );

   this->GetOutput()->SetNumberOfScalarComponents( 1);

//Set the DataExtent info
std::cout<<"DataExtent ("<<this->DataExtent[0]<<", "<<this->DataExtent 
[1]<<", "<<this->DataExtent[2]<<", "<<
   this->DataExtent[3]<<", "<<this->DataExtent[4]<<", "<<this- 

   VOI[0] = 0;
   VOI[1] = 1291;
   VOI[2] = 0;
   VOI[3] = 967;
   VOI[4] = 100;
   VOI[5] = 100;
outInfo->Set( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), this- 
 >DataExtent, 6 );
std::cout << "#--- RequestInformation End" << std::endl;
return 1;

Currently I have the following for RequestData:
vtkTypeInt32 vtkH5RoboMetReader::RequestData( vtkInformation*  
                     vtkInformationVector** vtkNotUsed(inputVector),
                     vtkInformationVector* outputVector )
std::cout << "\n**--- RequestData Starting \tTimes="<<++loop_count <<
      " Modified Time: " << this->MTime.GetMTime() << std::endl;

vtkDebugMacro( << "Entering RequestData method");
if (NULL == this->FileName) {
vtkDebugMacro( << "FileName must be specified");
return 0;

vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkImageData* output = vtkImageData::SafeDownCast(outInfo->Get 

vtkTypeInt32 requestedExtent[6];
   VOI[0] = 0;
   VOI[1] = 1291;
   VOI[2] = 0;
   VOI[3] = 967;
   VOI[4] = 100;
   VOI[5] = 101;

vtkTypeInt32 error = 1;
//Read the file and load up the top left "corner" of data
error = loadSingleFrame(outInfo, output, this->VOI);
std::cout << "**----RequestData Ending" << " Modified Time: " << this- 
 >MTime.GetMTime() << std::endl;
return error;

Mike Jackson
imikejackson & gmail * com

More information about the vtkusers mailing list