From: malaterre Date: Mon, 7 Jun 2004 03:21:43 +0000 (+0000) Subject: ENH: Add a new flag to vtkGdcmReader: AllowLookupTable, user can now select if he... X-Git-Tag: Version0.5.bp~153 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9cfc9aff66a9339b8b467f48c8a5ef6e39ae9e34;p=gdcm.git ENH: Add a new flag to vtkGdcmReader: AllowLookupTable, user can now select if he wants to use a lookuptable when possible, disable by default --- diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index 7ef73566..ea4545a0 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -63,6 +63,7 @@ vtkGdcmReader::vtkGdcmReader() { this->LookupTable = NULL; + this->AllowLookupTable = 0; } vtkGdcmReader::~vtkGdcmReader() @@ -529,8 +530,9 @@ int vtkGdcmReader::CheckFileCoherence() this->ImageType = type; this->PixelSize = GdcmHeader.GetPixelSize(); - if( GdcmHeader.HasLUT() && false ) + if( GdcmHeader.HasLUT() && this->AllowLookupTable ) { + // I could raise an error is AllowLookupTable is on and HasLUT() off this->NumComponents = GdcmHeader.GetNumberOfScalarComponentsRaw(); } else @@ -624,7 +626,7 @@ size_t vtkGdcmReader::LoadImageInMemory( unsigned char * Source; - if( GdcmFile.GetHeader()->HasLUT() && false ) + if( GdcmFile.GetHeader()->HasLUT() && this->AllowLookupTable ) { size = GdcmFile.GetImageDataSizeRaw(); Source = (unsigned char*) GdcmFile.GetImageDataRaw(); diff --git a/vtk/vtkGdcmReader.h b/vtk/vtkGdcmReader.h index 32fc2fd0..b196c808 100644 --- a/vtk/vtkGdcmReader.h +++ b/vtk/vtkGdcmReader.h @@ -21,6 +21,15 @@ public: virtual void RemoveAllFileName(void); virtual void AddFileName(const char* name); virtual void SetFileName(const char *name); + + // Description: + // If this flag is set and the DICOM reader encounters a dicom file with + // lookup table the data will be kept as unsigned chars and a lookuptable + // will be exported and accessible through GetLookupTable() + vtkSetMacro(AllowLookupTable,int); + vtkGetMacro(AllowLookupTable,int); + vtkBooleanMacro(AllowLookupTable,int); + vtkGetObjectMacro(LookupTable,vtkLookupTable); protected: @@ -45,6 +54,7 @@ private: // Variables vtkLookupTable *LookupTable; vtkTimeStamp fileTime; + int AllowLookupTable; //BTX // Number of columns of the image/volume to be loaded diff --git a/vtk/vtkgdcmViewer.cxx b/vtk/vtkgdcmViewer.cxx index f1c1c32f..e6326efd 100644 --- a/vtk/vtkgdcmViewer.cxx +++ b/vtk/vtkgdcmViewer.cxx @@ -51,6 +51,7 @@ int main(int argc, char *argv[]) return 0; vtkGdcmReader *reader = vtkGdcmReader::New(); + reader->AllowLookupTableOff(); if( argc == 2 ) reader->SetFileName( argv[1] ); @@ -68,7 +69,7 @@ int main(int argc, char *argv[]) vtkImageViewer2 *viewer = vtkImageViewer2::New(); -/* if( reader->GetLookupTable() ) + if( reader->GetLookupTable() ) { //convert to color: vtkImageMapToColors *map = vtkImageMapToColors::New (); @@ -78,8 +79,7 @@ int main(int argc, char *argv[]) viewer->SetInput ( map->GetOutput() ); map->Delete(); } - else*/ - + else { viewer->SetInput ( reader->GetOutput() ); }