X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDicomDir.cxx;h=f61ae1b54ca330b237630d378b059a3543bf9adb;hb=e8cd982edb78da16b0ca42d09a5a7943e48587ef;hp=03cc6a20c939c2cdc175ae2db38e06dad6fefaed;hpb=fea9426f960497d2d9124ab532d2097f2915678f;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 03cc6a20..f61ae1b5 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/22 03:05:40 $ - Version: $Revision: 1.74 $ + Date: $Date: 2004/11/09 22:15:36 $ + Version: $Revision: 1.79 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -34,7 +34,7 @@ #include #include -#ifdef _MSC_VER +#if defined( _MSC_VER) || defined(__BORLANDC__) #include #else #include @@ -340,6 +340,7 @@ void DicomDir::SetEndMethodArgDelete(Method* method) bool DicomDir::WriteDicomDir(std::string const& fileName) { + int i; uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff }; uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff }; @@ -347,20 +348,23 @@ bool DicomDir::WriteDicomDir(std::string const& fileName) std::ios::out | std::ios::binary); if( !fp ) { - printf("Failed to open(write) File [%s] \n", fileName.c_str()); + dbg.Verbose(2, "Failed to open(write) File: ", fileName.c_str()); return false; } - uint8_t filePreamble[128]; + char filePreamble[128]; memset(filePreamble, 0, 128); - fp->write((char*)filePreamble, 128); - fp->write("DICM",4); + fp->write(filePreamble, 128); //FIXME + binary_write( *fp, "DICM"); DicomDirMeta *ptrMeta = GetDicomDirMeta(); ptrMeta->Write(fp, ExplicitVR); // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta - fp->write((char*)&sq[0],8); + for(i=0;i<4;++i) + { + binary_write(*fp, sq[i]); + } for(ListDicomDirPatient::iterator cc = Patients.begin(); cc != Patients.end(); @@ -370,7 +374,10 @@ bool DicomDir::WriteDicomDir(std::string const& fileName) } // force writing Sequence Delimitation Item - fp->write((char*)&sqt[0],8); // fffe e0dd ffff ffff + for(i=0;i<4;++i) + { + binary_write(*fp, sqt[i]); // fffe e0dd ffff ffff + } fp->close(); return true; @@ -463,10 +470,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; } @@ -476,13 +483,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 @@ -534,11 +541,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; @@ -693,6 +700,7 @@ void DicomDir::SetElement(std::string &path,DicomDirType type, } +//----------------------------------------------------------------------------- /** * \brief CallStartMethod */ @@ -706,6 +714,7 @@ void DicomDir::CallStartMethod() } } +//----------------------------------------------------------------------------- /** * \ingroup DicomDir * \brief CallProgressMethod @@ -718,6 +727,7 @@ void DicomDir::CallProgressMethod() } } +//----------------------------------------------------------------------------- /** * \ingroup DicomDir * \brief CallEndMethod @@ -765,7 +775,7 @@ void DicomDir::CreateDicomDir() return; } - DicomDirType type = DicomDir::GDCM_DICOMDIR_META; + DicomDirType type; // = DicomDir::GDCM_DICOMDIR_META; MetaElems = NewMeta(); ListSQItem listItems = s->GetSQItems(); @@ -867,7 +877,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)); } @@ -888,12 +899,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)); } @@ -907,7 +919,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 = ""; @@ -917,8 +929,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);