From d3e997d981d84fece924c52c8b513bccc6cd371a Mon Sep 17 00:00:00 2001 From: regrain Date: Fri, 23 Jan 2004 13:05:30 +0000 Subject: [PATCH] * Bug fix on field having a VR = 'UI'. Assume that is a string field * Bug fix on test suite after remove the strip made on not string fields * Split the IsReadable method between gdcmParser which test that the file is dicom and gdcmHeader which test that it's an image file -- BeNours --- ChangeLog | 2 ++ src/gdcmHeader.cxx | 29 +++++++++++++++++++++++++++++ src/gdcmHeader.h | 1 + src/gdcmHeaderEntry.cxx | 14 +++++++------- src/gdcmParser.cxx | 20 +++++++------------- src/gdcmParser.h | 2 +- src/gdcmTS.cxx | 6 ------ 7 files changed, 47 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae542590..9d502b47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2004-01-23 Benoit Regrain * Bug fix on field having a VR = 'UI'. Assume that is a string field * Bug fix on test suite after remove the strip made on not string fields + * Split the IsReadable method between gdcmParser which test that the file + is dicom and gdcmHeader which test that it's an image file 2004-01-22 Benoit Regrain * DicomDir : clean code, add methods, set variables in protected or private diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index e9d52811..503fea29 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -59,6 +59,35 @@ gdcmHeader::~gdcmHeader (void) { //----------------------------------------------------------------------------- // Public +/** + * \ingroup gdcmHeader + * \brief This predicate, based on hopefully reasonable heuristics, + * decides whether or not the current gdcmParser was properly parsed + * and contains the mandatory information for being considered as + * a well formed and usable Dicom/Acr File. + * @return true when gdcmParser is the one of a reasonable Dicom/Acr file, + * false otherwise. + */ +bool gdcmHeader::IsReadable(void) +{ + if(!gdcmParser::IsReadable()) + return(false); + + std::string res = GetEntryByNumber(0x0028, 0x0005); + if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) + return false; // Image Dimensions + + 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; +} + /** * \ingroup gdcmHeader * \brief Determines if the Transfer Syntax was already encountered diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index c07c94d2..d5cc86b6 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -38,6 +38,7 @@ public: virtual ~gdcmHeader(); // Standard values and informations contained in the header + virtual bool IsReadable(void); bool IsJPEGBaseLineProcess1TransferSyntax(void); bool IsJPEGExtendedProcess2_4TransferSyntax(void); bool IsJPEGExtendedProcess3_5TransferSyntax(void); diff --git a/src/gdcmHeaderEntry.cxx b/src/gdcmHeaderEntry.cxx index 56ff8978..c74b8afb 100644 --- a/src/gdcmHeaderEntry.cxx +++ b/src/gdcmHeaderEntry.cxx @@ -27,7 +27,6 @@ gdcmHeaderEntry::gdcmHeaderEntry(gdcmDictEntry* in) { //----------------------------------------------------------------------------- // Print - void gdcmHeaderEntry::Print(std::ostream & os) { size_t o; unsigned short int g, e; @@ -81,16 +80,17 @@ void gdcmHeaderEntry::Print(std::ostream & os) { s << "[" << GetName()<< "]"; s << " [" << d2 << "]"; - // Display the UID value (instead of displaying the rough code) + + // Display the UID value (instead of displaying the rough code) if (g == 0x0002) { // Any more to be displayed ? - if ( (e == 0x0010) || (e == 0x0002) ) - s << " ==>\t[" << ts->GetValue(v) << "]"; + if ( (e == 0x0010) || (e == 0x0002) ) + s << " ==>\t[" << ts->GetValue(v) << "]"; } else { if (g == 0x0008) { - if ( (e == 0x0016) || (e == 0x1150) ) - s << " ==>\t[" << ts->GetValue(v) << "]"; + if ( (e == 0x0016) || (e == 0x1150) ) + s << " ==>\t[" << ts->GetValue(v) << "]"; } - } + } if (e == 0x0000) { // elem 0x0000 --> group length if (v == "4294967295") // to avoid troubles in convertion sprintf (st," x(ffffffff)"); diff --git a/src/gdcmParser.cxx b/src/gdcmParser.cxx index 384aa6e0..ad614191 100644 --- a/src/gdcmParser.cxx +++ b/src/gdcmParser.cxx @@ -187,19 +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 ( !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(filetype==Unknown) + return(false); + + if(listEntries.size()<=0) + return(false); + + return(true); } /** diff --git a/src/gdcmParser.h b/src/gdcmParser.h index 34311b8e..cd18a817 100644 --- a/src/gdcmParser.h +++ b/src/gdcmParser.h @@ -62,7 +62,7 @@ public: bool SetShaDict(DictKey dictName); // Informations contained in the parser - bool IsReadable(void); + virtual bool IsReadable(void); bool IsImplicitVRLittleEndianTransferSyntax(void); bool IsExplicitVRLittleEndianTransferSyntax(void); bool IsDeflatedExplicitVRLittleEndianTransferSyntax(void); diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index 469247c6..b648b26b 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -35,12 +35,6 @@ gdcmTS::gdcmTS(void) from.getline(buff, 1024, ' '); key = buff; - if(key.size()%2==1) - { - key.resize(key.size()+1); - key[key.size()-1]=0; - } - eatwhite(from); from.getline(buff, 1024, '\n'); name = buff; -- 2.45.2