]> Creatis software - gdcm.git/blobdiff - vtk/vtkGdcmReader.cxx
ENH: Minor patch
[gdcm.git] / vtk / vtkGdcmReader.cxx
index 94fc11ce25d4a61be44507575f994eb62ad690f4..798139a0283c69966596d115c68a91a24d0128db 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmReader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 08:28:32 $
-  Version:   $Revision: 1.80 $
+  Date:      $Date: 2006/03/29 11:23:43 $
+  Version:   $Revision: 1.86 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -69,7 +69,7 @@
 #include <vtkPointData.h>
 #include <vtkLookupTable.h>
 
-vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.80 $")
+vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.86 $")
 vtkStandardNewMacro(vtkGdcmReader)
 
 //-----------------------------------------------------------------------------
@@ -87,7 +87,7 @@ vtkGdcmReader::vtkGdcmReader()
    this->UserFunction     = 0;
 
    this->OwnFile=true;
-   this->Execution=false;
+   // this->Execution=false; // For VTK5.0
 }
 
 vtkGdcmReader::~vtkGdcmReader()
@@ -156,10 +156,10 @@ void vtkGdcmReader::SetFileName(const char *name)
  */
 void vtkGdcmReader::ExecuteInformation()
 {
-   if(this->Execution)
-      return;
-
-   this->Execution=true;
+//   if(this->Execution)  // For VTK5.0
+//      return;
+//
+//   this->Execution=true; // end For VTK5.0
    this->RemoveAllInternalFile();
    if(this->MTime>this->fileTime)
    {
@@ -266,13 +266,13 @@ void vtkGdcmReader::ExecuteInformation()
       this->fileTime=this->MTime;
    }
 
-   this->Superclass::ExecuteInformation();
+   this->Superclass::ExecuteInformation();  
 
-   this->GetOutput()->SetUpdateExtentToWholeExtent();
-   this->BuildData(this->GetOutput());
+   //this->GetOutput()->SetUpdateExtentToWholeExtent();// For VTK5.0
+   //this->BuildData(this->GetOutput());
 
-   this->Execution=false;
-   this->RemoveAllInternalFile();
+   //this->Execution=false;
+   //this->RemoveAllInternalFile();                   // End For VTK5.0
 }
  
 /*
@@ -301,11 +301,23 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
       return;
    }
 */
-}
-
-void vtkGdcmReader::BuildData(vtkDataObject *output)
-{
-   vtkImageData *data = this->AllocateOutputData(output);
+  
+  // data->AllocateScalars();  // For VTK5.0
+  // if (this->UpdateExtentIsEmpty(output))
+  // {
+  //    return;
+  // }
+//}                           // end For VTK5.0
+
+   data->AllocateScalars();  // For VTK5.0
+   if (this->UpdateExtentIsEmpty(output))
+   {
+      return;
+   }
+   
+//void vtkGdcmReader::BuildData(vtkDataObject *output)  // For VTK5.0
+//{
+//   vtkImageData *data = this->AllocateOutputData(output);  // end For VTK5.0
 
    data->GetPointData()->GetScalars()->SetName("DicomImage-Volume");
 
@@ -345,6 +357,7 @@ void vtkGdcmReader::BuildData(vtkDataObject *output)
          Dest += size;
       }
    }
+   this->RemoveAllInternalFile(); // For VTK5.0
 }
 
 /*
@@ -452,7 +465,7 @@ void vtkGdcmReader::LoadFileInformation()
       fclose(fp);
 
       // Read the file
-      file=new gdcm::File();
+      file=gdcm::File::New();
       file->SetLoadMode( LoadMode );
       file->SetFileName(filename->c_str() );
       file->Load();
@@ -463,7 +476,7 @@ void vtkGdcmReader::LoadFileInformation()
          vtkErrorMacro(<< "Gdcm cannot parse file " << filename->c_str());
          vtkErrorMacro(<< "Removing this file from read files: "
                         << filename->c_str());
-         delete file;
+         file->Delete();
          file=NULL;
          InternalFileList.push_back(file);
          continue;
@@ -479,7 +492,7 @@ void vtkGdcmReader::LoadFileInformation()
                        << "   File type found : " << type.c_str() 
                        << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n"
                        << "   Removing this file from read files");
-         delete file;
+         file->Delete();
          file=NULL;
          InternalFileList.push_back(file);
          continue;
@@ -499,7 +512,7 @@ void vtkGdcmReader::LoadFileInformation()
       }
       else if(!TestFileInformation(file))
       {
-         delete file;
+         file->Delete();
          file=NULL;
       }
 
@@ -681,7 +694,7 @@ void vtkGdcmReader::RemoveAllInternalFile(void)
                                  it!=InternalFileList.end();
                                  ++it)
       {
-         delete (*it);
+         (*it)->Delete();
       }
    }
    this->InternalFileList.clear();
@@ -696,7 +709,8 @@ void vtkGdcmReader::IncrementProgress(const unsigned long updateProgressTarget,
    {
       if (!(updateProgressCount%updateProgressTarget))
       {
-         this->UpdateProgress(updateProgressCount/(50.0*updateProgressTarget));
+         this->UpdateProgress(
+             updateProgressCount/(50.0*updateProgressTarget));
       }
    }
 }
@@ -741,7 +755,7 @@ void vtkGdcmReader::LoadImageInMemory(
    if(!f)
       return;
 
-   gdcm::FileHelper *fileH = new gdcm::FileHelper( f );
+   gdcm::FileHelper *fileH = gdcm::FileHelper::New( f );
    fileH->SetUserFunction( UserFunction );
 
    int numColumns = f->GetXSize();
@@ -753,9 +767,9 @@ void vtkGdcmReader::LoadImageInMemory(
       numComponents = f->GetNumberOfScalarComponentsRaw();
    else
       numComponents = f->GetNumberOfScalarComponents(); //rgb or mono
-
+   vtkDebugMacro(<< "numComponents:" << numComponents);
    vtkDebugMacro(<< "Copying to memory image [" << f->GetFileName().c_str() << "]");
-   size_t size;
+   //size_t size;
 
    // If the data structure of vtk for image/volume representation
    // were straigthforwards the following would be enough:
@@ -771,7 +785,8 @@ void vtkGdcmReader::LoadImageInMemory(
    
    if( fileH->GetFile()->HasLUT() && AllowLookupTable )
    {
-      size               = fileH->GetImageDataSize();
+      // to avoid bcc 5.5 w
+      /*size               = */ fileH->GetImageDataSize(); 
       src                = (unsigned char*) fileH->GetImageDataRaw();
       unsigned char *lut = (unsigned char*) fileH->GetLutRGBA();
 
@@ -796,8 +811,9 @@ void vtkGdcmReader::LoadImageInMemory(
    }
    else
    {
-      size = fileH->GetImageDataSize();
-      src  = (unsigned char*)fileH->GetImageData();
+      //size = fileH->GetImageDataSize(); 
+      // useless - just an accessor;  'size' unused
+      src  = (unsigned char*)fileH->GetImageData();  
    } 
 
    unsigned char *dst = dest + planeSize - lineSize;
@@ -812,14 +828,15 @@ void vtkGdcmReader::LoadImageInMemory(
          // Update progress related:
          if (!(updateProgressCount%updateProgressTarget))
          {
-            this->UpdateProgress(updateProgressCount/(50.0*updateProgressTarget));
+            this->UpdateProgress(
+               updateProgressCount/(50.0*updateProgressTarget));
          }
          updateProgressCount++;
       }
       dst += 2 * planeSize;
    }
 
-   delete fileH;
+   fileH->Delete();
 }
 
 //-----------------------------------------------------------------------------