1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirSerie.cxx,v $
6 Date: $Date: 2007/03/23 15:30:15 $
7 Version: $Revision: 1.41 $
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 Remove all 'Images' in the serie
93 void DicomDirSerie::ClearPrivate()
95 for(ListDicomDirPrivate::iterator cc = Privates.begin();
106 * \brief Remove all 'Privates' in the serie
108 void DicomDirSerie::ClearImage()
110 for(ListDicomDirImage::iterator cc = Images.begin();
119 * \brief Get the first entry while visiting the DicomDirImage
120 * \return The first DicomDirImage if DicomDirserie not empty, otherwhise NULL
122 DicomDirImage *DicomDirSerie::GetFirstImage()
124 ItImage = Images.begin();
125 if (ItImage != Images.end())
131 * \brief Get the next entry while visiting the DicomDirImages
132 * \note : meaningfull only if GetFirstImage already called
133 * \return The next DicomDirImages if found, otherwhise NULL
135 DicomDirImage *DicomDirSerie::GetNextImage()
137 gdcmAssertMacro (ItImage != Images.end());
140 if (ItImage != Images.end())
146 * \brief Get the first entry while visiting the DicomDirPrivate
147 * \return The first DicomDirPrivate if DicomDirserie not empty, otherwhise NULL
149 DicomDirPrivate *DicomDirSerie::GetFirstPrivate()
151 ItPrivate = Privates.begin();
152 if (ItPrivate != Privates.end())
158 * \brief Get the next entry while visiting the DicomDirPrivates
159 * \note : meaningfull only if GetFirstPrivate already called
160 * \return The next DicomDirPrivates if found, otherwhise NULL
162 DicomDirPrivate *DicomDirSerie::GetNextPrivate()
164 gdcmAssertMacro (ItPrivate != Privates.end());
167 if (ItPrivate != Privates.end())
173 * \brief Copies all the attributes from an other DocEntrySet
174 * @param set entry to copy from
175 * @remarks The contained DocEntries a not copied, only referenced
177 void DicomDirSerie::Copy(DocEntrySet *set)
179 // Remove all previous childs
183 DicomDirObject::Copy(set);
185 DicomDirSerie *ddEntry = dynamic_cast<DicomDirSerie *>(set);
188 Images = ddEntry->Images;
189 for(ItImage = Images.begin();ItImage != Images.end();++ItImage)
190 (*ItImage)->Register();
192 Privates = ddEntry->Privates;
193 for(ItPrivate = Privates.begin();ItPrivate != Privates.end();++ItPrivate)
194 (*ItPrivate)->Register();
198 //-----------------------------------------------------------------------------
201 //-----------------------------------------------------------------------------
204 //-----------------------------------------------------------------------------
207 * \brief Prints the Object
208 * @param os ostream to write to
209 * @param indent Indentation string to be prepended during printing
211 void DicomDirSerie::Print(std::ostream &os, std::string const &)
213 os << "SERIE" << std::endl;
214 DicomDirObject::Print(os);
216 for(ListDicomDirImage::iterator cc = Images.begin();
220 (*cc)->SetPrintLevel(PrintLevel);
224 for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
225 cc2 != Privates.end();
228 (*cc2)->SetPrintLevel(PrintLevel);
234 //-----------------------------------------------------------------------------
235 } // end namespace gdcm