]> Creatis software - gdcm.git/blob - src/gdcmSerieHelper.h
BUG: Fix problem with typedef. When you use a typedef within a namespace + class...
[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:16:07 $
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
19 #ifndef GDCMSERIEHELPER_H
20 #define GDCMSERIEHELPER_H
21
22 #include "gdcmCommon.h" 
23
24 #include <list>
25 #include <map>
26
27 namespace gdcm 
28 {
29 class File;
30 typedef std::list<File* > GdcmFileList;
31
32 //-----------------------------------------------------------------------------
33 /**
34  * \brief  
35  * - This class should be used for a stack of 2D dicom images.
36  *   It allows to explore (recursively or not) a directory and 
37  *   makes a set of 'Coherent Files' list (coherent : same Serie UID)
38  *   It allows to sort any of the Coherent File list on the image postion
39  */
40 class GDCM_EXPORT SerieHelper 
41 {
42 public:
43    typedef std::map<std::string, GdcmFileList *> CoherentFileListmap;
44    typedef std::vector<File* > GdcmFileVector;
45
46    SerieHelper();
47    ~SerieHelper();
48    void Print();
49
50    /// \todo should return bool or throw error ?
51    void AddFileName(std::string const &filename);
52    void SetDirectory(std::string const &dir, bool recursive=false);
53    void OrderGdcmFileList(GdcmFileList *CoherentGdcmFileList);
54    
55    /// \brief Gets the FIRST *coherent* File List.
56    ///        Deprecated; kept not to break the API
57    /// \note Caller must call OrderGdcmFileList first
58    /// @return the (first) *coherent* File List
59    const GdcmFileList &GetGdcmFileList() { return
60                        *CoherentGdcmFileListHT.begin()->second; }
61   
62    GdcmFileList *GetFirstCoherentFileList();
63    GdcmFileList *GetNextCoherentFileList();
64    GdcmFileList *GetCoherentFileList(std::string SerieUID);
65
66 private:
67    bool ImagePositionPatientOrdering(GdcmFileList *CoherentGdcmFileList);
68    bool ImageNumberOrdering(GdcmFileList *CoherentGdcmFileList);
69    bool FileNameOrdering(GdcmFileList *CoherentGdcmFileList);
70    
71    CoherentFileListmap CoherentGdcmFileListHT;
72    CoherentFileListmap::iterator ItListHt;
73 };
74
75 } // end namespace gdcm
76
77 //-----------------------------------------------------------------------------
78 #endif