X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmParser.cxx;h=ad61419132e4bc03917241f98abd6e0d7defe346;hb=d3e997d981d84fece924c52c8b513bccc6cd371a;hp=362ca03fc8a9b9d48a40b6270d2210b2f8f362e1;hpb=413108bd0261c821361a4fec1c0fa34ea446cb29;p=gdcm.git diff --git a/src/gdcmParser.cxx b/src/gdcmParser.cxx index 362ca03f..ad614191 100644 --- a/src/gdcmParser.cxx +++ b/src/gdcmParser.cxx @@ -19,6 +19,11 @@ #endif # include +#define UI1_2_840_10008_1_2 "1.2.840.10008.1.2" +#define UI1_2_840_10008_1_2_1 "1.2.840.10008.1.2.1" +#define UI1_2_840_10008_1_2_2 "1.2.840.10008.1.2.2" +#define UI1_2_840_10008_1_2_1_99 "1.2.840.10008.1.2.1.99" + //----------------------------------------------------------------------------- // Refer to gdcmParser::CheckSwap() const unsigned int gdcmParser::HEADER_LENGTH_TO_READ = 256; @@ -182,21 +187,13 @@ bool gdcmParser::SetShaDict(DictKey dictName) */ bool gdcmParser::IsReadable(void) { - std::string res = GetEntryByNumber(0x0028, 0x0005); - if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) - { - return false; // Image Dimensions - } + if(filetype==Unknown) + return(false); - if ( !GetHeaderEntryByNumber(0x0028, 0x0100) ) - return false; // "Bits Allocated" - if ( !GetHeaderEntryByNumber(0x0028, 0x0101) ) - return false; // "Bits Stored" - if ( !GetHeaderEntryByNumber(0x0028, 0x0102) ) - return false; // "High Bit" - if ( !GetHeaderEntryByNumber(0x0028, 0x0103) ) - return false; // "Pixel Representation" - return true; + if(listEntries.size()<=0) + return(false); + + return(true); } /** @@ -214,7 +211,7 @@ bool gdcmParser::IsImplicitVRLittleEndianTransferSyntax(void) LoadHeaderEntrySafe(Element); std::string Transfer = Element->GetValue(); - if ( Transfer == "1.2.840.10008.1.2" ) + if ( Transfer == UI1_2_840_10008_1_2 ) return true; return false; } @@ -234,7 +231,7 @@ bool gdcmParser::IsExplicitVRLittleEndianTransferSyntax(void) LoadHeaderEntrySafe(Element); std::string Transfer = Element->GetValue(); - if ( Transfer == "1.2.840.10008.1.2.1" ) + if ( Transfer == UI1_2_840_10008_1_2_1 ) return true; return false; } @@ -254,7 +251,7 @@ bool gdcmParser::IsDeflatedExplicitVRLittleEndianTransferSyntax(void) LoadHeaderEntrySafe(Element); std::string Transfer = Element->GetValue(); - if ( Transfer == "1.2.840.10008.1.2.1.99" ) + if ( Transfer == UI1_2_840_10008_1_2_1_99 ) return true; return false; } @@ -274,7 +271,7 @@ bool gdcmParser::IsExplicitVRBigEndianTransferSyntax(void) LoadHeaderEntrySafe(Element); std::string Transfer = Element->GetValue(); - if ( Transfer == "1.2.840.10008.1.2.2" ) //1.2.2 ??? A verifier ! + if ( Transfer == UI1_2_840_10008_1_2_2 ) //1.2.2 ??? A verifier ! return true; return false; } @@ -375,7 +372,7 @@ bool gdcmParser::Write(FILE *fp, FileType type) if (type == ImplicitVR) { - std::string implicitVRTransfertSyntax = "1.2.840.10008.1.2"; + std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2; ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010); //FIXME Refer to standards on page 21, chapter 6.2 "Value representation": @@ -387,7 +384,7 @@ bool gdcmParser::Write(FILE *fp, FileType type) if (type == ExplicitVR) { - std::string explicitVRTransfertSyntax = "1.2.840.10008.1.2.1"; + std::string explicitVRTransfertSyntax = UI1_2_840_10008_1_2_1; ReplaceOrCreateByNumber(explicitVRTransfertSyntax,0x0002, 0x0010); //FIXME Refer to standards on page 21, chapter 6.2 "Value representation": @@ -1320,7 +1317,11 @@ void gdcmParser::LoadHeaderEntry(gdcmHeaderEntry *Entry) Entry->SetValue("gdcm::UnRead"); return; } - Entry->SetValue(NewValue); + + if( (vr == "UI") ) // Because of correspondance with the VR dic + Entry->SetValue(NewValue.c_str()); + else + Entry->SetValue(NewValue); } /** @@ -1603,7 +1604,8 @@ std::string gdcmParser::GetHeaderEntryValue(gdcmHeaderEntry *Entry) { if(i!=0) s << '\\'; - NewInt32=(val[4*i+0]&0xFF)+((val[4*i+1]&0xFF)<<8)+((val[4*i+2]&0xFF)<<16)+((val[4*i+3]&0xFF)<<24); + NewInt32= (val[4*i+0]&0xFF)+((val[4*i+1]&0xFF)<<8)+ + ((val[4*i+2]&0xFF)<<16)+((val[4*i+3]&0xFF)<<24); NewInt32=SwapLong(NewInt32); s << NewInt32; } @@ -1634,7 +1636,6 @@ std::string gdcmParser::GetHeaderEntryUnvalue(gdcmHeaderEntry *Entry) std::string vr=Entry->GetVR(); std::ostringstream s; std::vector tokens; - unsigned char *ptr; if (vr == "US" || vr == "SS") {