1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
6 Date: $Date: 2005/07/08 19:07:12 $
7 Version: $Revision: 1.38 $
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"
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)
63 DicomDirObject::WriteContent(fp, t);
65 for(ListDicomDirSerie::iterator cc = Series.begin();
69 (*cc)->WriteContent( fp, t );
72 for(ListDicomDirVisit::iterator cc = Visits.begin();
76 (*cc)->WriteContent( fp, t );
81 * \brief adds a new Serie at the beginning of the SerieList
82 * of a partially created DICOMDIR
84 DicomDirSerie *DicomDirStudy::NewSerie()
86 DicomDirSerie *st = new DicomDirSerie();
92 * \brief adds a new Visit at the beginning of the VisitList
93 * of a partially created DICOMDIR
95 DicomDirVisit *DicomDirStudy::NewVisit()
97 DicomDirVisit *st = new DicomDirVisit();
103 * \brief Remove all series in the study
105 void DicomDirStudy::ClearSerie()
107 for(ListDicomDirSerie::iterator cc = Series.begin();
117 * \brief Remove all visits in the study
119 void DicomDirStudy::ClearVisit()
121 for(ListDicomDirVisit::iterator cc = Visits.begin();
131 * \brief Get the first entry while visiting the DicomDirSeries
132 * \return The first DicomDirSerie if found, otherwhise NULL
134 DicomDirSerie *DicomDirStudy::GetFirstSerie()
136 ItSerie = Series.begin();
137 if (ItSerie != Series.end())
143 * \brief Get the first entry while visiting the DicomDirVisit
144 * \return The first DicomDirVisit if found, otherwhise NULL
146 DicomDirVisit *DicomDirStudy::GetFirstVisit()
148 ItVisit = Visits.begin();
149 if (ItVisit != Visits.end())
155 * \brief Get the next entry while visiting the DicomDirSeries
156 * \note : meaningfull only if GetFirstEntry already called
157 * \return The next DicomDirSerie if found, otherwhise NULL
159 DicomDirSerie *DicomDirStudy::GetNextSerie()
161 gdcmAssertMacro (ItSerie != Series.end());
164 if (ItSerie != Series.end())
170 * \brief Get the next entry while visiting the DicomDirVisit
171 * \note : meaningfull only if GetFirstEntry already called
172 * \return The next DicomDirVisit if found, otherwhise NULL
174 DicomDirVisit *DicomDirStudy::GetNextVisit()
176 gdcmAssertMacro (ItVisit != Visits.end());
179 if (ItVisit != Visits.end())
185 * \brief Get the last entry while visiting the DicomDirSeries
186 * \return The last DicomDirSerie if found, otherwhise NULL
188 DicomDirSerie *DicomDirStudy::GetLastSerie()
190 ItSerie = Series.end();
191 if (ItSerie != Series.begin())
200 * \brief Get the last entry while visiting the DicomDirVisit
201 * \return The last DicomDirVisit if found, otherwhise NULL
203 DicomDirVisit *DicomDirStudy::GetLastVisit()
205 ItVisit = Visits.end();
206 if (ItVisit != Visits.begin())
214 //-----------------------------------------------------------------------------
217 //-----------------------------------------------------------------------------
220 //-----------------------------------------------------------------------------
223 * \brief Prints the Object
224 * @param os ostream to write to
225 * @param indent Indentation string to be prepended during printing
228 void DicomDirStudy::Print(std::ostream &os, std::string const & )
230 os << "STUDY" << std::endl;
231 DicomDirObject::Print(os);
233 for(ListDicomDirSerie::iterator cc = Series.begin();
237 (*cc)->SetPrintLevel(PrintLevel);
241 for(ListDicomDirVisit::iterator cc2 = Visits.begin();
245 (*cc2)->SetPrintLevel(PrintLevel);
251 //-----------------------------------------------------------------------------
252 } // end namespace gdcm