]> Creatis software - gdcm.git/commitdiff
* src/gdcmHeader[h, cxx] gdcmHeader now has an IsReadable predicate.
authorfrog <frog>
Wed, 26 Mar 2003 18:38:44 +0000 (18:38 +0000)
committerfrog <frog>
Wed, 26 Mar 2003 18:38:44 +0000 (18:38 +0000)
      * gdcmPython/demo/test.py changed accordingly. --- Frog

.cvsignore
ChangeLog
gdcmPython/.cvsignore
gdcmPython/_gdcm.so [deleted file]
gdcmPython/demo/test.py
src/gdcmHeader.cxx
src/gdcmHeader.h

index 04643c47aabaec3143a99ae054680acf5d01263a..1326c4569c91a3395d172c3c730d1cf78ea45154 100644 (file)
@@ -13,5 +13,5 @@ aclocal.m4
 build
 dist
 MANIFEST
-DCMlib*.tar.gz
+gdcm*.tar.gz
 gdcm.spec
index e22a8f873ceb91f574efc8b9c2df6d849c2530aa..a7d1e2ad4198b1798731c60ab2deec34c7f82f0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-03-26 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+      * src/gdcmHeader[h, cxx] gdcmHeader now has an IsReadable predicate.
+      * gdcmPython/demo/test.py changed accordingly.
+
 2003-03-25 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
       * gdcmPython/Makefile.am fixed linking against libstdc++
       * gdcmPython/_gdcm.so symbolic link to gdcmPython/.libs/pygdcm.so added.
index 11666e7ad0aeef8f027994162256caa5410f7c8f..0b2b713498d7c58881f8209327046138fe1fedd8 100644 (file)
@@ -9,3 +9,4 @@ Makefile.in
 *.la
 .libs
 .deps
+_gdcm.so
diff --git a/gdcmPython/_gdcm.so b/gdcmPython/_gdcm.so
deleted file mode 100755 (executable)
index 8d2325b..0000000
Binary files a/gdcmPython/_gdcm.so and /dev/null differ
index 935345c1cf4fe6ef7e034ab7b47cd545b48bb15e..fa98de2d86a4a8108a69f2b027ad399ca0b9e66e 100644 (file)
@@ -1,4 +1,5 @@
 from gdcmPython import *
+import sys
 
 ### Get filename from command line or default it
 try:
@@ -15,6 +16,10 @@ if not os.path.isfile(FileName):
 
 ### Build the header element list
 toRead = gdcmHeader(FileName)
+if not toRead.IsReadable():
+   print "The ", FileName, " file is not "
+   print "   readable with gdcm. Sorry."
+   sys.exit()
 
 print "##############################################################"
 print "### Display all the elements and their respective values"
index a16d0693841a40f35696f18e52fc917dd1c5aebd..6a6a277ae681c7250ebbbfbed2da5cdff66be044 100644 (file)
@@ -714,13 +714,14 @@ void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) {
 
    fseek(fp, (long)ElVal->GetOffset(), SEEK_SET);
    
-   // Sequences not treated yet !
+   // FIXME Sequences not treated yet !
    //
    // Ne faudrait-il pas au contraire trouver immediatement
    // une maniere 'propre' de traiter les sequences (vr = SQ)
    // car commencer par les ignorer risque de conduire a qq chose
    // qui pourrait ne pas etre generalisable
-   //
+   // Well, I'm expecting your code !!!
+    
    if( vr == "SQ" )
       SkipLoad = true;
 
@@ -1415,6 +1416,32 @@ void gdcmHeader::AddAndDefaultElements(void) {
       NewElVal->SetValue("0");
 }
 
+/**
+ * \ingroup gdcmHeader
+ * \brief  This predicate, based on hopefully reasonnable heuristics,
+ *         decides whether or not the current gdcmHeader was properly parsed
+ *         and contains the mandatory information for being considered as
+ *         a well formed and usable image.
+ * @return true when gdcmHeader is the one of a reasonable Dicom file,
+ *         false otherwise. 
+ */
+bool gdcmHeader::IsReadable(void) {
+   if (   GetElValByName("Image Dimensions") != "gdcm::Unfound"
+      && atoi(GetElValByName("Image Dimensions").c_str()) > 4 ) {
+      return false;
+   }
+   if (  GetElValByName("Bits Allocated") == "gdcm::Unfound" )
+      return false;
+   if (  GetElValByName("Bits Stored") == "gdcm::Unfound" )
+      return false;
+   if (  GetElValByName("High Bit") == "gdcm::Unfound" )
+      return false;
+   if (  GetElValByName("Pixel Representation") == "gdcm::Unfound" )
+      return false;
+   return true;
+}
+
+
 /**
  * \ingroup gdcmHeader
  * \brief   Small utility function that creates a new manually crafted
index ec1943ba30f741e27974276c3489b9118dbd02d9..7aec5e5249bd53517ea12c0e17ca71f62fca2df4 100644 (file)
@@ -123,6 +123,7 @@ protected:
    int anonymize(ostream&);  // FIXME : anonymize should be a friend ?
 public:
    void LoadElements(void);
+   bool IsReadable(void);
    virtual void ParseHeader(bool exception_on_error = false)
      throw(gdcmFormatError);
    gdcmHeader(const char *filename, bool exception_on_error = false)