-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.18 2003/08/29 09:47:13 malaterre Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.21 2003/10/24 15:38:56 malaterre Exp $
// //////////////////////////////////////////////////////////////
// WARNING TODO CLENAME
// Actual limitations of this code:
#include <vtkPointData.h>
#include "vtkGdcmReader.h"
#include "gdcm.h"
+#include "gdcmHeaderHelper.h"
vtkGdcmReader::vtkGdcmReader()
{
}
this->RemoveAllInternalFileName();
- for (int idx = this->DataExtent[4]; idx <= this->DataExtent[5]; ++idx)
+ if( this->FileNameList.empty() )
{
- this->ComputeInternalFileName(idx);
+ //Multiframe case:
+ this->ComputeInternalFileName(this->DataExtent[4]);
vtkDebugMacro("Adding file " << this->InternalFileName);
this->AddInternalFileName(this->InternalFileName);
}
+ else
+ {
+ //stack of 2D dicom case:
+ for (int idx = this->DataExtent[4]; idx <= this->DataExtent[5]; ++idx)
+ {
+ this->ComputeInternalFileName(idx);
+ vtkDebugMacro("Adding file " << this->InternalFileName);
+ this->AddInternalFileName(this->InternalFileName);
+ }
+ }
}
//----------------------------------------------------------------------------
fclose(fp);
// Stage 1.2: check for Gdcm parsability
- gdcmHeader GdcmHeader(FileName->c_str());
+ gdcmHeaderHelper GdcmHeader(FileName->c_str());
if (!GdcmHeader.IsReadable())
{
vtkErrorMacro("Gdcm cannot parse file " << FileName->c_str());
ReturnedTotalNumberOfPlanes += NZ - 1; // First plane already added
this->ImageType = type;
this->PixelSize = GdcmHeader.GetPixelSize();
+ this->NumComponents = GdcmHeader.GetNumberOfScalarComponents(); //rgb or mono
+
+ //Set image spacing
+ this->DataSpacing[0] = GdcmHeader.GetXSpacing();
+ this->DataSpacing[1] = GdcmHeader.GetYSpacing();
+ this->DataSpacing[2] = GdcmHeader.GetZSpacing();
+
+ //Set image origin
+ this->DataOrigin[0] = GdcmHeader.GetXOrigin();
+ this->DataOrigin[1] = GdcmHeader.GetYOrigin();
+ this->DataOrigin[2] = GdcmHeader.GetZOrigin();
+
}
} // End of loop on FileName
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;
- }
+ 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()
this->SetDataScalarTypeToInt();
}
+ //Set number of scalar components:
+ this->SetNumberOfScalarComponents(this->NumComponents);
+
vtkImageReader::ExecuteInformation();
}
const unsigned long UpdateProgressTarget,
unsigned long & UpdateProgressCount)
{
- vtkDebugMacro("Copying to memmory image" << FileName.c_str());
+ vtkDebugMacro("Copying to memory image" << FileName.c_str());
gdcmFile GdcmFile(FileName.c_str());
size_t size = GdcmFile.GetImageDataSize();
int NumColumns = GdcmFile.GetXSize();
int NumLines = GdcmFile.GetYSize();
int NumPlanes = GdcmFile.GetZSize();
- int LineSize = NumColumns * GdcmFile.GetPixelSize();
+ int LineSize = NumComponents * NumColumns * GdcmFile.GetPixelSize();
unsigned char * Source = (unsigned char*)GdcmFile.GetImageData();
unsigned char * pSource = Source; //pointer for later deletion
unsigned char * Destination = Dest + size - LineSize;
// The memory size for a full stack of images of course depends
// on the number of planes and the size of each image:
size_t StackNumPixels = this->NumColumns * this->NumLines
- * this->TotalNumberOfPlanes;
+ * this->TotalNumberOfPlanes * this->NumComponents;
size_t stack_size = StackNumPixels * this->PixelSize;
// Allocate pixel data space itself.
unsigned char *mem = new unsigned char [stack_size];
// The "size" of the vtkScalars data is expressed in number of points,
// and is not the memory size representing those points:
data->GetPointData()->GetScalars()->SetVoidArray(mem, StackNumPixels, 0);
- this->Modified();
+ //don't know why it's here, it's calling one more time ExecuteInformation:
+ //this->Modified();
}
}