]> Creatis software - gdcm.git/blobdiff - Testing/TestAllReadCompareDicom.cxx
Avoid Warning
[gdcm.git] / Testing / TestAllReadCompareDicom.cxx
index e3212a8500d8e324459ea0b9014bfd7683a51334..7a7ab5c6f4f79ba630bb947d523798702d42d610 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllReadCompareDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/04/27 09:14:06 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2005/08/30 15:13:07 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,7 @@
 #include "gdcmFileHelper.h"
 #include "gdcmGlobal.h"
 #include "gdcmTS.h"
+#include "gdcmDebug.h"
 
 #include <iostream>
 
@@ -112,9 +113,10 @@ private:
    static const unsigned int HEADER_SIZE;
 };
 
+const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10;
 const unsigned int TestFile::HEADER_SIZE = 20;
 
-TestFile::TestFile(void)
+TestFile::TestFile()
 {
    fileName = "";
    readable=false;
@@ -394,16 +396,23 @@ int InternalTest(std::string const &filename,
 
       ////// Step 1:
       std::cout << "1...";
-      gdcm::FileHelper *tested = new gdcm::FileHelper( filename );
-      if( !tested->GetFile()->IsReadable() )
+
+       // new style 
+      gdcm::File *f = new gdcm::File();
+      f->SetLoadMode ( gdcm::LD_ALL ); // Load everything
+      f->SetFileName( filename );
+      f->Load();
+      if( !f->IsReadable() )
       {
         std::cout << " Failed" << std::endl
                    << "      Image not gdcm compatible:"
                   << filename << std::endl;
-        delete tested;
+        delete f;
         return 1;
       }
-
+     gdcm::FileHelper *tested = new gdcm::FileHelper( f );
+     
       ////// Step 2:
       ////// Check for existence of reference baseline dicom file:
       std::cout << "2...";
@@ -435,6 +444,7 @@ int InternalTest(std::string const &filename,
                   << filename << std::endl;
          delete reference;
          delete tested;
+         delete f;
          return 1;
       }
 
@@ -462,6 +472,7 @@ int InternalTest(std::string const &filename,
                    << reference->GetZSize() << std::endl;
          delete reference;
          delete tested;
+         delete f;
          return 1;
       }
 
@@ -477,7 +488,7 @@ int InternalTest(std::string const &filename,
                    << reference->GetNumberOfComponents() << std::endl;
          delete reference;
          delete tested;
-         return 1;
+         delete f;
       }
 
       // Test the data size
@@ -496,6 +507,7 @@ int InternalTest(std::string const &filename,
                    << std::endl;
          delete tested;
          delete reference;
+         delete f;
          return 1;
       }
 
@@ -514,26 +526,34 @@ int InternalTest(std::string const &filename,
                    << "        compression : " 
                    << gdcm::Global::GetTS()->GetValue(ts) << std::endl;
 
-         std::cout << "        list of pixels differing (pos : test - ref) :" 
+         std::cout << "        list of the first " << MAX_NUMBER_OF_DIFFERENCE
+                   << " pixels differing (pos : test - ref) :" 
                    << std::endl;
-         for(int i=0;i<testedDataSize;i++)
+         int i;
+         unsigned int j;
+         for(i=0, j=0;i<testedDataSize && j<MAX_NUMBER_OF_DIFFERENCE;i++)
          {
             if(testedImageData[i]!=referenceImageData[i])
+              {
                std::cout << std::hex << "(" << i << " : " 
                          << std::hex << (int)(testedImageData[i]) << " - "
                          << std::hex << (int)(referenceImageData[i]) << ") "
                          << std::dec;
+               ++j;
+              }
          }
          std::cout << std::endl;
 
          delete tested;
          delete reference;
+         delete f;
          return 1;
       }
 
       //////////////// Clean up:
       delete tested;
       delete reference;
+      delete f;
 
       std::cout << "OK." << std::endl;
       
@@ -542,7 +562,10 @@ int InternalTest(std::string const &filename,
 
 int TestAllReadCompareDicom(int argc, char *argv[]) 
 {
-   if ( argc == 3 )
+   if (argc == 4)
+      gdcm::Debug::DebugOn();
+
+   if ( argc >= 3 )
    {
       // The test is specified a specific filename, use it instead of looping
       // over all images
@@ -550,7 +573,7 @@ int TestAllReadCompareDicom(int argc, char *argv[])
       const std::string reference = argv[2];
       return InternalTest( input, reference );
    }
-   else if ( argc > 3 || argc == 2 )
+   else if ( argc > 4 || argc == 2 )
    {
       std::cerr << "   Usage: " << argv[0]
                 << " (no arguments needed)." << std::endl;