Commit a0c73232 authored by Jim Miller's avatar Jim Miller
Browse files

FIX: access routines were returning internal data from a temporary. Needed to...

FIX: access routines were returning internal data from a temporary.  Needed to cache the temporaries in an ivar.
parent 8294013a
......@@ -29,7 +29,7 @@
#include <vtkstd/vector>
#include <vtkstd/string>
vtkCxxRevisionMacro(vtkDICOMImageReader, "1.18.2.2");
vtkCxxRevisionMacro(vtkDICOMImageReader, "1.18.2.3");
vtkStandardNewMacro(vtkDICOMImageReader);
class vtkDICOMImageReaderVector : public vtkstd::vector<vtkstd::string>
......@@ -42,6 +42,10 @@ vtkDICOMImageReader::vtkDICOMImageReader()
this->Parser = new DICOMParser();
this->AppHelper = new DICOMAppHelper();
this->DirectoryName = NULL;
this->PatientName = NULL;
this->StudyUID = NULL;
this->StudyID = NULL;
this->TransferSyntaxUID = NULL;
this->DICOMFileNames = new vtkDICOMImageReaderVector();
}
......@@ -55,6 +59,22 @@ vtkDICOMImageReader::~vtkDICOMImageReader()
{
delete [] this->DirectoryName;
}
if (this->PatientName)
{
delete [] this->PatientName;
}
if (this->StudyUID)
{
delete [] this->StudyUID;
}
if (this->StudyID)
{
delete [] this->StudyID;
}
if (this->TransferSyntaxUID)
{
delete [] this->TransferSyntaxUID;
}
}
void vtkDICOMImageReader::PrintSelf(ostream& os, vtkIndent indent)
......@@ -464,7 +484,17 @@ int vtkDICOMImageReader::GetNumberOfComponents()
const char* vtkDICOMImageReader::GetTransferSyntaxUID()
{
return this->AppHelper->GetTransferSyntaxUID().c_str();
vtkstd::string tmp = this->AppHelper->GetTransferSyntaxUID();
if (this->TransferSyntaxUID)
{
delete [] this->TransferSyntaxUID;
}
this->TransferSyntaxUID = new char[tmp.length()+1];
strcpy(this->TransferSyntaxUID, tmp.c_str());
this->TransferSyntaxUID[tmp.length()] = '\0';
return this->TransferSyntaxUID;
}
float vtkDICOMImageReader::GetRescaleSlope()
......@@ -479,12 +509,47 @@ float vtkDICOMImageReader::GetRescaleOffset()
const char* vtkDICOMImageReader::GetPatientName()
{
return this->AppHelper->GetPatientName().c_str();
vtkstd::string tmp = this->AppHelper->GetPatientName();
if (this->PatientName)
{
delete [] this->PatientName;
}
this->PatientName = new char[tmp.length()+1];
strcpy(this->PatientName, tmp.c_str());
this->PatientName[tmp.length()] = '\0';
return this->PatientName;
}
const char* vtkDICOMImageReader::GetStudyUID()
{
return this->AppHelper->GetStudyUID().c_str();
vtkstd::string tmp = this->AppHelper->GetStudyUID();
if (this->StudyUID)
{
delete [] this->StudyUID;
}
this->StudyUID = new char[tmp.length()+1];
strcpy(this->StudyUID, tmp.c_str());
this->StudyUID[tmp.length()] = '\0';
return this->StudyUID;
}
const char* vtkDICOMImageReader::GetStudyID()
{
vtkstd::string tmp = this->AppHelper->GetStudyID();
if (this->StudyID)
{
delete [] this->StudyID;
}
this->StudyID = new char[tmp.length()+1];
strcpy(this->StudyID, tmp.c_str());
this->StudyID[tmp.length()] = '\0';
return this->StudyID;
}
float vtkDICOMImageReader::GetGantryAngle()
......
......@@ -126,6 +126,10 @@ class VTK_IO_EXPORT vtkDICOMImageReader : public vtkImageReader2
// Get the study uid for the last image processed.
const char* GetStudyUID();
// Description:
// Get the Study ID for the last image processed.
const char* GetStudyID();
// Description:
// Get the gantry angle for the last image processed.
float GetGantryAngle();
......@@ -185,6 +189,11 @@ protected:
vtkDICOMImageReaderVector* DICOMFileNames;
char* DirectoryName;
char* PatientName;
char* StudyUID;
char* StudyID;
char* TransferSyntaxUID;
private:
vtkDICOMImageReader(const vtkDICOMImageReader&); // Not implemented.
void operator=(const vtkDICOMImageReader&); // Not implemented.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment