New ImageData free logic.
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include "DICOMDirectoryHelper.h"
|
#include "DICOMDirectoryHelper.h"
|
||||||
#include "ExtendMedicalImageProperties.h"
|
#include "ExtendMedicalImageProperties.h"
|
||||||
#include "vtkDICOMImageReader2.h"
|
#include "vtkDICOMImageReader2.h"
|
||||||
|
#include "vtkImageData.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vtkStringArray.h>
|
#include <vtkStringArray.h>
|
||||||
@@ -105,14 +106,14 @@ DicomLoader::DicomLoader():m_addType(AddDicomType::DUPLICATE_TYPE) {
|
|||||||
// m_inputNames = InputNamesGeneratorType::New();
|
// m_inputNames = InputNamesGeneratorType::New();
|
||||||
|
|
||||||
DICOMHelper = new DICOMDirectoryHelper;
|
DICOMHelper = new DICOMDirectoryHelper;
|
||||||
reader = vtkDICOMImageReader2::New();
|
reader = nullptr;
|
||||||
//transfer to series after!
|
//transfer to series after!
|
||||||
m_patients.clear();
|
m_patients.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
DicomLoader::~DicomLoader() {
|
DicomLoader::~DicomLoader() {
|
||||||
delete DICOMHelper;
|
delete DICOMHelper;
|
||||||
reader->Delete();
|
if (reader)reader->Delete();
|
||||||
reader = nullptr;
|
reader = nullptr;
|
||||||
delete instance;
|
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.
|
//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)
|
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);
|
instance->m_fileNames.push_back(v);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
reader->Delete();
|
||||||
|
|
||||||
|
reader = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//You may not use const & cause intance may be deleted during this func
|
//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();
|
DICOMHelper->Update();
|
||||||
if(DICOMHelper->GetSeriesCount()>0){
|
if(DICOMHelper->GetSeriesCount()>0){
|
||||||
currentImageProperty = DICOMHelper->GetSeries(0);
|
currentImageProperty = DICOMHelper->GetSeries(0);
|
||||||
|
if (reader) reader->Delete();
|
||||||
|
reader = vtkDICOMImageReader2::New();
|
||||||
reader->SetFileNames(*(currentImageProperty->GetFileNames()));
|
reader->SetFileNames(*(currentImageProperty->GetFileNames()));
|
||||||
reader->Update();
|
reader->Update();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user