]> Creatis software - gdcm.git/blob - Testing/TestSerieHelper.cxx
COMP: Fix compilation, previous checkin was not meant sorry...
[gdcm.git] / Testing / TestSerieHelper.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestSerieHelper.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/05/26 18:50:45 $
7   Version:   $Revision: 1.4 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 #include "gdcmSerieHelper.h"
19 #include "gdcmFile.h"
20 #include "gdcmDebug.h"
21 #include <iostream>
22
23 int TestSerieHelper(int argc, char *argv[])
24 {  
25    gdcm::SerieHelper *s;
26   
27    std::string dirName; 
28    if (argc > 1) 
29       dirName = argv[1];    
30    else 
31    {
32       dirName = GDCM_DATA_ROOT;
33    }
34
35    //if (argc > 2)
36    //   gdcm::Debug::DebugOn();
37
38    std::cout << "Dir Name :[" << dirName << "]" << std::endl;
39
40    s = new gdcm::SerieHelper();
41    s->SetDirectory(dirName, true); // true : recursive exploration 
42    std::cout << " -------------------------------------------Finish parsing :["
43              << dirName << "]" << std::endl;
44
45    s->Print();
46    std::cout << " -----------------------------------------Finish printing (1)"
47              << std::endl;
48
49    int nbFiles;
50    // For all the Coherent Files lists of the gdcm::Serie
51    gdcm::FileList *l = s->GetFirstCoherentFileList();
52    while (l)
53    { 
54       nbFiles = l->size() ;
55       if ( l->size() > 3 ) // Why not ? Just an example, for testing
56       {
57          std::cout << "Sort list : " << nbFiles << " long" << std::endl;
58          s->OrderFileList(l);  // sort the list
59       }
60       l = s->GetNextCoherentFileList();
61    } 
62    std::cout << " ----------------------------------------------Finish sorting"
63              << std::endl;
64    s->Print(); // Prints all the Coherent Files lists (sorted or not)
65    std::cout << " ---------------------------------------------Finish printing"
66              << std::endl;
67
68    delete s;
69
70    return 0;
71 }