1 /*=========================================================================
4 Module: $RCSfile: gdcmSerieHelper.h,v $
6 Date: $Date: 2005/07/30 18:13:24 $
7 Version: $Revision: 1.16 $
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.
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.
17 =========================================================================*/
19 #ifndef GDCMSERIEHELPER_H
20 #define GDCMSERIEHELPER_H
22 #include "gdcmCommon.h"
23 #include "gdcmDebug.h" // for LEGACY
32 typedef std::vector<File* > FileList;
34 //-----------------------------------------------------------------------------
37 * - This class should be used for a stack of 2D dicom images.
38 * It allows to explore (recursively or not) a directory and
39 * makes a set of 'Coherent Files' list (coherent : same Serie UID)
40 * It allows to sort any of the Coherent File list on the image position
42 class GDCM_EXPORT SerieHelper
45 typedef std::map<std::string, FileList *> CoherentFileListmap;
46 typedef std::vector<File* > FileVector;
50 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
52 /// \todo should return bool or throw error ?
53 void AddFileName(std::string const &filename);
54 void AddGdcmFile(File *header);
56 void SetDirectory(std::string const &dir, bool recursive=false);
57 bool IsCoherent(FileList *coherentFileList);
58 void OrderFileList(FileList *coherentFileList);
60 /// \brief Gets the FIRST *coherent* File List.
61 /// Deprecated; kept not to break the API
62 /// \note Caller must call OrderFileList first
63 /// @return the (first) *coherent* File List
64 const FileList &GetFileList() { return *CoherentFileListHT.begin()->second; }
66 FileList *GetFirstCoherentFileList();
67 FileList *GetNextCoherentFileList();
68 FileList *GetCoherentFileList(std::string serieUID);
70 /// All the following allow user to restrict DICOM file to be part
71 /// of a particular serie
72 GDCM_LEGACY( void AddRestriction(TagKey const &key, std::string const &value) );
73 void AddRestriction(uint16_t group, uint16_t elem,
74 std::string const &value, int op);
77 * \brief Sets the LoadMode as a boolean string.
78 * NO_SEQ, NO_SHADOW, NO_SHADOWSEQ
79 ... (nothing more, right now)
80 * WARNING : before using NO_SHADOW, be sure *all* your files
81 * contain accurate values in the 0x0000 element (if any)
82 * of *each* Shadow Group. The parser will fail if the size is wrong !
83 * @param mode Load mode to be used
85 void SetLoadMode (int mode) { LoadMode = mode; }
87 /// Brief User wants the files to be sorted Direct Order (default value)
88 void SetSortOrderToDirect() { DirectOrder = true; }
90 /// Brief User wants the files to be sorted Reverse Order
91 void SetSortOrderToReverse() { DirectOrder = false; }
94 bool ImagePositionPatientOrdering(FileList *coherentFileList);
95 bool ImageNumberOrdering(FileList *coherentFileList);
96 bool FileNameOrdering(FileList *coherentFileList);
98 static bool ImageNumberLessThan(File *file1, File *file2);
99 static bool ImageNumberGreaterThan(File *file1, File *file2);
100 static bool FileNameLessThan(File *file1, File *file2);
101 static bool FileNameGreaterThan(File *file1, File *file2);
104 CoherentFileListmap CoherentFileListHT;
105 CoherentFileListmap::iterator ItListHt;
107 typedef std::pair<TagKey, std::string> Rule;
108 typedef std::vector<Rule> SerieRestrictions;
109 SerieRestrictions Restrictions;
111 // New style for (extented) Rules (Moreover old one doesn't compile)
118 typedef std::vector<ExRule> SerieExRestrictions;
119 SerieExRestrictions ExRestrictions;
121 /// \brief Bit string integer (each one considered as a boolean)
122 /// Bit 0 : Skip Sequences, if possible
123 /// Bit 1 : Skip Shadow Groups if possible
124 /// Probabely, some more to add
127 /// \brief whether we want to sort in direct order or not (reverse order).
128 /// To be used by aware user only
132 } // end namespace gdcm
134 //-----------------------------------------------------------------------------