]> Creatis software - gdcm.git/commitdiff
ENH: Add a new flag to vtkGdcmReader: AllowLookupTable, user can now select if he...
authormalaterre <malaterre>
Mon, 7 Jun 2004 03:21:43 +0000 (03:21 +0000)
committermalaterre <malaterre>
Mon, 7 Jun 2004 03:21:43 +0000 (03:21 +0000)
vtk/vtkGdcmReader.cxx
vtk/vtkGdcmReader.h
vtk/vtkgdcmViewer.cxx

index 7ef73566e8963d9ac0596a019626c99af7e9961e..ea4545a02a57c104cbe938be545d633b254083be 100644 (file)
@@ -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();
index 32fc2fd0994a53e046328281d048fc35096104b6..b196c808a5a4040be3d19c9acfbc644e94fd2d7b 100644 (file)
@@ -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
index f1c1c32f5d8ca558a56df9f704ea0e153127699c..e6326efd8e9d03d337ecc14321bb40e3f419906b 100644 (file)
@@ -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() );
   }