]> 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 ae54259..9d502b4 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 e9d5281..503fea2 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 c07c94d..d5cc86b 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 56ff897..c74b8af 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 384aa6e..ad61419 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 34311b8..cd18a81 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 469247c..b648b26 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;