X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDicomDir.cxx;h=b7f4cb00d04bfa18f3376856c1c2f893daaad918;hb=559c3639fc5b255b36a951f352db1addead9f78f;hp=68e27d63cac75e1633cefb42811892028aadbb16;hpb=7b3410ee413b056e0e599a4800ea836c8b56152b;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 68e27d63..b7f4cb00 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/25 04:08:19 $ - Version: $Revision: 1.75 $ + Date: $Date: 2004/11/03 20:52:13 $ + Version: $Revision: 1.77 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -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; @@ -534,7 +541,7 @@ DicomDirPatient * DicomDir::NewPatient() * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...) * @param header Header of the current file */ -void DicomDir::SetElement(std::string &path, DicomDirType type, +void DicomDir::SetElement(std::string const & path, DicomDirType type, Document *header) { ListDicomDirElem elemList; //FIXME this is going to be a by copy operation @@ -912,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 = ""; @@ -922,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);