Changed the handling of erroneous dicom files so that the loading of a directory of dicom files is not abondonded when one or more erroneous files are encountered.
This commit is contained in:
@@ -576,13 +576,21 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
|
||||
|
||||
unsigned int totalNumSlices = 0;
|
||||
|
||||
typedef std::map<std::string, ReadResult> ErrorMap;
|
||||
ErrorMap errorMap;
|
||||
|
||||
for(Files::iterator itr = files.begin();
|
||||
itr != files.end();
|
||||
++itr)
|
||||
{
|
||||
DcmFileFormat fileformat;
|
||||
OFCondition status = fileformat.loadFile((*itr).c_str());
|
||||
if(!status.good()) return ReadResult::ERROR_IN_READING_FILE;
|
||||
const std::string& dicom_filename = *itr;
|
||||
OFCondition status = fileformat.loadFile(dicom_filename.c_str());
|
||||
if(!status.good())
|
||||
{
|
||||
errorMap[dicom_filename] = ReadResult::ERROR_IN_READING_FILE;
|
||||
continue;
|
||||
}
|
||||
|
||||
FileInfo fileInfo;
|
||||
fileInfo.filename = *itr;
|
||||
@@ -903,6 +911,16 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
|
||||
}
|
||||
}
|
||||
|
||||
if (!errorMap.empty())
|
||||
{
|
||||
for(ErrorMap::iterator itr = errorMap.begin();
|
||||
itr != errorMap.end();
|
||||
++itr)
|
||||
{
|
||||
warning()<<"Error in reading file "<<itr->first<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (!image)
|
||||
{
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
|
||||
Reference in New Issue
Block a user