1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirSerie.cxx,v $
6 Date: $Date: 2007/05/23 14:01:44 $
7 Version: $Revision: 1.42 $
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 "gdcmDicomDirSerie.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmDicomDirImage.h"
22 #include "gdcmDicomDirPrivate.h"
23 #include "gdcmGlobal.h"
24 #include "gdcmDebug.h"
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
32 * \note End user must use : DicomDirStudy::NewSerie()
34 DicomDirSerie::DicomDirSerie(bool empty):
39 ListDicomDirSerieElem const &elemList =
40 Global::GetDicomDirElements()->GetDicomDirSerieElements();
46 * \brief Canonical destructor.
48 DicomDirSerie::~DicomDirSerie()
51 ClearPrivate(); // For SIEMENS 'CSA non image'
54 //-----------------------------------------------------------------------------
57 * \brief Writes the Object
58 * @param fp ofstream to write to
59 * @param t Type of the File (explicit VR, implicitVR, ...)
61 void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
63 DicomDirObject::WriteContent(fp, t);
65 for(ListDicomDirImage::iterator cc = Images.begin();
69 (*cc)->WriteContent( fp, t );
71 for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
75 (*cc2)->WriteContent( fp, t );
80 * \brief adds a new Image (with the basic elements) to a partially created
83 DicomDirImage *DicomDirSerie::NewImage()
85 DicomDirImage *dd = DicomDirImage::New();
91 * \brief adds a new Private (with the basic elements) to a partially created
95 DicomDirPrivate *DicomDirSerie::NewPrivate()
97 DicomDirPrivate *dd = DicomDirPrivate::New();
98 Privates.push_back(dd);
103 * \brief Remove all 'Privates' in the serie
105 void DicomDirSerie::ClearPrivate()
107 for(ListDicomDirPrivate::iterator cc = Privates.begin();
118 * \brief Remove all 'Images' in the serie
120 void DicomDirSerie::ClearImage()
122 for(ListDicomDirImage::iterator cc = Images.begin();
131 * \brief Get the first entry while visiting the DicomDirImage
132 * \return The first DicomDirImage if DicomDirserie not empty, otherwhise NULL
134 DicomDirImage *DicomDirSerie::GetFirstImage()
136 ItImage = Images.begin();
137 if (ItImage != Images.end())
143 * \brief Get the next entry while visiting the DicomDirImages
144 * \note : meaningfull only if GetFirstImage already called
145 * \return The next DicomDirImages if found, otherwhise NULL
147 DicomDirImage *DicomDirSerie::GetNextImage()
149 gdcmAssertMacro (ItImage != Images.end());
152 if (ItImage != Images.end())
158 * \brief Get the first entry while visiting the DicomDirPrivate
159 * \return The first DicomDirPrivate if DicomDirserie not empty, otherwhise NULL
161 DicomDirPrivate *DicomDirSerie::GetFirstPrivate()
163 ItPrivate = Privates.begin();
164 if (ItPrivate != Privates.end())
170 * \brief Get the next entry while visiting the DicomDirPrivates
171 * \note : meaningfull only if GetFirstPrivate already called
172 * \return The next DicomDirPrivates if found, otherwhise NULL
174 DicomDirPrivate *DicomDirSerie::GetNextPrivate()
176 gdcmAssertMacro (ItPrivate != Privates.end());
179 if (ItPrivate != Privates.end())
185 * \brief Copies all the attributes from an other DocEntrySet
186 * @param set entry to copy from
187 * @remarks The contained DocEntries a not copied, only referenced
189 void DicomDirSerie::Copy(DocEntrySet *set)
191 // Remove all previous childs
195 DicomDirObject::Copy(set);
197 DicomDirSerie *ddEntry = dynamic_cast<DicomDirSerie *>(set);
200 Images = ddEntry->Images;
201 for(ItImage = Images.begin();ItImage != Images.end();++ItImage)
202 (*ItImage)->Register();
204 Privates = ddEntry->Privates;
205 for(ItPrivate = Privates.begin();ItPrivate != Privates.end();++ItPrivate)
206 (*ItPrivate)->Register();
210 //-----------------------------------------------------------------------------
213 //-----------------------------------------------------------------------------
216 //-----------------------------------------------------------------------------
219 * \brief Prints the Object
220 * @param os ostream to write to
221 * @param indent Indentation string to be prepended during printing
223 void DicomDirSerie::Print(std::ostream &os, std::string const &)
225 os << "SERIE" << std::endl;
226 DicomDirObject::Print(os);
228 for(ListDicomDirImage::iterator cc = Images.begin();
232 (*cc)->SetPrintLevel(PrintLevel);
236 for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
237 cc2 != Privates.end();
240 (*cc2)->SetPrintLevel(PrintLevel);
246 //-----------------------------------------------------------------------------
247 } // end namespace gdcm