]> Creatis software - gdcm.git/blobdiff - vtk/vtkGdcmReader.cxx
2004-03-24 Jean-Pierre Roux
[gdcm.git] / vtk / vtkGdcmReader.cxx
index 619896842d27832903bd5ec5ea83dc4d5c6b8452..5fb33b226fca53838fb756a767a7a003527c62a8 100644 (file)
@@ -61,7 +61,7 @@ vtkGdcmReader::vtkGdcmReader()
 }
 
 vtkGdcmReader::~vtkGdcmReader()
-{ 
+{
    this->RemoveAllFileName();
    this->InternalFileNameList.clear();
    if(this->LookupTable) 
@@ -72,15 +72,15 @@ vtkGdcmReader::~vtkGdcmReader()
 // Print
 void vtkGdcmReader::PrintSelf(ostream& os, vtkIndent indent)
 {
-  vtkImageReader::PrintSelf(os,indent);
-  os << indent << "Filenames  : " << endl;
-  vtkIndent nextIndent = indent.GetNextIndent();
-  for (std::list<std::string>::iterator FileName  = FileNameList.begin();
-                                        FileName != FileNameList.end();
-                                      ++FileName)
-    {
-    os << nextIndent << FileName->c_str() << endl ;
-    }
+   vtkImageReader::PrintSelf(os,indent);
+   os << indent << "Filenames  : " << endl;
+   vtkIndent nextIndent = indent.GetNextIndent();
+   for (std::list<std::string>::iterator FileName  = FileNameList.begin();
+        FileName != FileNameList.end();
+        ++FileName)
+   {
+      os << nextIndent << FileName->c_str() << endl ;
+   }
 }
 
 //-----------------------------------------------------------------------------
@@ -209,11 +209,15 @@ void vtkGdcmReader::ExecuteInformation()
       vtkDebugMacro("32 bits signed image");
       this->SetDataScalarTypeToInt();
    }
-
+   else if ( ImageType == "FD" )
+   {
+      vtkDebugMacro("64 bits Double image");
+      this->SetDataScalarTypeToDouble();
+   }
    //Set number of scalar components:
    this->SetNumberOfScalarComponents(this->NumComponents);
 
-   vtkImageReader::ExecuteInformation();
+   this->Superclass::ExecuteInformation();
 }
 
 /*
@@ -248,7 +252,6 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
                             * this->TotalNumberOfPlanes * this->NumComponents;
       size_t stack_size = StackNumPixels * this->PixelSize;
       // Allocate pixel data space itself.
-      unsigned char *mem = new unsigned char [stack_size];
 
       // Variables for the UpdateProgress. We shall use 50 steps to signify
       // the advance of the process:
@@ -259,7 +262,7 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
       unsigned long UpdateProgressCount = 0;
 
       // Feeling the allocated memory space with each image/volume:
-      unsigned char * Dest = mem;
+      unsigned char *Dest = (unsigned char *)data->GetPointData()->GetScalars()->GetVoidPointer(0);
       for (std::list<std::string>::iterator FileName  = InternalFileNameList.begin();
            FileName != InternalFileNameList.end();
            ++FileName)
@@ -292,12 +295,6 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
             }
          } // Else, file not loadable
       } // Loop on files
-
-      // The "size" of the vtkScalars data is expressed in number of points,
-      // and is not the memory size representing those points:
-      data->GetPointData()->GetScalars()->SetVoidArray(mem, StackNumPixels, 0);
-      //don't know why it's here, it's calling one more time ExecuteInformation:
-      //this->Modified();
    }
 }
 
@@ -584,7 +581,7 @@ size_t vtkGdcmReader::LoadImageInMemory(
    size_t size;
 
    // If the data structure of vtk for image/volume representation
-   // were straigthforwards the following would suffice:
+   // were straigthforwards the following would be enough:
    //    GdcmFile.GetImageDataIntoVector((void*)Dest, size);
    // But vtk chooses to invert the lines of an image, that is the last
    // line comes first (for some axis related reasons?). Hence we need
@@ -596,6 +593,7 @@ size_t vtkGdcmReader::LoadImageInMemory(
    int LineSize   = NumComponents * NumColumns * GdcmFile.GetHeader()->GetPixelSize();
 
    unsigned char * Source;
+   
    if( GdcmFile.GetHeader()->HasLUT() )
    {
       size               = GdcmFile.GetImageDataSizeRaw();
@@ -645,7 +643,6 @@ size_t vtkGdcmReader::LoadImageInMemory(
    }
    //GetImageData allocate a (void*)malloc, remove it:
    free(pSource);
-
    return size;
 }