1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
6 Date: $Date: 2007/10/08 15:20:17 $
7 Version: $Revision: 1.46 $
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 #include "gdcmDicomDirStudy.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmGlobal.h"
22 #include "gdcmDicomDirSerie.h"
23 #include "gdcmDicomDirVisit.h"
24 #include "gdcmDebug.h"
26 namespace GDCM_NAME_SPACE
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
32 * \note End user must use : DicomDirPatient::NewStudy()
34 DicomDirStudy::DicomDirStudy(bool empty)
39 ListDicomDirStudyElem const &elemList =
40 Global::GetDicomDirElements()->GetDicomDirStudyElements();
46 * \brief Canonical destructor.
48 DicomDirStudy::~DicomDirStudy()
53 //-----------------------------------------------------------------------------
56 * \brief Writes the Object
57 * @param fp ofstream to write to
58 * @param t Type of the File (explicit VR, implicitVR, ...)
61 void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t, bool , bool )
63 DicomDirObject::WriteContent(fp, t, false, true);
65 for(ListDicomDirSerie::iterator cc = Series.begin();
69 (*cc)->WriteContent( fp, t, false, true );
72 for(ListDicomDirVisit::iterator icc = Visits.begin();
76 (*icc)->WriteContent( fp, t, false, true );
81 * \brief adds a new Serie at the beginning of the SerieList
82 * of a partially created DICOMDIR
84 DicomDirSerie *DicomDirStudy::NewSerie()
86 DicomDirSerie *dd = DicomDirSerie::New();
92 * \brief Remove all series in the study
94 void DicomDirStudy::ClearSerie()
96 for(ListDicomDirSerie::iterator cc = Series.begin();
106 * \brief Get the first entry while visiting the DicomDirSeries
107 * \return The first DicomDirSerie if found, otherwhise NULL
109 DicomDirSerie *DicomDirStudy::GetFirstSerie()
111 ItSerie = Series.begin();
112 if (ItSerie != Series.end())
118 * \brief Get the next entry while visiting the DicomDirSeries
119 * \note : meaningfull only if GetFirstEntry already called
120 * \return The next DicomDirSerie if found, otherwhise NULL
122 DicomDirSerie *DicomDirStudy::GetNextSerie()
124 gdcmAssertMacro (ItSerie != Series.end());
127 if (ItSerie != Series.end())
133 * \brief Get the last entry while visiting the DicomDirSeries
134 * \return The last DicomDirSerie if found, otherwhise NULL
136 DicomDirSerie *DicomDirStudy::GetLastSerie()
138 ItSerie = Series.end();
139 if (ItSerie != Series.begin())
149 * \brief adds a new Visit at the beginning of the VisitList
150 * of a partially created DICOMDIR
152 DicomDirVisit *DicomDirStudy::NewVisit()
154 DicomDirVisit *dd = DicomDirVisit::New();
155 Visits.push_back(dd);
161 * \brief Remove all visits in the study
163 void DicomDirStudy::ClearVisit()
165 for(ListDicomDirVisit::iterator cc = Visits.begin();
175 * \brief Get the first entry while visiting the DicomDirVisit
176 * \return The first DicomDirVisit if found, otherwhise NULL
178 DicomDirVisit *DicomDirStudy::GetFirstVisit()
180 ItVisit = Visits.begin();
181 if (ItVisit != Visits.end())
187 * \brief Get the next entry while visiting the DicomDirVisit
188 * \note : meaningfull only if GetFirstEntry already called
189 * \return The next DicomDirVisit if found, otherwhise NULL
191 DicomDirVisit *DicomDirStudy::GetNextVisit()
193 gdcmAssertMacro (ItVisit != Visits.end());
196 if (ItVisit != Visits.end())
202 * \brief Get the last entry while visiting the DicomDirVisit
203 * \return The last DicomDirVisit if found, otherwhise NULL
205 DicomDirVisit *DicomDirStudy::GetLastVisit()
207 ItVisit = Visits.end();
208 if (ItVisit != Visits.begin())
217 * \brief Copies all the attributes from an other DocEntrySet
218 * @param set entry to copy from
219 * @remarks The contained DocEntries a not copied, only referenced
221 void DicomDirStudy::Copy(DocEntrySet *set)
223 // Remove all previous childs
227 DicomDirObject::Copy(set);
229 DicomDirStudy *ddEntry = dynamic_cast<DicomDirStudy *>(set);
232 Series = ddEntry->Series;
233 for(ItSerie = Series.begin();ItSerie != Series.end();++ItSerie)
234 (*ItSerie)->Register();
236 Visits = ddEntry->Visits;
237 for(ItVisit = Visits.begin();ItVisit != Visits.end();++ItVisit)
238 (*ItVisit)->Register();
242 //-----------------------------------------------------------------------------
245 //-----------------------------------------------------------------------------
248 //-----------------------------------------------------------------------------
251 * \brief Prints the Object
252 * @param os ostream to write to
253 * @param indent Indentation string to be prepended during printing
256 void DicomDirStudy::Print(std::ostream &os, std::string const & )
258 os << "STUDY" << std::endl;
259 DicomDirObject::Print(os);
261 for(ListDicomDirSerie::iterator cc = Series.begin();
265 (*cc)->SetPrintLevel(PrintLevel);
269 for(ListDicomDirVisit::iterator cc2 = Visits.begin();
273 (*cc2)->SetPrintLevel(PrintLevel);
279 //-----------------------------------------------------------------------------
280 } // end namespace gdcm