]> Creatis software - gdcm.git/commitdiff
* Bug fix on field having a VR = 'UI'. Assume that is a string field
authorregrain <regrain>
Fri, 23 Jan 2004 13:05:30 +0000 (13:05 +0000)
committerregrain <regrain>
Fri, 23 Jan 2004 13:05:30 +0000 (13:05 +0000)
     * 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
src/gdcmHeader.cxx
src/gdcmHeader.h
src/gdcmHeaderEntry.cxx
src/gdcmParser.cxx
src/gdcmParser.h
src/gdcmTS.cxx

index ae5425907a85fd611351a7c9c3f99a705fb2a662..9d502b4754572fcfd430feeb4737c3e6346231fe 100644 (file)
--- 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
index e9d528117364d0e8927e902852e553ad8072a40a..503fea29fb85f2c13e750c3fd95190572233b89d 100644 (file)
@@ -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
index c07c94d297fb96d925178e21ce30e872eb934562..d5cc86b642209219860cba93749775404821a87a 100644 (file)
@@ -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);
index 56ff8978c2fd8f5a2397eb73403f3e9ff1f71fd8..c74b8afb8415d246645e534f72dc4806af4d4a9d 100644 (file)
@@ -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)");
index 384aa6e045beb73fd36eafe99c6ad616f2a64896..ad61419132e4bc03917241f98abd6e0d7defe346 100644 (file)
@@ -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);
 }
 
 /**
index 34311b8e1b45f0dba116e41f9e1cfbff0b8a20d1..cd18a817f23ffbccda29cda7fe34574b4b57c6ae 100644 (file)
@@ -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);
index 469247c6e7c209c292a84614905fb78e25e04596..b648b26bbb9e018bb2612108fe7fae8726147a1d 100644 (file)
@@ -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;