]> Creatis software - gdcm.git/blobdiff - src/gdcmSerieHelper.cxx
* Remove #define and replace then by the call to the corresponding
[gdcm.git] / src / gdcmSerieHelper.cxx
index 19f82fe3e6588ab1784657cad76111030b296bd8..27f6b509bab8d88ba9f3021146f0dab7e6416395 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/30 18:13:24 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2005/08/30 14:15:34 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -29,6 +29,7 @@
 
 namespace gdcm 
 {
+//-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
@@ -37,6 +38,8 @@ namespace gdcm
  */
 SerieHelper::SerieHelper()
 {
+   UserLessThanFunction = 0;
+
    // For all the File lists that may already exist within the gdcm::Serie
    FileList *l = GetFirstCoherentFileList();
    while (l)
@@ -282,7 +285,13 @@ void SerieHelper::SetDirectory(std::string const &dir, bool recursive)
  */
 void SerieHelper::OrderFileList(FileList *coherentFileList)
 {
-   if ( ImagePositionPatientOrdering( coherentFileList ) )
+
+   if ( SerieHelper::UserLessThanFunction )
+   {
+      UserOrdering( coherentFileList );
+      return; 
+   }
+   else if ( ImagePositionPatientOrdering( coherentFileList ) )
    {
       return ;
    }
@@ -562,12 +571,12 @@ bool SerieHelper::ImageNumberOrdering(FileList *fileList)
 
 bool SerieHelper::FileNameLessThan(File *file1, File *file2)
 {
-  return file1->GetFileName() < file2->GetFileName();
+   return file1->GetFileName() < file2->GetFileName();
 }
 
 bool SerieHelper::FileNameGreaterThan(File *file1, File *file2)
 {
-  return file1->GetFileName() > file2->GetFileName();
+   return file1->GetFileName() > file2->GetFileName();
 }
 /**
  * \brief sorts the images, according to their File Name
@@ -584,6 +593,21 @@ bool SerieHelper::FileNameOrdering(FileList *fileList)
    return true;
 }
 
+/**
+ * \brief sorts the images, according to user supplied function
+ * @param fileList Coherent File list (same Serie UID) to sort
+ * @return false only if the header is bugged !
+ */
+bool SerieHelper::UserOrdering(FileList *fileList)
+{
+   std::sort(fileList->begin(), fileList->end(), SerieHelper::UserLessThanFunction);
+   if (!DirectOrder) 
+   {
+      std::reverse(fileList->begin(), fileList->end());
+   }
+   return true;
+}
+
 //-----------------------------------------------------------------------------
 // Print
 /**