1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
6 Date: $Date: 2005/07/11 08:20:25 $
7 Version: $Revision: 1.40 $
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 icc = Visits.begin();
76 (*icc)->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 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 *st = new DicomDirVisit();
155 Visits.push_back(st);
160 * \brief Remove all visits in the study
162 void DicomDirStudy::ClearVisit()
164 for(ListDicomDirVisit::iterator cc = Visits.begin();
174 * \brief Get the first entry while visiting the DicomDirVisit
175 * \return The first DicomDirVisit if found, otherwhise NULL
177 DicomDirVisit *DicomDirStudy::GetFirstVisit()
179 ItVisit = Visits.begin();
180 if (ItVisit != Visits.end())
186 * \brief Get the next entry while visiting the DicomDirVisit
187 * \note : meaningfull only if GetFirstEntry already called
188 * \return The next DicomDirVisit if found, otherwhise NULL
190 DicomDirVisit *DicomDirStudy::GetNextVisit()
192 gdcmAssertMacro (ItVisit != Visits.end());
195 if (ItVisit != Visits.end())
201 * \brief Get the last entry while visiting the DicomDirVisit
202 * \return The last DicomDirVisit if found, otherwhise NULL
204 DicomDirVisit *DicomDirStudy::GetLastVisit()
206 ItVisit = Visits.end();
207 if (ItVisit != Visits.begin())
215 //-----------------------------------------------------------------------------
218 //-----------------------------------------------------------------------------
221 //-----------------------------------------------------------------------------
224 * \brief Prints the Object
225 * @param os ostream to write to
226 * @param indent Indentation string to be prepended during printing
229 void DicomDirStudy::Print(std::ostream &os, std::string const & )
231 os << "STUDY" << std::endl;
232 DicomDirObject::Print(os);
234 for(ListDicomDirSerie::iterator cc = Series.begin();
238 (*cc)->SetPrintLevel(PrintLevel);
242 for(ListDicomDirVisit::iterator cc2 = Visits.begin();
246 (*cc2)->SetPrintLevel(PrintLevel);
252 //-----------------------------------------------------------------------------
253 } // end namespace gdcm