]> Creatis software - gdcm.git/blobdiff - Testing/TestSerieHelper.cxx
Strange name gdcm::SerieHeader turned to gdcm::SerieHelper
[gdcm.git] / Testing / TestSerieHelper.cxx
diff --git a/Testing/TestSerieHelper.cxx b/Testing/TestSerieHelper.cxx
new file mode 100644 (file)
index 0000000..a36cfde
--- /dev/null
@@ -0,0 +1,73 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: TestSerieHelper.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/02/02 14:26:34 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+#include "gdcmSerieHelper.h"
+#include "gdcmFile.h"
+#include "gdcmDebug.h"
+#include <iostream>
+
+typedef std::list<gdcm::File* > GdcmFileList;
+
+int TestSerieHelper(int argc, char* argv[])
+{  
+   gdcm::SerieHelper *s;
+  
+   std::string dirName; 
+   if (argc > 1) 
+      dirName = argv[1];    
+   else 
+   {
+      dirName = GDCM_DATA_ROOT;
+   }
+
+   //if (argc > 2)
+   //   gdcm::Debug::SetDebugOn();
+
+   std::cout << "Dir Name :[" << dirName << "]" << std::endl;
+
+   s = new gdcm::SerieHelper();
+   s->SetDirectory(dirName, true); // true : recursive exploration 
+   std::cout << " -------------------------------------------Finish parsing :["
+             << dirName << "]" << std::endl;
+
+   s->Print();
+   std::cout << " -----------------------------------------Finish printing (1)"
+             << std::endl;
+
+   int nbFiles;
+   // For all the Coherent Files lists of the gdcm::Serie
+   GdcmFileList *l = s->GetFirstCoherentFileList();
+   while (l)
+   { 
+      nbFiles = l->size() ;
+      if ( l->size() > 3 ) // Why not ? Just an example, for testing
+      {
+         std::cout << "Sort list : " << nbFiles << " long" << std::endl;
+         s->OrderGdcmFileList(l);  // sort the list
+      }
+      l = s->GetNextCoherentFileList();
+   } 
+   std::cout << " ----------------------------------------------Finish sorting"
+             << std::endl;
+   s->Print(); // Prints all the Coherent Files lists (sorted or not)
+   std::cout << " ---------------------------------------------Finish printing"
+             << std::endl;
+
+   delete s;
+
+   return 0;
+}