]> Creatis software - gdcm.git/blob - src/gdcmSerieHelper.h
COMP: Fix compilation on MINGW32
[gdcm.git] / src / gdcmSerieHelper.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmSerieHelper.h,v $
5   Language:  C++
6   Date:      $Date: 2005/05/26 18:49:46 $
7   Version:   $Revision: 1.8 $
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
19 #ifndef GDCMSERIEHELPER_H
20 #define GDCMSERIEHELPER_H
21
22 #include "gdcmCommon.h" 
23
24 #include <vector>
25 #include <iostream>
26 #include <map>
27
28 namespace gdcm 
29 {
30 class File;
31 typedef std::vector<File* > FileList;
32
33 //-----------------------------------------------------------------------------
34 /**
35  * \brief  
36  * - This class should be used for a stack of 2D dicom images.
37  *   It allows to explore (recursively or not) a directory and 
38  *   makes a set of 'Coherent Files' list (coherent : same Serie UID)
39  *   It allows to sort any of the Coherent File list on the image postion
40  */
41 class GDCM_EXPORT SerieHelper 
42 {
43 public:
44    typedef std::map<std::string, FileList *> CoherentFileListmap;
45    typedef std::vector<File* > FileVector;
46
47    SerieHelper();
48    ~SerieHelper();
49    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
50
51    /// \todo should return bool or throw error ?
52    void AddFileName(std::string const &filename);
53    void SetDirectory(std::string const &dir, bool recursive=false);
54    void OrderFileList(FileList *coherentFileList);
55    
56    /// \brief Gets the FIRST *coherent* File List.
57    ///        Deprecated; kept not to break the API
58    /// \note Caller must call OrderFileList first
59    /// @return the (first) *coherent* File List
60    const FileList &GetFileList() { return *CoherentFileListHT.begin()->second; }
61   
62    FileList *GetFirstCoherentFileList();
63    FileList *GetNextCoherentFileList();
64    FileList *GetCoherentFileList(std::string serieUID);
65
66 private:
67    bool ImagePositionPatientOrdering(FileList *coherentFileList);
68    bool ImageNumberOrdering(FileList *coherentFileList);
69    bool FileNameOrdering(FileList *coherentFileList);
70    
71    static bool ImageNumberLessThan(File *file1, File *file2);
72    static bool FileNameLessThan(File *file1, File *file2);
73    CoherentFileListmap CoherentFileListHT;
74    CoherentFileListmap::iterator ItListHt;
75 };
76
77 } // end namespace gdcm
78
79 //-----------------------------------------------------------------------------
80 #endif