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