]> Creatis software - gdcm.git/blobdiff - src/gdcmHeader.cxx
* Bug fix on field having a VR = 'UI'. Assume that is a string field
[gdcm.git] / src / gdcmHeader.cxx
index 024862ddd77b5e9eec4d304630d8900f5b872216..503fea29fb85f2c13e750c3fd95190572233b89d 100644 (file)
@@ -4,21 +4,8 @@
 
 #include <stdio.h>
 #include <cerrno>
-/*// For nthos:
-#ifdef _MSC_VER
-   #include <winsock.h>
-#else
-   #include <netinet/in.h>
-#endif*/
 #include <cctype>    // for isalpha
 
-/*#ifdef GDCM_NO_ANSI_STRING_STREAM
-#  include <strstream>
-#  define  ostringstream ostrstream
-# else
-#  include <sstream>
-#endif*/
-
 #include "gdcmUtil.h"
 #include "gdcmTS.h"
 
@@ -72,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