From 97a4e78229c03da87d956291f56485d5772c8cc1 Mon Sep 17 00:00:00 2001 From: regrain Date: Thu, 15 Jan 2004 10:24:24 +0000 Subject: [PATCH] * 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 -- BeNours --- ChangeLog | 7 +++++++ src/gdcmHeaderEntrySet.cxx | 41 +++++++++++++++++++------------------- vtk/vtkGdcmReader.cxx | 31 +++++++++++----------------- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index db6de6c4..9eb2c49f 100644 --- 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 diff --git a/src/gdcmHeaderEntrySet.cxx b/src/gdcmHeaderEntrySet.cxx index 7bea7efa..49139942 100644 --- a/src/gdcmHeaderEntrySet.cxx +++ b/src/gdcmHeaderEntrySet.cxx @@ -78,13 +78,12 @@ void gdcmHeaderEntrySet::Print(std::ostream & os) { } s << std::endl; } - os<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<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::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::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::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(); } } -- 2.48.1