1 /*========================================================================= 2 3 Program: GDCM (Grassroots DICOM). A DICOM library 4 5 Copyright (c) 2006-2011 Mathieu Malaterre 6 All rights reserved. 7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 8 9 This software is distributed WITHOUT ANY WARRANTY; without even 10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 11 PURPOSE. See the above copyright notice for more information. 12 13 =========================================================================*/ 14 #ifndef GDCMSERIEHELPER_H 15 #define GDCMSERIEHELPER_H 16 17 #include "gdcmTag.h" 18 #include "gdcmSmartPointer.h" 19 #include "gdcmFile.h" 20 #include <vector> 21 #include <string> 22 #include <map> 23 24 namespace gdcm 25 { 26 27 enum CompOperators { 28 GDCM_EQUAL = 0, 29 GDCM_DIFFERENT, 30 GDCM_GREATER, 31 GDCM_GREATEROREQUAL, 32 GDCM_LESS, 33 GDCM_LESSOREQUAL 34 }; 35 enum LodModeType 36 { 37 LD_ALL = 0x00000000, 38 LD_NOSEQ = 0x00000001, 39 LD_NOSHADOW = 0x00000002, 40 LD_NOSHADOWSEQ = 0x00000004 41 }; 42 43 44 /** 45 * \brief FileWithName 46 * 47 * \details 48 * Backward only class do not use in newer code 49 */ 50 class GDCM_EXPORT FileWithName : public File 51 { 52 public: FileWithName(File & f)53 FileWithName(File &f):File(f),filename(){} 54 std::string filename; 55 }; 56 57 typedef std::vector< SmartPointer<FileWithName> > FileList; 58 typedef bool (*BOOL_FUNCTION_PFILE_PFILE_POINTER)(File *, File *); 59 class Scanner; 60 61 /** 62 * \brief SerieHelper 63 * DO NOT USE this class, it is only a temporary solution for ITK migration from GDCM 1.x to GDCM 2.x 64 * It will disappear soon, you've been warned. 65 * 66 * Instead see ImageHelper or IPPSorter 67 */ 68 class GDCM_EXPORT SerieHelper 69 { 70 public: 71 SerieHelper(); 72 ~SerieHelper(); 73 74 void Clear(); SetLoadMode(int)75 void SetLoadMode (int ) {} 76 void SetDirectory(std::string const &dir, bool recursive=false); 77 78 void AddRestriction(const std::string & tag); 79 void SetUseSeriesDetails( bool useSeriesDetails ); 80 void CreateDefaultUniqueSeriesIdentifier(); 81 FileList *GetFirstSingleSerieUIDFileSet(); 82 FileList *GetNextSingleSerieUIDFileSet(); 83 std::string CreateUniqueSeriesIdentifier( File * inFile ); 84 void OrderFileList(FileList *fileSet); 85 void AddRestriction(uint16_t group, uint16_t elem, std::string const &value, int op); 86 87 protected: 88 bool UserOrdering(FileList *fileSet); 89 void AddFileName(std::string const &filename); 90 bool AddFile(FileWithName &header); 91 void AddRestriction(const Tag& tag); 92 bool ImagePositionPatientOrdering(FileList *fileSet); 93 bool ImageNumberOrdering( FileList *fileList ); 94 bool FileNameOrdering( FileList *fileList ); 95 96 using Rule = struct RuleStructure{ 97 uint16_t group; 98 uint16_t elem; 99 std::string value; 100 int op; 101 }; 102 typedef std::vector<Rule> SerieRestrictions; 103 104 typedef std::map<std::string, FileList *> SingleSerieUIDFileSetmap; 105 SingleSerieUIDFileSetmap SingleSerieUIDFileSetHT; 106 SingleSerieUIDFileSetmap::iterator ItFileSetHt; 107 108 private: 109 SerieRestrictions Restrictions; 110 SerieRestrictions Refine; 111 112 bool UseSeriesDetails; 113 bool DirectOrder; 114 115 BOOL_FUNCTION_PFILE_PFILE_POINTER UserLessThanFunction; 116 }; 117 118 // backward compat 119 } // end namespace gdcm 120 121 122 #endif //GDCMSERIEHELPER_H 123