-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.23 2003/11/03 10:51:47 jpr Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.28 2003/11/13 10:23:41 malaterre Exp $
// //////////////////////////////////////////////////////////////
// WARNING TODO CLENAME
// Actual limitations of this code:
// time...
// //////////////////////////////////////////////////////////////
-#include <stdio.h>
+#include "gdcmFile.h"
+#include "gdcmHeaderHelper.h"
+#include "vtkGdcmReader.h"
+
+//#include <stdio.h>
#include <vtkObjectFactory.h>
#include <vtkImageData.h>
#include <vtkPointData.h>
-#include "vtkGdcmReader.h"
-#include "gdcm.h"
-#include "gdcmHeaderHelper.h"
+#include <vtkLookupTable.h>
+
vtkGdcmReader::vtkGdcmReader()
{
// Constructor
+ this->LookupTable = NULL;
}
//----------------------------------------------------------------------------
{
this->RemoveAllFileName();
this->InternalFileNameList.clear();
+ if(this->LookupTable) this->LookupTable->Delete();
}
//----------------------------------------------------------------------------
&& (type != "32U") && (type != "32S") )
{
vtkErrorMacro("Bad File Type for file" << FileName->c_str());
- vtkErrorMacro(" " << type);
+ vtkErrorMacro(" " << type.c_str());
vtkErrorMacro("Removing this file from readed files "
<< FileName->c_str());
*FileName = "GDCM_UNREADABLE";
this->ImageType = type;
this->PixelSize = GdcmHeader.GetPixelSize();
- // JPR to Mathieu:
- // Be carefull : when u'll pane to use 'GetImageDataRaw',
- // use 'GetNumberOfScalarComponentsRaw' !
-
- this->NumComponents = GdcmHeader.GetNumberOfScalarComponents(); //rgb or mono
+ if( GdcmHeader.HasLUT() )
+ {
+ this->NumComponents = GdcmHeader.GetNumberOfScalarComponentsRaw();
+ }
+ else
+ {
+ this->NumComponents = GdcmHeader.GetNumberOfScalarComponents(); //rgb or mono
+ }
//Set image spacing
this->DataSpacing[0] = GdcmHeader.GetXSpacing();
{
vtkDebugMacro("Copying to memory image" << FileName.c_str());
gdcmFile GdcmFile(FileName.c_str());
- size_t size = GdcmFile.GetImageDataSize();
+ size_t size;
// If the data structure of vtk for image/volume representation
// were straigthforwards the following would suffice:
int NumLines = GdcmFile.GetYSize();
int NumPlanes = GdcmFile.GetZSize();
int LineSize = NumComponents * NumColumns * GdcmFile.GetPixelSize();
- unsigned char * Source = (unsigned char*)GdcmFile.GetImageData();
+
+ unsigned char * Source;
+ if( GdcmFile.HasLUT() )
+ {
+ size = GdcmFile.GetImageDataSizeRaw();
+ Source = (unsigned char*) GdcmFile.GetImageDataRaw();
+ unsigned char *Lut = GdcmFile.GetLUTRGBA();
+
+ if(!this->LookupTable) this->LookupTable = vtkLookupTable::New();
+ this->LookupTable->SetNumberOfTableValues(256);
+ for (int tmp=0; tmp<256; tmp++)
+ {
+ this->LookupTable->SetTableValue(tmp,
+ (float)Lut[4*tmp+0]/255.0,
+ (float)Lut[4*tmp+1]/255.0,
+ (float)Lut[4*tmp+2]/255.0,
+ 1);
+ }
+ this->LookupTable->SetRange(0,255);
+ vtkDataSetAttributes *a=this->GetOutput()->GetPointData();
+ a->GetScalars()->SetLookupTable(this->LookupTable);
+ free(Lut);
+ }
+ else
+ {
+ size = GdcmFile.GetImageDataSize();
+ Source = (unsigned char*)GdcmFile.GetImageData();
+ }
unsigned char * pSource = Source; //pointer for later deletion
unsigned char * Destination = Dest + size - LineSize;