2 //-----------------------------------------------------------------------------
3 #include "gdcmDicomDir.h"
11 //-----------------------------------------------------------------------------
12 // Constructor / Destructor
15 * \ingroup gdcmDicomDir
18 * @param exception_on_error
20 gdcmDicomDir::gdcmDicomDir(std::string & FileName,
21 bool exception_on_error):
22 gdcmParser(FileName.c_str(),exception_on_error, true )
24 if ( GetListEntry().begin() == GetListEntry().end() )
26 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir entry list empty");
34 * \ingroup gdcmDicomDir
36 * @param exception_on_error
38 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
39 gdcmParser(exception_on_error )
46 gdcmDicomDir::~gdcmDicomDir()
48 for(ListPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
54 //-----------------------------------------------------------------------------
56 void gdcmDicomDir::Print(std::ostream &os)
58 for(ListPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
60 (*cc)->SetPrintLevel(printLevel);
65 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
71 //-----------------------------------------------------------------------------
73 void gdcmDicomDir::CreateDicomDir(void)
75 // The list is parsed. When a tag is found :
76 // 1 - we save the beginning iterator
77 // 2 - we continue to parse
78 // 3 - we find an other tag
79 // + we create the object for the precedent tag
82 gdcmDicomDirType type=gdcmDicomDir::GDCM_NONE;
83 ListTag::iterator begin;
84 ListTag::iterator end;
86 begin=GetListEntry().begin();
88 for(ListTag::iterator i=GetListEntry().begin();i != GetListEntry().end();++i)
90 // std::cout << std::hex << (*i)->GetGroup() <<
91 // " " << (*i)->GetElement() << endl;
93 std::string v = (*i)->GetValue();
96 // std::cout<<"PATIENT"<<std::endl;
98 AddObjectToEnd(type,begin,end);
100 type=gdcmDicomDir::GDCM_PATIENT;
106 // std::cout<<"STUDY"<<std::endl;
108 AddObjectToEnd(type,begin,end);
110 type=gdcmDicomDir::GDCM_STUDY;
116 // std::cout<<"SERIES"<<std::endl;
118 AddObjectToEnd(type,begin,end);
120 type=gdcmDicomDir::GDCM_SERIE;
126 // std::cout<<"IMAGE"<<std::endl;
128 AddObjectToEnd(type,begin,end);
130 type=gdcmDicomDir::GDCM_IMAGE;
135 end=GetListEntry().end();
136 AddObjectToEnd(type,begin,end);
139 void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end)
146 case gdcmDicomDir::GDCM_PATIENT:
147 AddPatientToEnd(begin,end);
149 case gdcmDicomDir::GDCM_STUDY:
150 AddStudyToEnd(begin,end);
152 case gdcmDicomDir::GDCM_SERIE:
153 AddSerieToEnd(begin,end);
155 case gdcmDicomDir::GDCM_IMAGE:
156 AddImageToEnd(begin,end);
161 void gdcmDicomDir::AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
163 patients.push_back(new gdcmPatient(begin,end));
166 void gdcmDicomDir::AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
168 if(patients.size()>0)
170 ListPatient::iterator itp=patients.end();
172 (*itp)->AddStudy(new gdcmStudy(begin,end));
176 void gdcmDicomDir::AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
178 if(patients.size()>0)
180 ListPatient::iterator itp=patients.end();
183 if((*itp)->GetStudies().size()>0)
185 ListStudy::iterator itst=(*itp)->GetStudies().end();
187 (*itst)->AddSerie(new gdcmSerie(begin,end));
192 void gdcmDicomDir::AddImageToEnd(ListTag::iterator begin,ListTag::iterator end)
194 if(patients.size()>0)
196 ListPatient::iterator itp=patients.end();
199 if((*itp)->GetStudies().size()>0)
201 ListStudy::iterator itst=(*itp)->GetStudies().end();
204 if((*itst)->GetSeries().size()>0)
206 ListSerie::iterator its=(*itst)->GetSeries().end();
208 (*its)->AddImage(new gdcmImage(begin,end));
214 //-----------------------------------------------------------------------------