00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GDCMDICOMDIR_H
00020 #define GDCMDICOMDIR_H
00021
00022 #include "gdcmDocument.h"
00023 #include "gdcmDebug.h"
00024
00025 #include <list>
00026 #include <vector>
00027
00028 namespace gdcm
00029 {
00030
00031 class DicomDirPatient;
00032 class DicomDirMeta;
00033 class DicomDirElement;
00034 class DicomDirStudy;
00035 class DicomDirSerie;
00036 class DicomDirVisit;
00037 class DicomDirImage;
00038 class SQItem;
00039
00040 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
00041 typedef std::vector<Document *> VectDocument;
00042
00043
00051 class GDCM_EXPORT DicomDir: public Document
00052 {
00053 gdcmTypeMacro(DicomDir);
00054
00055 public:
00057 static DicomDir *New() {return new DicomDir();}
00058
00059 bool Load( );
00060 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
00061
00063 void SetDirectoryName(std::string const &dirName)
00064 { ParseDir = true; if (Filename != dirName)
00065 Filename = dirName, IsDocumentModified = true; }
00067 virtual void SetFileName(std::string const &fileName)
00068 { ParseDir = false; if (Filename != fileName)
00069 Filename = fileName, IsDocumentModified = true;}
00070
00071
00072 virtual bool IsReadable();
00073
00074
00075 DicomDirMeta *NewMeta();
00077 DicomDirMeta *GetMeta() { return MetaElems; }
00078
00079
00080 DicomDirPatient *NewPatient();
00081 void ClearPatient();
00082
00083 DicomDirPatient *GetFirstPatient();
00084 DicomDirPatient *GetNextPatient();
00085
00086
00087 void ParseDirectory();
00088
00090 float GetProgress() const { return Progress; }
00092 void AbortProgress() { Abort = true; }
00094 bool IsAborted() { return Abort; }
00095
00096
00097 bool Write(std::string const &fileName);
00098
00099 bool Anonymize();
00100
00101 virtual void Copy(DocEntrySet *set);
00102
00104 typedef enum
00105 {
00106 GDCM_DICOMDIR_NONE,
00107 GDCM_DICOMDIR_META,
00108 GDCM_DICOMDIR_PATIENT,
00109 GDCM_DICOMDIR_STUDY,
00110 GDCM_DICOMDIR_SERIE,
00111 GDCM_DICOMDIR_VISIT,
00112 GDCM_DICOMDIR_IMAGE
00113 } DicomDirType;
00114
00115 protected:
00116 DicomDir();
00117 ~DicomDir();
00118
00119 void CreateDicomDirChainedList(std::string const &path);
00120
00121 private:
00122 void Initialize();
00123 void CreateDicomDir();
00124 bool DoTheLoadingJob();
00125 bool AddPatientToEnd(DicomDirPatient *dd);
00126 bool AddStudyToEnd (DicomDirStudy *dd);
00127 bool AddSerieToEnd (DicomDirSerie *dd);
00128 bool AddVisitToEnd (DicomDirVisit *dd);
00129 bool AddImageToEnd (DicomDirImage *dd);
00130
00131 void SetElements(std::string const &path, VectDocument const &list);
00132 void SetElement (std::string const &path, DicomDirType type,
00133 Document *header);
00134 void MoveSQItem(DocEntrySet *dst, DocEntrySet *src);
00135
00136 static bool HeaderLessThan(Document *header1, Document *header2);
00137
00138
00139
00141 DicomDirMeta *MetaElems;
00142
00144 ListDicomDirPatient Patients;
00145 ListDicomDirPatient::iterator ItPatient;
00146
00148 bool ParseDir;
00149
00150 };
00151 }
00152
00153 #endif