]> Creatis software - gdcm.git/blob - src/gdcmSerieHelper.h
BUG: Fix for picky compiler
[gdcm.git] / src / gdcmSerieHelper.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmSerieHelper.h,v $
5   Language:  C++
6   Date:      $Date: 2005/02/02 16:58:04 $
7   Version:   $Revision: 1.3 $
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 <list>
25 #include <vector>
26 #include <map>
27
28 namespace gdcm 
29 {
30 class File;
31 typedef std::list<File* > GdcmFileList;
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, GdcmFileList *> CoherentFileListmap;
45    typedef std::vector<File* > GdcmFileVector;
46
47    SerieHelper();
48    ~SerieHelper();
49    void Print();
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 OrderGdcmFileList(GdcmFileList *CoherentGdcmFileList);
55    
56    /// \brief Gets the FIRST *coherent* File List.
57    ///        Deprecated; kept not to break the API
58    /// \note Caller must call OrderGdcmFileList first
59    /// @return the (first) *coherent* File List
60    const GdcmFileList &GetGdcmFileList() { return
61                        *CoherentGdcmFileListHT.begin()->second; }
62   
63    GdcmFileList *GetFirstCoherentFileList();
64    GdcmFileList *GetNextCoherentFileList();
65    GdcmFileList *GetCoherentFileList(std::string SerieUID);
66
67 private:
68    bool ImagePositionPatientOrdering(GdcmFileList *CoherentGdcmFileList);
69    bool ImageNumberOrdering(GdcmFileList *CoherentGdcmFileList);
70    bool FileNameOrdering(GdcmFileList *CoherentGdcmFileList);
71    
72    CoherentFileListmap CoherentGdcmFileListHT;
73    CoherentFileListmap::iterator ItListHt;
74 };
75
76 } // end namespace gdcm
77
78 //-----------------------------------------------------------------------------
79 #endif