Program: gdcm
Module: $RCSfile: gdcmSerieHelper.cxx,v $
Language: C++
- Date: $Date: 2005/07/21 06:39:24 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2005/07/29 15:07:16 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
delete l;;
l = GetNextCoherentFileList();
}
+ DirectOrder = true;
}
/**
// Even if a rule was unmatch we don't deallocate the gdcm::File:
}
-
/**
* \brief add a rules for restricting a DICOM file to be in the serie we are
* trying to find. For example you can select only the DICOM file from a
}
fileList->clear(); // doesn't delete list elements, only nodes
-
- //VC++ don't understand what scope is !! it -> it3
- for (FileVector::const_iterator it3 = CoherentFileVector.begin();
- it3 != CoherentFileVector.end(); ++it3)
- {
- fileList->push_back( *it3 );
+
+ if (DirectOrder)
+ {
+ //VC++ don't understand what scope is !! it -> it3
+ for (FileVector::const_iterator it3 = CoherentFileVector.begin();
+ it3 != CoherentFileVector.end(); ++it3)
+ {
+ fileList->push_back( *it3 );
+ }
}
+ else // user asked for reverse order
+ {
+ FileVector::const_iterator it4;
+ it4 = CoherentFileVector.end();
+ do
+ {
+ it4--;
+ fileList->push_back( *it4 );
+ } while (it4 != CoherentFileVector.begin() );
+ }
distlist.clear();
CoherentFileVector.clear();
return file1->GetImageNumber() < file2->GetImageNumber();
}
+bool SerieHelper::ImageNumberGreaterThan(File *file1, File *file2)
+{
+ return file1->GetImageNumber() > file2->GetImageNumber();
+}
/**
* \brief sorts the images, according to their Image Number
* \note Works only on bona fide files (i.e image number is a character string
gdcmWarningMacro( " 'Image numbers' not coherent. No ImageNumberOrdering sort performed.");
return false;
}
- std::sort(fileList->begin(), fileList->end(), SerieHelper::ImageNumberLessThan );
+ if (DirectOrder)
+ std::sort(fileList->begin(), fileList->end(), SerieHelper::ImageNumberLessThan );
+ else
+ std::sort(fileList->begin(), fileList->end(), SerieHelper::ImageNumberGreaterThan );
return true;
}
return file1->GetFileName() < file2->GetFileName();
}
+bool SerieHelper::FileNameGreaterThan(File *file1, File *file2)
+{
+ return file1->GetFileName() > file2->GetFileName();
+}
/**
* \brief sorts the images, according to their File Name
* @param fileList Coherent File list (same Serie UID) to sort
*/
bool SerieHelper::FileNameOrdering(FileList *fileList)
{
- std::sort(fileList->begin(), fileList->end(), SerieHelper::FileNameLessThan);
+ if (DirectOrder)
+ std::sort(fileList->begin(), fileList->end(), SerieHelper::FileNameLessThan);
+ else
+ std::sort(fileList->begin(), fileList->end(), SerieHelper::FileNameGreaterThan);
+
return true;
}
Program: gdcm
Module: $RCSfile: gdcmSerieHelper.h,v $
Language: C++
- Date: $Date: 2005/07/21 05:00:30 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2005/07/29 15:07:16 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
void SetLoadMode (int mode) { LoadMode = mode; }
+/// Brief User wants the files to be sorted Direct Order (default value)
+ void SetSortOrderToDirect() { DirectOrder = true; }
+
+/// Brief User wants the files to be sorted Reverse Order
+ void SetSortOrderToReverse() { DirectOrder = false; }
+
private:
bool ImagePositionPatientOrdering(FileList *coherentFileList);
bool ImageNumberOrdering(FileList *coherentFileList);
bool FileNameOrdering(FileList *coherentFileList);
static bool ImageNumberLessThan(File *file1, File *file2);
+ static bool ImageNumberGreaterThan(File *file1, File *file2);
static bool FileNameLessThan(File *file1, File *file2);
+ static bool FileNameGreaterThan(File *file1, File *file2);
//Attributes:
CoherentFileListmap CoherentFileListHT;
/// Bit 1 : Skip Shadow Groups if possible
/// Probabely, some more to add
int LoadMode;
+
+ /// \brief whether we want to sort in direct order or not (reverse order).
+ /// To be used by aware user only
+ bool DirectOrder;
};
} // end namespace gdcm