- this->TotalNumberOfPlanes = this->CheckFileCoherence();
- if ( this->TotalNumberOfPlanes == 0)
- {
- vtkErrorMacro("File set is not coherent. Exiting...");
- return;
- }
-
- // if the user has not set the extent, but has set the VOI
- // set the zaxis extent to the VOI z axis
- if (this->DataExtent[4]==0 && this->DataExtent[5] == 0 &&
- (this->DataVOI[4] || this->DataVOI[5]))
- {
- this->DataExtent[4] = this->DataVOI[4];
- this->DataExtent[5] = this->DataVOI[5];
- }
-
- // When the user has set the VOI, check it's coherence with the file content.
- if (this->DataVOI[0] || this->DataVOI[1] ||
- this->DataVOI[2] || this->DataVOI[3] ||
- this->DataVOI[4] || this->DataVOI[5])
- {
- if ((this->DataVOI[0] < 0) ||
- (this->DataVOI[1] >= this->NumColumns) ||
- (this->DataVOI[2] < 0) ||
- (this->DataVOI[3] >= this->NumLines) ||
- (this->DataVOI[4] < 0) ||
- (this->DataVOI[5] >= this->TotalNumberOfPlanes ))
- {
- vtkWarningMacro("The requested VOI is larger than expected extent.");
- this->DataVOI[0] = 0;
- this->DataVOI[1] = this->NumColumns - 1;
- this->DataVOI[2] = 0;
- this->DataVOI[3] = this->NumLines - 1;
- this->DataVOI[4] = 0;
- this->DataVOI[5] = this->TotalNumberOfPlanes - 1;
- }
- }
-
- // Positionate the Extent.
- this->DataExtent[0] = 0;
- this->DataExtent[1] = this->NumColumns - 1;
- this->DataExtent[2] = 0;
- this->DataExtent[3] = this->NumLines - 1;
- if(this->InternalFileNameList.size() > 1)
- {
- this->DataExtent[4] = 0;
- this->DataExtent[5] = this->TotalNumberOfPlanes - 1;
- }
-
- // We don't need to positionate the Endian related stuff (by using
- // this->SetDataByteOrderToBigEndian() or SetDataByteOrderToLittleEndian()
- // since the reading of the file is done by gdcm.
- // But we do need to set up the data type for downstream filters:
- if ( ImageType == "8U" )
- {
- vtkDebugMacro("8 bits unsigned image");
- this->SetDataScalarTypeToUnsignedChar();
- }
- else if ( ImageType == "8S" )
- {
- vtkErrorMacro("Cannot handle 8 bit signed files");
- return;
- }
- else if ( ImageType == "16U" )
- {
- vtkDebugMacro("16 bits unsigned image");
- this->SetDataScalarTypeToUnsignedShort();
- }
- else if ( ImageType == "16S" )
- {
- vtkDebugMacro("16 bits signed image");
- this->SetDataScalarTypeToShort();
- //vtkErrorMacro("Cannot handle 16 bit signed files");
- }
- else if ( ImageType == "32U" )
- {
- vtkDebugMacro("32 bits unsigned image");
- vtkDebugMacro("WARNING: forced to signed int !");
- this->SetDataScalarTypeToInt();
- }
- else if ( ImageType == "32S" )
- {
- vtkDebugMacro("32 bits signed image");
- this->SetDataScalarTypeToInt();
- }
-
- //Set number of scalar components:
- this->SetNumberOfScalarComponents(this->NumComponents);
-
- vtkImageReader::ExecuteInformation();