New ImageData free logic.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "DICOMDirectoryHelper.h"
|
||||
#include "ExtendMedicalImageProperties.h"
|
||||
#include "vtkDICOMImageReader2.h"
|
||||
#include "vtkImageData.h"
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <vtkStringArray.h>
|
||||
@@ -105,14 +106,14 @@ DicomLoader::DicomLoader():m_addType(AddDicomType::DUPLICATE_TYPE) {
|
||||
// m_inputNames = InputNamesGeneratorType::New();
|
||||
|
||||
DICOMHelper = new DICOMDirectoryHelper;
|
||||
reader = vtkDICOMImageReader2::New();
|
||||
reader = nullptr;
|
||||
//transfer to series after!
|
||||
m_patients.clear();
|
||||
|
||||
}
|
||||
DicomLoader::~DicomLoader() {
|
||||
delete DICOMHelper;
|
||||
reader->Delete();
|
||||
if (reader)reader->Delete();
|
||||
reader = nullptr;
|
||||
delete instance;
|
||||
}
|
||||
@@ -199,8 +200,8 @@ void DicomLoader::InitFromRead(SeriesInstance* instance)//, DicomTagInfo_t* tag_
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//You have to use DeepCopy on this condition,otherwise, the previous image will be flushed.
|
||||
instance->m_image->DeepCopy(reader->GetOutput());
|
||||
//instance->m_image = m_itkConnector->GetOutput();
|
||||
|
||||
instance->m_image = reader->GetOutput();
|
||||
|
||||
if (instance->getUniqueID()->open_mode == DIR_OPEN_MODE)
|
||||
{
|
||||
@@ -209,6 +210,9 @@ void DicomLoader::InitFromRead(SeriesInstance* instance)//, DicomTagInfo_t* tag_
|
||||
instance->m_fileNames.push_back(v);
|
||||
});
|
||||
}
|
||||
reader->Delete();
|
||||
|
||||
reader = nullptr;
|
||||
}
|
||||
|
||||
//You may not use const & cause intance may be deleted during this func
|
||||
@@ -565,6 +569,8 @@ void DicomLoader::ItkPreReadSeries(const std::string &dicomName, SeriesOpenMode
|
||||
DICOMHelper->Update();
|
||||
if(DICOMHelper->GetSeriesCount()>0){
|
||||
currentImageProperty = DICOMHelper->GetSeries(0);
|
||||
if (reader) reader->Delete();
|
||||
reader = vtkDICOMImageReader2::New();
|
||||
reader->SetFileNames(*(currentImageProperty->GetFileNames()));
|
||||
reader->Update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user