]> Creatis software - gdcm.git/commitdiff
* src/gdcmHeader.h : added method to get the file name
authorregrain <regrain>
Fri, 4 Jul 2003 17:12:42 +0000 (17:12 +0000)
committerregrain <regrain>
Fri, 4 Jul 2003 17:12:42 +0000 (17:12 +0000)
      * vtk/vtkGdcmReader.[cxx|h] : bug fix concerning loading of bad dicom
        files. Added method to remove all files on the input
        Added FIXME comment concerning the bad parsing of header made by
        ExecuteInformation method (in ExecuteData method)
      -- BeNours

ChangeLog
src/gdcmHeader.h
vtk/vtkGdcmReader.cxx
vtk/vtkGdcmReader.h

index ba66981b25327b2f20278ce27ad1a41884ac6c08..e83eef49dc503478c6d0f4ec4c92a60d23651412 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-04  Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+      * src/gdcmHeader.h : added method to get the file name
+      * vtk/vtkGdcmReader.[cxx|h] : bug fix concerning loading of bad dicom
+        files. Added method to remove all files on the input
+        Added FIXME comment concerning the bad parsing of header made by
+        ExecuteInformation method (in ExecuteData method)
+
 2003-07-03  Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
       * vtk/Makefile.am: vtkGdcmReader.h should now be cleany installed
         when using make instal.
index 1657e70c0c343a32ef64e957a85a83d0b560f429..8d6d4b783e6b975de8d25ea5eeab15921d11886d 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.32 2003/07/02 16:47:22 jpr Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.33 2003/07/04 17:12:42 regrain Exp $
 
 #ifndef GDCMHEADER_H
 #define GDCMHEADER_H
@@ -133,6 +133,8 @@ public:
    gdcmHeader(const char *filename, bool exception_on_error = false);
    gdcmHeader( bool exception_on_error = false);
    virtual ~gdcmHeader();
+
+       std::string GetFileName(void) {return filename;}
    
    size_t GetPixelOffset(void);
    int    GetSwapCode(void) { return sw; }
index a3e871f78974451c97d875e16343df3b48e80d65..41c41df1edf7fbe39f6de22d94712c70ab799be4 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.13 2003/07/01 10:04:37 frog Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.14 2003/07/04 17:12:43 regrain Exp $
 #include <stdio.h>
 #include <vtkObjectFactory.h>
 #include <vtkImageData.h>
@@ -18,6 +18,13 @@ vtkGdcmReader::~vtkGdcmReader()
   this->FileNameList.clear();
 }
 
+//----------------------------------------------------------------------------
+// Remove all files from the list of images to read.
+void vtkGdcmReader::RemoveAllFileName(void)
+{
+  this->FileNameList.clear();
+}
+
 //----------------------------------------------------------------------------
 // Adds a file name to the list of images to read.
 void vtkGdcmReader::AddFileName(const char* name)
@@ -96,7 +103,7 @@ void vtkGdcmReader::BuildFileListFromPattern()
 // (i.e. an image represents one plane, but a volume represents many planes)
 int vtkGdcmReader::CheckFileCoherence()
 {
-   int ReturnedTotalNumberOfPlanes = 0;   // The returned value.
+       int ReturnedTotalNumberOfPlanes = 0;   // The returned value.
 
    this->BuildFileListFromPattern();
    if (this->FileNameList.empty())
@@ -115,6 +122,17 @@ int vtkGdcmReader::CheckFileCoherence()
                                         FileName != FileNameList.end();
                                       ++FileName)
      {
+     // The file is always added in the number of planes
+     //  - If file doesn't exist, it will be replaced by a black place in the 
+     //    ExecuteData method
+     //  - If file has more than 1 plane, other planes will be added later to
+     //    to the ReturnedTotalNumberOfPlanes variable counter
+     ReturnedTotalNumberOfPlanes += 1;
+
+     /////// Stage 0: check for file name:
+         if(*FileName==std::string("GDCM_UNREADABLE"))
+                 continue;
+
      /////// Stage 1: check for file readability:
      // Stage 1.1: check for file existence.
      FILE *fp;
@@ -191,14 +209,12 @@ int vtkGdcmReader::CheckFileCoherence()
          {
          vtkErrorMacro("This file contains multiple planes (images)"
                        << FileName->c_str());
-         vtkErrorMacro("Removing this file from readed files " 
-                       << FileName->c_str());
          }
 
        // Eventually, this file can be added on the stack. Update the
        // full size of the stack
        vtkDebugMacro("Number of planes added to the stack: " << NZ);
-       ReturnedTotalNumberOfPlanes += NZ;
+       ReturnedTotalNumberOfPlanes += NZ - 1; // First plane already added
        continue;
 
        } else {
@@ -214,7 +230,7 @@ int vtkGdcmReader::CheckFileCoherence()
        this->NumColumns = NX;
        this->NumLines   = NY;
        ReferenceNZ      = NZ;
-       ReturnedTotalNumberOfPlanes += NZ;
+       ReturnedTotalNumberOfPlanes += NZ - 1; // First plane already added
        this->ImageType = type;
        this->PixelSize = GdcmHeader.GetPixelSize();
        }
@@ -239,14 +255,15 @@ int vtkGdcmReader::CheckFileCoherence()
 
    vtkDebugMacro("Total number of planes on the stack: "
                  << ReturnedTotalNumberOfPlanes);
-   return ReturnedTotalNumberOfPlanes;
+   
+       return ReturnedTotalNumberOfPlanes;
 }
 
 //----------------------------------------------------------------------------
 // Configure the output e.g. WholeExtent, spacing, origin, scalar type...
 void vtkGdcmReader::ExecuteInformation()
 {
-  //FIXME free any old memory
+       //FIXME free any old memory
   this->TotalNumberOfPlanes = this->CheckFileCoherence();
   if ( this->TotalNumberOfPlanes == 0)
     {
@@ -382,8 +399,8 @@ size_t vtkGdcmReader::LoadImageInMemory(
 }
 
 //----------------------------------------------------------------------------
-// Update -> UpdateData -> Execute -> ExecuteData (see vtkSource.cxx for
-// last step.
+// Update => ouput->Update => UpdateData => Execute => ExecuteData 
+// (see vtkSource.cxx for last step).
 // This function (redefinition of vtkImageReader::ExecuteData, see 
 // VTK/IO/vtkImageReader.cxx) reads a data from a file. The datas
 // extent/axes are assumed to be the
@@ -396,6 +413,7 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
     return;
     }
 
+  // FIXME : the bad parse of header is made when allocating OuputData
   vtkImageData *data = this->AllocateOutputData(output);
   data->SetExtent(this->DataExtent);
   data->GetPointData()->GetScalars()->SetName("DicomImage-Volume");
@@ -435,13 +453,14 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
       // this image/volume couldn't be loaded. We simply skip one image
       // size:
       Dest += this->NumColumns * this->NumLines * this->PixelSize;
-      // Update progress related:
-      UpdateProgressCount += this->NumLines;
-      if (!(UpdateProgressCount%UpdateProgressTarget))
-        {
-        this->UpdateProgress(UpdateProgressCount/(50.0*UpdateProgressTarget));
-        }
       } // Else, file not loadable
+
+    // Update progress related:
+    UpdateProgressCount += this->NumLines;
+    if (!(UpdateProgressCount%UpdateProgressTarget))
+               {
+      this->UpdateProgress(UpdateProgressCount/(50.0*UpdateProgressTarget));
+               }
     } // Loop on files
 
   // The "size" of the vtkScalars data is expressed in number of points,
index 7c495337a2beaf02a3d4b11d42028ce10dfddee2..490d3b1b048675573725f9ae5a1d0346f37a97e6 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.h,v 1.6 2003/06/12 14:53:01 malaterre Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.h,v 1.7 2003/07/04 17:12:43 regrain Exp $
 
 #ifndef __vtkGdcmReader_h
 #define __vtkGdcmReader_h
@@ -13,8 +13,11 @@ public:
   static vtkGdcmReader *New() {return new vtkGdcmReader;};
   vtkTypeMacro(vtkGdcmReader, vtkImageReader);
   void PrintSelf(ostream& os, vtkIndent indent);
+
+  void RemoveAllFileName(void);
   void AddFileName(const char* name);
   void SetFileName(const char *name);
+
 protected:
   vtkGdcmReader();
   ~vtkGdcmReader();
@@ -22,6 +25,7 @@ protected:
   void ExecuteData(vtkDataObject *output);
   void BuildFileListFromPattern();
   int CheckFileCoherence();
+
 private:
   //BTX
   // Number of columns of the image/volume to be loaded
@@ -37,6 +41,7 @@ private:
   // List of filenames to be read in order to build a stack of images
   // or volume. The order in the list shall be the order of the images.
   std::list<std::string> FileNameList;
+
   size_t LoadImageInMemory(std::string FileName, unsigned char * Dest,
                            const unsigned long UpdateProgressTarget,
                            unsigned long & UpdateProgressCount);