00001 /*========================================================================= 00002 00003 Program: gdcm 00004 Module: $RCSfile: gdcmDicomDirSerie.cxx,v $ 00005 Language: C++ 00006 Date: $Date: 2005/11/29 12:48:46 $ 00007 Version: $Revision: 1.40 $ 00008 00009 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00010 l'Image). All rights reserved. See Doc/License.txt or 00011 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. 00012 00013 This software is distributed WITHOUT ANY WARRANTY; without even 00014 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00015 PURPOSE. See the above copyright notices for more information. 00016 00017 =========================================================================*/ 00018 00019 #include "gdcmDicomDirSerie.h" 00020 #include "gdcmDicomDirElement.h" 00021 #include "gdcmDicomDirImage.h" 00022 #include "gdcmGlobal.h" 00023 #include "gdcmDebug.h" 00024 00025 namespace gdcm 00026 { 00027 //----------------------------------------------------------------------------- 00028 // Constructor / Destructor 00033 DicomDirSerie::DicomDirSerie(bool empty): 00034 DicomDirObject() 00035 { 00036 if ( !empty ) 00037 { 00038 ListDicomDirSerieElem const &elemList = 00039 Global::GetDicomDirElements()->GetDicomDirSerieElements(); 00040 FillObject(elemList); 00041 } 00042 } 00043 00047 DicomDirSerie::~DicomDirSerie() 00048 { 00049 ClearImage(); 00050 } 00051 00052 //----------------------------------------------------------------------------- 00053 // Public 00059 void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t) 00060 { 00061 DicomDirObject::WriteContent(fp, t); 00062 00063 for(ListDicomDirImage::iterator cc = Images.begin(); 00064 cc!= Images.end(); 00065 ++cc ) 00066 { 00067 (*cc)->WriteContent( fp, t ); 00068 } 00069 } 00070 00075 DicomDirImage *DicomDirSerie::NewImage() 00076 { 00077 DicomDirImage *dd = DicomDirImage::New(); 00078 Images.push_back(dd); 00079 return dd; 00080 } 00081 00085 void DicomDirSerie::ClearImage() 00086 { 00087 for(ListDicomDirImage::iterator cc = Images.begin(); 00088 cc != Images.end(); 00089 ++cc) 00090 { 00091 (*cc)->Delete(); 00092 } 00093 Images.clear(); 00094 } 00095 00100 DicomDirImage *DicomDirSerie::GetFirstImage() 00101 { 00102 ItImage = Images.begin(); 00103 if (ItImage != Images.end()) 00104 return *ItImage; 00105 return NULL; 00106 } 00107 00113 DicomDirImage *DicomDirSerie::GetNextImage() 00114 { 00115 gdcmAssertMacro (ItImage != Images.end()); 00116 00117 ++ItImage; 00118 if (ItImage != Images.end()) 00119 return *ItImage; 00120 return NULL; 00121 } 00122 00128 void DicomDirSerie::Copy(DocEntrySet *set) 00129 { 00130 // Remove all previous childs 00131 ClearImage(); 00132 00133 DicomDirObject::Copy(set); 00134 00135 DicomDirSerie *ddEntry = dynamic_cast<DicomDirSerie *>(set); 00136 if( ddEntry ) 00137 { 00138 Images = ddEntry->Images; 00139 for(ItImage = Images.begin();ItImage != Images.end();++ItImage) 00140 (*ItImage)->Register(); 00141 } 00142 } 00143 00144 //----------------------------------------------------------------------------- 00145 // Protected 00146 00147 //----------------------------------------------------------------------------- 00148 // Private 00149 00150 //----------------------------------------------------------------------------- 00151 // Print 00157 void DicomDirSerie::Print(std::ostream &os, std::string const &) 00158 { 00159 os << "SERIE" << std::endl; 00160 DicomDirObject::Print(os); 00161 00162 for(ListDicomDirImage::iterator cc = Images.begin(); 00163 cc != Images.end(); 00164 ++cc) 00165 { 00166 (*cc)->SetPrintLevel(PrintLevel); 00167 (*cc)->Print(os); 00168 } 00169 } 00170 00171 //----------------------------------------------------------------------------- 00172 } // end namespace gdcm