From 3c0d544c9c06862021f24807ccde4bc3ad3eaf06 Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 5 May 2004 12:48:29 +0000 Subject: [PATCH] * src/gdcmCommon.h, gdcmDicomDir.cxx, gdcmFile.cxx, gdcmHeaderHelper.h, gdcmParser.cxx, gdcmParser.h : bug fix for the Microsoft .Net compilation -- BeNours --- ChangeLog | 4 +++ src/gdcmCommon.h | 10 +++--- src/gdcmDicomDir.cxx | 10 +++--- src/gdcmFile.cxx | 14 ++++---- src/gdcmParser.cxx | 80 ++++++++++++++++++++++---------------------- src/gdcmParser.h | 2 +- 6 files changed, 62 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2ee06a8..a4f7c524 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-05-04 Benoit Regrain + * src/gdcmCommon.h, gdcmDicomDir.cxx, gdcmFile.cxx, gdcmHeaderHelper.h, + gdcmParser.cxx, gdcmParser.h : bug fix for the Microsoft .Net compilation + 2004-05-04 Benoit Regrain * src/gdcmFile.cxx, gdcmHeader.cxx : bug fix for the msvc compilation * Test/ShowDicom.cxx : bug fix for msvc compilation diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 0af21208..76b3b064 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -92,11 +92,11 @@ typedef std::string TagKey; typedef std::string TagName; enum FileType { - Unknown = 0, - ExplicitVR, // gdcmDicomDir is in this case - ImplicitVR, - ACR, - ACR_LIBIDO + gdcmUnknown = 0, + gdcmExplicitVR, // gdcmDicomDir is in this case + gdcmImplicitVR, + gdcmACR, + gdcmACR_LIBIDO }; //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 6f80dfce..20d81973 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -337,28 +337,28 @@ void gdcmDicomDir::WriteEntries(FILE *_fp) ptrMeta= GetDicomDirMeta(); for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) { - WriteEntry(*i,_fp, ExplicitVR); + WriteEntry(*i,_fp, gdcmExplicitVR); } itPatient = GetDicomDirPatients().begin(); while ( itPatient != GetDicomDirPatients().end() ) { for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) { - WriteEntry(*i,_fp, ExplicitVR); + WriteEntry(*i,_fp, gdcmExplicitVR); } itStudy = ((*itPatient)->GetDicomDirStudies()).begin(); while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) { - WriteEntry(*i,_fp, ExplicitVR); + WriteEntry(*i,_fp, gdcmExplicitVR); } itSerie = ((*itStudy)->GetDicomDirSeries()).begin(); while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) { - WriteEntry(*i,_fp, ExplicitVR); + WriteEntry(*i,_fp, gdcmExplicitVR); } itImage = ((*itSerie)->GetDicomDirImages()).begin(); while (itImage != (*itSerie)->GetDicomDirImages().end() ) { for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) { - WriteEntry(*i,_fp, ExplicitVR); + WriteEntry(*i,_fp, gdcmExplicitVR); } ++itImage; } diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 607c37ae..12d464bc 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -623,7 +623,7 @@ bool gdcmFile::WriteRawData (std::string fileName) { */ bool gdcmFile::WriteDcmImplVR (std::string fileName) { - return WriteBase(fileName, ImplicitVR); + return WriteBase(fileName, gdcmImplicitVR); } /** @@ -649,7 +649,7 @@ bool gdcmFile::WriteDcmImplVR (const char *fileName) { */ bool gdcmFile::WriteDcmExplVR (std::string fileName) { - return WriteBase(fileName, ExplicitVR); + return WriteBase(fileName, gdcmExplicitVR); } /** @@ -668,7 +668,7 @@ bool gdcmFile::WriteDcmExplVR (std::string fileName) { */ bool gdcmFile::WriteAcr (std::string fileName) { - return WriteBase(fileName, ACR); + return WriteBase(fileName, gdcmACR); } //----------------------------------------------------------------------------- @@ -686,7 +686,7 @@ bool gdcmFile::WriteBase (std::string fileName, FileType type) { FILE *fp1; - if (PixelRead==-1 && type != ExplicitVR) { + if (PixelRead==-1 && type != gdcmExplicitVR) { return false; } @@ -696,7 +696,7 @@ bool gdcmFile::WriteBase (std::string fileName, FileType type) { return (false); } - if ( (type == ImplicitVR) || (type == ExplicitVR) ) { + if ( (type == gdcmImplicitVR) || (type == gdcmExplicitVR) ) { char *filePreamble; // writing Dicom File Preamble filePreamble=new char[128]; @@ -717,7 +717,7 @@ bool gdcmFile::WriteBase (std::string fileName, FileType type) { /// but pb expected if user deals with, e.g. COMPLEX images std::string rows, columns; - if ( Header->GetFileType() == ACR_LIBIDO){ + if ( Header->GetFileType() == gdcmACR_LIBIDO){ rows = Header->GetEntryByNumber(0x0028, 0x0010); columns = Header->GetEntryByNumber(0x0028, 0x0011); Header->SetEntryByNumber(columns, 0x0028, 0x0010); @@ -763,7 +763,7 @@ bool gdcmFile::WriteBase (std::string fileName, FileType type) { // ...and we restore the Header to be Dicom Compliant again // just after writting - if (Header->GetFileType() == ACR_LIBIDO){ + if (Header->GetFileType() == gdcmACR_LIBIDO){ Header->SetEntryByNumber(rows , 0x0028, 0x0010); Header->SetEntryByNumber(columns, 0x0028, 0x0011); } diff --git a/src/gdcmParser.cxx b/src/gdcmParser.cxx index 9a1c07ce..332b415a 100644 --- a/src/gdcmParser.cxx +++ b/src/gdcmParser.cxx @@ -178,7 +178,7 @@ bool gdcmParser::SetShaDict(DictKey dictName){ * false otherwise. */ bool gdcmParser::IsReadable(void) { - if(filetype==Unknown) { + if(filetype==gdcmUnknown) { return(false); } if(listEntries.size()<=0) { @@ -258,7 +258,7 @@ bool gdcmParser::IsExplicitVRBigEndianTransferSyntax(void) { /** * \brief returns the File Type - * (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown) + * (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unfound) * @return the FileType code */ FileType gdcmParser::GetFileType(void) { @@ -346,7 +346,7 @@ bool gdcmParser::Write(FILE *fp, FileType type) { /// a moins de se livrer a un tres complique ajout des champs manquants. /// faire un CheckAndCorrectHeader (?) - if (type == ImplicitVR) + if (type == gdcmImplicitVR) { std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2; ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010); @@ -359,7 +359,7 @@ bool gdcmParser::Write(FILE *fp, FileType type) { SetEntryLengthByNumber(18, 0x0002, 0x0010); } - if (type == ExplicitVR) + if (type == gdcmExplicitVR) { std::string explicitVRTransfertSyntax = UI1_2_840_10008_1_2_1; ReplaceOrCreateByNumber(explicitVRTransfertSyntax,0x0002, 0x0010); @@ -881,7 +881,7 @@ void gdcmParser::UpdateGroupLength(bool SkipSequence, FileType type) { } else // any elem but the first { - if (type == ExplicitVR) + if (type == gdcmExplicitVR) { if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) { @@ -946,7 +946,7 @@ void gdcmParser::WriteEntryTagVRLength(gdcmHeaderEntry *tag, fwrite ( &group,(size_t)2 ,(size_t)1 ,_fp); //group fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element - if ( type == ExplicitVR ) { + if ( type == gdcmExplicitVR ) { // Special case of delimiters: if (group == 0xfffe) { @@ -961,7 +961,7 @@ void gdcmParser::WriteEntryTagVRLength(gdcmHeaderEntry *tag, guint16 z=0; guint16 shortLgr = lgr; - if (vr == "unkn") { // Unknown was 'written' + if (vr == "unkn") { // Unfound was 'written' // deal with Little Endian fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp); fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp); @@ -1097,7 +1097,7 @@ bool gdcmParser::WriteEntries(FILE *_fp,FileType type) tag2 != listEntries.end(); ++tag2) { - if ( type == ACR ){ + if ( type == gdcmACR ){ if ((*tag2)->GetGroup() < 0x0008) // Ignore pure DICOM V3 groups continue; @@ -1138,7 +1138,7 @@ void gdcmParser::WriteEntriesDeprecated(FILE *_fp,FileType type) { for (TagHeaderEntryHT::iterator tag2=tagHT.begin(); tag2 != tagHT.end(); ++tag2){ - if ( type == ACR ){ + if ( type == gdcmACR ){ if ((*tag2->second).GetGroup() < 0x0008) continue; // ignore pure DICOM V3 groups if ((*tag2->second).GetElement() %2) continue; // ignore shadow groups if ((*tag2->second).GetVR() == "SQ" ) continue; // ignore Sequences @@ -1261,7 +1261,7 @@ bool gdcmParser::LoadHeaderEntries(bool exception_on_error) throw(gdcmFormatErro RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares // with "little-endian strings" { - filetype = ACR_LIBIDO; + filetype = gdcmACR_LIBIDO; std::string rows = GetEntryByNumber(0x0028, 0x0010); std::string columns = GetEntryByNumber(0x0028, 0x0011); SetEntryByNumber(columns, 0x0028, 0x0010); @@ -1398,7 +1398,7 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry) { guint16 length16; - if ( (filetype == ExplicitVR) && (! Entry->IsImplicitVR()) ) + if ( (filetype == gdcmExplicitVR) && (! Entry->IsImplicitVR()) ) { if ( (vr=="OB") || (vr=="OW") || (vr=="SQ") || (vr=="UN") ) { @@ -1480,7 +1480,7 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry) { //dbg.Verbose(0, "gdcmParser::FindLength", // "Erroneous element length fixed."); // Actually, length= 0xffff means that we deal with - // Unknown Sequence Length + // Unfound Sequence Length } FixHeaderEntryFoundLength(Entry, (guint32)length16); return; @@ -1505,7 +1505,7 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry) { */ void gdcmParser::FindHeaderEntryVR( gdcmHeaderEntry *Entry) { - if (filetype != ExplicitVR) + if (filetype != gdcmExplicitVR) return; char VR[3]; @@ -2026,13 +2026,13 @@ bool gdcmParser::CheckSwap() { // Use gdcmParser::dicom_vr to test all the possibilities // instead of just checking for UL, OB and UI !? group 0000 { - filetype = ExplicitVR; + filetype = gdcmExplicitVR; dbg.Verbose(1, "gdcmParser::CheckSwap:", "explicit Value Representation"); } else { - filetype = ImplicitVR; + filetype = gdcmImplicitVR; dbg.Verbose(1, "gdcmParser::CheckSwap:", "not an explicit Value Representation"); } @@ -2077,19 +2077,19 @@ bool gdcmParser::CheckSwap() { switch (s32) { case 0x00040000 : sw = 3412; - filetype = ACR; + filetype = gdcmACR; return true; case 0x04000000 : sw = 4321; - filetype = ACR; + filetype = gdcmACR; return true; case 0x00000400 : sw = 2143; - filetype = ACR; + filetype = gdcmACR; return true; case 0x00000004 : sw = 0; - filetype = ACR; + filetype = gdcmACR; return true; default : @@ -2108,27 +2108,27 @@ bool gdcmParser::CheckSwap() { // the file IS NOT ACR-NEMA nor DICOM V3 // Find a trick to tell it the caller... - s16 = *((guint16 *)(deb)); - - switch (s16) { - case 0x0002 : - case 0x0004 : - case 0x0008 : - sw = 0; - filetype = ACR; - return true; - case 0x0200 : - case 0x0400 : - case 0x0800 : - sw = 4321; - filetype = ACR; - return true; - default : - dbg.Verbose(0, "gdcmParser::CheckSwap:", - "ACR/NEMA unfound swap info (Really hopeless !)"); - filetype = Unknown; - return false; - } + s16 = *((guint16 *)(deb)); + + switch (s16) { + case 0x0002 : + case 0x0004 : + case 0x0008 : + sw = 0; + filetype = gdcmACR; + return true; + case 0x0200 : + case 0x0400 : + case 0x0800 : + sw = 4321; + filetype = gdcmACR; + return true; + default : + dbg.Verbose(0, "gdcmParser::CheckSwap:", + "ACR/NEMA unfound swap info (Really hopeless !)"); + filetype = gdcmUnknown; + return false; + } // Then the only info we have is the net2host one. //if (! net2host ) diff --git a/src/gdcmParser.h b/src/gdcmParser.h index 6f6c30bb..3bdc99a0 100644 --- a/src/gdcmParser.h +++ b/src/gdcmParser.h @@ -194,7 +194,7 @@ protected: void LoadHeaderEntrySafe(gdcmHeaderEntry *); void UpdateGroupLength(bool SkipSequence = false, - FileType type = ImplicitVR); + FileType type = gdcmImplicitVR); void AddHeaderEntry (gdcmHeaderEntry *); -- 2.48.1