Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gdcmSerieHelper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmSerieHelper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006/01/18 15:25:07 $
00007   Version:   $Revision: 1.36 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018 
00019 #ifndef GDCMSERIEHELPER_H
00020 #define GDCMSERIEHELPER_H
00021 
00022 #include "gdcmRefCounter.h"
00023 #include "gdcmTagKey.h" 
00024 #include "gdcmDebug.h"  // for LEGACY
00025  
00026 #include <vector>
00027 #include <iostream>
00028 #include <map>
00029 
00030 namespace gdcm 
00031 {
00032 class File;
00033 
00034    typedef std::vector<File* > FileList;
00035    
00040    typedef std::map<std::string, FileList *> XCoherentFileSetmap; 
00041       
00042    typedef bool (*BOOL_FUNCTION_PFILE_PFILE_POINTER)(File *, File *);
00043 
00044 //-----------------------------------------------------------------------------
00058 class GDCM_EXPORT SerieHelper  : public RefCounter
00059 {
00060    gdcmTypeMacro(SerieHelper);
00061    
00062 public:
00066    typedef std::map<std::string, FileList *> SingleSerieUIDFileSetmap;
00067 
00068    typedef std::vector<File* > FileVector;
00069 
00071     static SerieHelper *New() {return new SerieHelper();}
00072      
00073    virtual ~SerieHelper();
00074    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
00075 
00077    void AddFileName(std::string const &filename);
00078    void AddGdcmFile(File *header);
00079 
00080    void SetDirectory(std::string const &dir, bool recursive=false);
00081    bool IsCoherent(FileList *fileSet);
00082    void OrderFileList(FileList *fileSet);
00083    
00088    const FileList &GetFileList()
00089                            { return *SingleSerieUIDFileSetHT.begin()->second; }
00090   
00091    GDCM_LEGACY(   FileList *GetFirstCoherentFileList()  );
00092    GDCM_LEGACY(   FileList *GetNextCoherentFileList()   );
00093    GDCM_LEGACY(   FileList *GetCoherentFileList(std::string serieUID)  );
00094 
00095    FileList *GetFirstSingleSerieUIDFileSet();
00096    FileList *GetNextSingleSerieUIDFileSet();
00097    FileList *GetSingleSerieUIDFileSet(std::string serieUID);
00099    std::string GetCurrentSerieUIDFileSetUID()
00100                              { return  (*ItFileSetHt).first; }
00106    void AddRestriction(TagKey const &key, std::string const &value, int op);
00107    void AddRestriction(uint16_t group, uint16_t elem, std::string const &value,
00108                                                                     int op);
00109 
00113    void SetUseSeriesDetails( bool useSeriesDetails )
00114                                    { m_UseSeriesDetails = useSeriesDetails;}
00115    bool GetUseSeriesDetails( ){ return m_UseSeriesDetails; }
00116    
00117    void AddSeriesDetail(uint16_t group, uint16_t elem, bool convert);
00118    
00119    std::string CreateUniqueSeriesIdentifier( File * inFile );
00120    
00121    std::string CreateUserDefinedFileIdentifier( File * inFile );
00122  
00132    void SetLoadMode (int mode) { LoadMode = mode; }
00133 
00135    void SetSortOrderToDirect()  { DirectOrder = true;  }
00136 
00138    void SetSortOrderToReverse() { DirectOrder = false; }
00139 
00141    void SetUserLessThanFunction( BOOL_FUNCTION_PFILE_PFILE_POINTER userFunc ) 
00142                         { UserLessThanFunction = userFunc; }  
00143 
00144    XCoherentFileSetmap SplitOnOrientation(FileList *fileSet); 
00145    XCoherentFileSetmap SplitOnPosition(FileList *fileSet); 
00146    XCoherentFileSetmap SplitOnTagValue(FileList *fileSet,
00147                                                uint16_t group, uint16_t elem);
00148 protected :
00149    SerieHelper();
00150    
00151 private:
00152    void ClearAll();
00153    bool UserOrdering(FileList *fileSet);
00154    bool ImagePositionPatientOrdering(FileList *fileSet);
00155    bool ImageNumberOrdering(FileList *fileSet);
00156    bool FileNameOrdering(FileList *fileSet);
00157    
00158    static bool ImageNumberLessThan(File *file1, File *file2);
00159    static bool ImageNumberGreaterThan(File *file1, File *file2);
00160    static bool FileNameLessThan(File *file1, File *file2);
00161    static bool FileNameGreaterThan(File *file1, File *file2);
00162 
00163 //Attributes:
00164    
00165    SingleSerieUIDFileSetmap SingleSerieUIDFileSetHT;
00166    SingleSerieUIDFileSetmap::iterator ItFileSetHt;
00167    
00168    typedef std::pair<TagKey, std::string> Rule;
00169    typedef std::vector<Rule> SerieRestrictions;
00170    SerieRestrictions Restrictions;
00171    
00172    // New style for (extented) Rules
00173    typedef struct {
00174       uint16_t group;
00175       uint16_t elem;
00176       std::string value;
00177       int op;
00178    } ExRule;
00179    typedef std::vector<ExRule> SerieExRestrictions;
00180    SerieExRestrictions ExRestrictions;
00181    
00182    typedef struct {
00183       uint16_t group;
00184       uint16_t elem;
00185       bool convert;
00186    } ExDetail;
00187    typedef std::vector<ExDetail> SeriesExDetails; 
00188    SeriesExDetails ExDetails;
00189     
00190    bool m_UseSeriesDetails;
00191    
00196    int LoadMode;
00197 
00200    bool DirectOrder;
00201 
00204     BOOL_FUNCTION_PFILE_PFILE_POINTER UserLessThanFunction;
00205 
00206     void Sort(FileList *fileList, bool (*pt2Func)( File *file1, File *file2) );
00207 };
00208 
00209 } // end namespace gdcm
00210 
00211 //-----------------------------------------------------------------------------
00212 #endif

Generated on Fri Jan 20 10:14:26 2006 for gdcm by  doxygen 1.4.4