X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FgdcmDicomDir.cxx;h=5c264bf26b06875a1973b1948a5b7c49fa2941c8;hb=f6204e4795251ff95c653e32e8cdca61d2c19880;hp=35726eac96b77eb1e632e162b00347daed4cb68d;hpb=1d69b92978803204089d270599133917d944c651;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 35726eac..5c264bf2 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2004/10/12 04:35:44 $ - Version: $Revision: 1.73 $ + Date: $Date: 2004/10/25 04:47:43 $ + Version: $Revision: 1.76 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -29,6 +29,7 @@ #include "gdcmSQItem.h" #include "gdcmValEntry.h" +#include #include #include #include @@ -342,7 +343,8 @@ bool DicomDir::WriteDicomDir(std::string const& fileName) uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff }; uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff }; - FILE* fp = fopen(fileName.c_str(), "wb"); + std::ofstream* fp = new std::ofstream(fileName.c_str(), + std::ios::out | std::ios::binary); if( !fp ) { printf("Failed to open(write) File [%s] \n", fileName.c_str()); @@ -351,14 +353,14 @@ bool DicomDir::WriteDicomDir(std::string const& fileName) uint8_t filePreamble[128]; memset(filePreamble, 0, 128); - fwrite(filePreamble,128,1,fp); - fwrite("DICM",4,1,fp); + fp->write((char*)filePreamble, 128); + fp->write("DICM",4); DicomDirMeta *ptrMeta = GetDicomDirMeta(); ptrMeta->Write(fp, ExplicitVR); // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta - fwrite(&sq[0],8,1,fp); // 0004 1220 ffff ffff + fp->write((char*)&sq[0],8); for(ListDicomDirPatient::iterator cc = Patients.begin(); cc != Patients.end(); @@ -368,9 +370,9 @@ bool DicomDir::WriteDicomDir(std::string const& fileName) } // force writing Sequence Delimitation Item - fwrite(&sqt[0],8,1,fp); // fffe e0dd ffff ffff + fp->write((char*)&sqt[0],8); // fffe e0dd ffff ffff - fclose( fp ); + fp->close(); return true; } @@ -461,10 +463,10 @@ DicomDirMeta * DicomDir::NewMeta() } else // after root directory parsing { - std::list elemList; - elemList=Global::GetDicomDirElements()->GetDicomDirMetaElements(); - m->FillObject(elemList); - } + ListDicomDirMetaElem const & elemList = + Global::GetDicomDirElements()->GetDicomDirMetaElements(); + m->FillObject(elemList); + } m->SetSQItemNumber(0); // To avoid further missprinting return m; } @@ -474,13 +476,13 @@ DicomDirMeta * DicomDir::NewMeta() */ DicomDirPatient * DicomDir::NewPatient() { - std::list::iterator it; + ListDicomDirPatientElem::const_iterator it; uint16_t tmpGr,tmpEl; DictEntry *dictEntry; ValEntry *entry; - std::list elemList; - elemList=Global::GetDicomDirElements()->GetDicomDirPatientElements(); + ListDicomDirPatientElem const & elemList = + Global::GetDicomDirElements()->GetDicomDirPatientElements(); SQItem *s = new SQItem(0); // for all the DicomDirPatient Elements @@ -532,11 +534,11 @@ DicomDirPatient * DicomDir::NewPatient() * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...) * @param header Header of the current file */ -void DicomDir::SetElement(std::string &path,DicomDirType type, - Document *header) +void DicomDir::SetElement(std::string const & path, DicomDirType type, + Document *header) { - std::list elemList; - std::list::iterator it; + ListDicomDirElem elemList; //FIXME this is going to be a by copy operation + ListDicomDirElem::const_iterator it; uint16_t tmpGr, tmpEl; DictEntry *dictEntry; ValEntry *entry; @@ -691,6 +693,7 @@ void DicomDir::SetElement(std::string &path,DicomDirType type, } +//----------------------------------------------------------------------------- /** * \brief CallStartMethod */ @@ -704,6 +707,7 @@ void DicomDir::CallStartMethod() } } +//----------------------------------------------------------------------------- /** * \ingroup DicomDir * \brief CallProgressMethod @@ -716,6 +720,7 @@ void DicomDir::CallProgressMethod() } } +//----------------------------------------------------------------------------- /** * \ingroup DicomDir * \brief CallEndMethod @@ -865,7 +870,8 @@ void DicomDir::AddDicomDirSerieToEnd(SQItem *s) if( (*itp)->GetDicomDirStudies().size() > 0 ) { - ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end(); + ListDicomDirStudy::const_iterator itst = + (*itp)->GetDicomDirStudies().end(); itst--; (*itst)->AddDicomDirSerie(new DicomDirSerie(s, &TagHT)); } @@ -886,12 +892,13 @@ void DicomDir::AddDicomDirSerieToEnd(SQItem *s) if( (*itp)->GetDicomDirStudies().size() > 0 ) { - ListDicomDirStudy::iterator itst = (*itp)->GetDicomDirStudies().end(); + ListDicomDirStudy::const_iterator itst = + (*itp)->GetDicomDirStudies().end(); itst--; if( (*itst)->GetDicomDirSeries().size() > 0 ) { - ListDicomDirSerie::iterator its = (*itst)->GetDicomDirSeries().end(); + ListDicomDirSerie::const_iterator its = (*itst)->GetDicomDirSeries().end(); its--; (*its)->AddDicomDirImage(new DicomDirImage(s, &TagHT)); } @@ -905,7 +912,7 @@ void DicomDir::AddDicomDirSerieToEnd(SQItem *s) * @param path path of the root directory * @param list chained list of Headers */ -void DicomDir::SetElements(std::string &path, VectDocument &list) +void DicomDir::SetElements(std::string const & path, VectDocument const &list) { std::string patPrevName = "", patPrevID = ""; std::string studPrevInstanceUID = "", studPrevID = ""; @@ -915,8 +922,8 @@ void DicomDir::SetElements(std::string &path, VectDocument &list) std::string studCurInstanceUID, studCurID; std::string serCurInstanceUID, serCurID; - for( VectDocument::iterator it = list.begin(); - it != list.end(); ++it ) + for( VectDocument::const_iterator it = list.begin(); + it != list.end(); ++it ) { // get the current file characteristics patCurName = (*it)->GetEntryByNumber(0x0010,0x0010);