]> Creatis software - gdcm.git/commitdiff
* vtk/vtkGdcmReader.cxx : bug fix : before, with python only, the program
authorregrain <regrain>
Thu, 15 Jan 2004 10:24:24 +0000 (10:24 +0000)
committerregrain <regrain>
Thu, 15 Jan 2004 10:24:24 +0000 (10:24 +0000)
       made a fatal error because of the memory release at the end of program.
       The problem was in vtkGdcmReader::ExecuteData where we were allocate
       some memory and vtk seems to have some problems with that.
     * src/gdcmHeaderEntrySet.cxx : bug fix for std lib and cout
     -- BeNours

ChangeLog
src/gdcmHeaderEntrySet.cxx
vtk/vtkGdcmReader.cxx

index db6de6c4edfd0bf295711d3347d8615a47090180..9eb2c49f368d63099f92fb518424ccadb421f556 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-01-15 Benoit Regrain
+     * vtk/vtkGdcmReader.cxx : bug fix : before, with python only, the program
+       made a fatal error because of the memory release at the end of program.
+       The problem was in vtkGdcmReader::ExecuteData where we were allocate
+       some memory and vtk seems to have some problems with that.
+     * src/gdcmHeaderEntrySet.cxx : bug fix for std lib and cout
+
 2004-01-14 Benoit Regrain
      * src/gdcmHeaderEntry.[h|cxx] : gdcmElValue -> gdcmHeaderEntry
      * src/gdcmHeaderEntrySet.[h|cxx] : gdcmElValSet -> gdcmHeaderEntrySet
index 7bea7efa3c1307702a4e5e1e4192b47d94e9eeb5..49139942ea60d615ee2233b3a71fef3eae876931 100644 (file)
@@ -78,13 +78,12 @@ void gdcmHeaderEntrySet::Print(std::ostream & os) {
       }              
       s << std::endl;
    }
-   os<<s.str();
 
    // List element
    guint32 lgth;
    char greltag[10];  //group element tag
  
-   std::cout << "------------ using listEntries ----------------" << std::endl; 
+   s << "------------ using listEntries ----------------" << std::endl; 
 
    char st[11];
    for (ListTag::iterator i = listEntries.begin();  
@@ -96,36 +95,38 @@ void gdcmHeaderEntrySet::Print(std::ostream & os) {
       o = (*i)->GetOffset();
       sprintf(greltag,"%04x|%04x",g,e);           
       d2 = _CreateCleanString(v);  // replace non printable characters by '.'
-      cout << greltag << " lg : ";
+      s << greltag << " lg : ";
       lgth = (*i)->GetReadLength(); 
       sprintf(st,"x(%x)",lgth);
-      std::cout.setf(ios::left);
-      std::cout << setw(10-strlen(st)) << " ";  
-      std::cout << st << " ";
-      std::cout.setf(ios::left);
-      std::cout << setw(8) << lgth; 
-      std::cout << " Off.: ";
+      s.setf(std::ios::left);
+      s << std::setw(10-strlen(st)) << " ";  
+      s << st << " ";
+      s.setf(std::ios::left);
+      s << std::setw(8) << lgth; 
+      s << " Off.: ";
       sprintf(st,"x(%x)",o); 
-      std::cout << setw(10-strlen(st)) << " ";       
-      std::cout << st << " ";
-      std::cout << setw(8) << o; 
-      std::cout << "[" << (*i)->GetVR()  << "] ";
-      std::cout.setf(ios::left);
-      std::cout << setw(66-(*i)->GetName().length()) << " ";
-      std::cout << "[" << (*i)->GetName()<< "] ";       
-      std::cout << "[" << d2 << "]";
+      s << std::setw(10-strlen(st)) << " ";       
+      s << st << " ";
+      s << std::setw(8) << o; 
+      s << "[" << (*i)->GetVR()  << "] ";
+      s.setf(std::ios::left);
+      s << std::setw(66-(*i)->GetName().length()) << " ";
+      s << "[" << (*i)->GetName()<< "] ";       
+      s << "[" << d2 << "]";
        // Display the UID value (instead of displaying the rough code)  
       if (g == 0x0002) {  // Any more to be displayed ?
          if ( (e == 0x0010) || (e == 0x0002) )            
-            std::cout << "  ==>\t[" << ts->GetValue(v) << "]";   
+            s << "  ==>\t[" << ts->GetValue(v) << "]";   
       } else {
          if (g == 0x0008) {
             if ( (e == 0x0016) || (e == 0x1150)  )        
-               std::cout << "  ==>\t[" << ts->GetValue(v) << "]"; 
+               s << "  ==>\t[" << ts->GetValue(v) << "]"; 
          }
       }                        
-      std::cout << std::endl;
+      s << std::endl;
    } 
+
+   os<<s.str();
 } 
 
 //-----------------------------------------------------------------------------
index 619896842d27832903bd5ec5ea83dc4d5c6b8452..4b652a37be579ec78dbb2464e44e9743df0f5e9c 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 ;
+   }
 }
 
 //-----------------------------------------------------------------------------
@@ -213,7 +213,7 @@ void vtkGdcmReader::ExecuteInformation()
    //Set number of scalar components:
    this->SetNumberOfScalarComponents(this->NumComponents);
 
-   vtkImageReader::ExecuteInformation();
+   this->Superclass::ExecuteInformation();
 }
 
 /*
@@ -248,7 +248,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 +258,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 +291,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();
    }
 }