]> Creatis software - gdcm.git/blob - src/gdcmDicomDirSerie.cxx
Some normalizations :
[gdcm.git] / src / gdcmDicomDirSerie.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/23 10:12:33 $
7   Version:   $Revision: 1.33 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDicomDirSerie.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmDicomDirImage.h"
22 #include "gdcmGlobal.h"
23 #include "gdcmDebug.h"
24
25 namespace gdcm 
26 {
27
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
30 /**
31  * \brief  Constructor 
32  */
33 DicomDirSerie::DicomDirSerie(bool empty):
34    DicomDirObject()
35 {
36    if( !empty )
37    {
38       ListDicomDirSerieElem const &elemList = 
39          Global::GetDicomDirElements()->GetDicomDirSerieElements();   
40       FillObject(elemList);
41    }
42 }
43
44 /**
45  * \brief   Canonical destructor.
46  */
47 DicomDirSerie::~DicomDirSerie() 
48 {
49    for(ListDicomDirImage::iterator cc = Images.begin();
50                                    cc != Images.end();
51                                    ++cc)
52    {
53       delete *cc;
54    }
55 }
56
57 //-----------------------------------------------------------------------------
58 // Print
59 /**
60  * \brief   Prints the Object
61  * @param os ostream to write to
62  * @param indent Indentation string to be prepended during printing
63  */ 
64 void DicomDirSerie::Print(std::ostream &os, std::string const &)
65 {
66    os << "SERIE" << std::endl;
67    DicomDirObject::Print(os);
68
69    for(ListDicomDirImage::iterator cc = Images.begin();
70                                    cc != Images.end();
71                                    ++cc)
72    {
73       (*cc)->SetPrintLevel(PrintLevel);
74       (*cc)->Print(os);
75    }
76 }
77
78 //-----------------------------------------------------------------------------
79 // Public
80 /**
81  * \brief   Writes the Object
82  * @param fp ofstream to write to
83  * @param t Type of the File (explicit VR, implicitVR, ...)
84  */ 
85 void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
86 {
87    DicomDirObject::WriteContent(fp, t);
88
89    for(ListDicomDirImage::iterator cc = Images.begin();
90                                    cc!= Images.end();
91                                  ++cc )
92    {
93       (*cc)->WriteContent( fp, t );
94    }
95 }
96
97 /**
98  * \brief   adds a new Image (with the basic elements) to a partially created DICOMDIR
99  */
100 DicomDirImage *DicomDirSerie::NewImage()
101 {
102    DicomDirImage *st = new DicomDirImage();
103    Images.push_back(st);
104    return st;   
105 }
106
107 /**
108  * \brief   Get the first entry while visiting the DicomDirImage
109  * \return  The first DicomDirImage if found, otherwhise NULL
110  */
111 DicomDirImage *DicomDirSerie::GetFirstImage()
112 {
113    ItImage = Images.begin();
114    if (ItImage != Images.end())
115       return *ItImage;
116    return NULL;
117 }
118
119 /**
120  * \brief   Get the next entry while visiting the DicomDirImages
121  * \note : meaningfull only if GetFirstEntry already called
122  * \return  The next DicomDirImages if found, otherwhise NULL
123  */
124 DicomDirImage *DicomDirSerie::GetNextImage()
125 {
126    gdcmAssertMacro (ItImage != Images.end());
127    {
128       ++ItImage;
129       if (ItImage != Images.end())      
130          return *ItImage;
131    }
132    return NULL;
133 }
134  
135 /**
136  * \brief   Get the first entry while visiting the DicomDirImage
137  * \return  The first DicomDirImage if found, otherwhise NULL
138  */
139 DicomDirImage *DicomDirSerie::GetLastImage()
140 {
141    ItImage = Images.end();
142    if (ItImage != Images.begin())
143    {
144       --ItImage;
145       return *ItImage;
146    }
147    return NULL;
148 }
149
150 //-----------------------------------------------------------------------------
151 // Protected
152
153 //-----------------------------------------------------------------------------
154 // Private
155
156 //-----------------------------------------------------------------------------
157 } // end namespace gdcm
158
159