]> Creatis software - gdcm.git/blob - Testing/TestSerieHelper.cxx
Typo normalization
[gdcm.git] / Testing / TestSerieHelper.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestSerieHelper.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/03 10:00:06 $
7   Version:   $Revision: 1.2 $
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 typedef std::list<gdcm::File* > GdcmFileList;
24
25 int TestSerieHelper(int argc, char *argv[])
26 {  
27    gdcm::SerieHelper *s;
28   
29    std::string dirName; 
30    if (argc > 1) 
31       dirName = argv[1];    
32    else 
33    {
34       dirName = GDCM_DATA_ROOT;
35    }
36
37    //if (argc > 2)
38    //   gdcm::Debug::DebugOn();
39
40    std::cout << "Dir Name :[" << dirName << "]" << std::endl;
41
42    s = new gdcm::SerieHelper();
43    s->SetDirectory(dirName, true); // true : recursive exploration 
44    std::cout << " -------------------------------------------Finish parsing :["
45              << dirName << "]" << std::endl;
46
47    s->Print();
48    std::cout << " -----------------------------------------Finish printing (1)"
49              << std::endl;
50
51    int nbFiles;
52    // For all the Coherent Files lists of the gdcm::Serie
53    GdcmFileList *l = s->GetFirstCoherentFileList();
54    while (l)
55    { 
56       nbFiles = l->size() ;
57       if ( l->size() > 3 ) // Why not ? Just an example, for testing
58       {
59          std::cout << "Sort list : " << nbFiles << " long" << std::endl;
60          s->OrderGdcmFileList(l);  // sort the list
61       }
62       l = s->GetNextCoherentFileList();
63    } 
64    std::cout << " ----------------------------------------------Finish sorting"
65              << std::endl;
66    s->Print(); // Prints all the Coherent Files lists (sorted or not)
67    std::cout << " ---------------------------------------------Finish printing"
68              << std::endl;
69
70    delete s;
71
72    return 0;
73 }