]> Creatis software - gdcm.git/blobdiff - Testing/TestAllReadCompareDicom.cxx
Fix some verbosity
[gdcm.git] / Testing / TestAllReadCompareDicom.cxx
index caff81eded57fc51832320d574d6af5af57cc4fa..56aecc31634df67bce56481e673b2aeb846c6f9e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllReadCompareDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/14 12:27:57 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2007/06/04 08:51:24 $
+  Version:   $Revision: 1.59 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -21,6 +21,7 @@
 #include "gdcmGlobal.h"
 #include "gdcmTS.h"
 #include "gdcmDebug.h"
+#include "gdcmUtil.h"
 
 #include <iostream>
 
@@ -167,7 +168,14 @@ void TestFile::Write(const std::string &filename)
 
 int TestFile::ComputeSwapCode(uint32_t tag)
 {
+// FIXME : 100 % useless method !
+// "gdcm" was written on disc byte per byte.
+// when you fread it, you'll get *always* "gdcm"
+// whatever the processor indianess is !
+
    int swap = 0;
+   //std::cout << std::hex << "0x(" << tag << ")" << std::dec << std::endl;
+   
    for(int i=0;i<4;i++)
    {
       switch(tag&0x000000FF)
@@ -189,6 +197,7 @@ int TestFile::ComputeSwapCode(uint32_t tag)
       }
       tag >>= 8;
    }
+   //std::cout << std::hex << "0x(" << tag << ")" << std::dec << tag << std::endl;
    return swap;
 }
 
@@ -252,6 +261,7 @@ bool TestFile::ReadFileHeader(std::ifstream *fp)
    SwapCode = ComputeSwapCode(tag);
    if( SwapCode == 0 )
    {
+      // We shall *never* come here!
       std::cout << "TestFile: Bad tag - Must be 'gdcm'" << std::endl;
       return(false);
    }
@@ -274,15 +284,18 @@ bool TestFile::ReadFileData(std::ifstream *fp)
    if( !Data )
       return(false);
 
-   // Read data
+   // Read data  Note : .tst images are *always* created 
+   //           on little endian processor !
    fp->read((char *)Data,GetDataSize());
 
    // Track BigEndian troubles
    std::cout << " ScalarSize : " << GetScalarSize() 
-          << " SwapCode:" << GetSwapCode()
+          << " IsCurrentProcessorBigEndian:" 
+          << gdcm::Util::IsCurrentProcessorBigEndian()
           << std::endl;
         
-   if (GetScalarSize() == 1 || GetSwapCode() == 1234)
+   //if (GetScalarSize() == 1 || GetSwapCode() == 1234)  
+   if (GetScalarSize() == 1 || !gdcm::Util::IsCurrentProcessorBigEndian() )    
    {
       return true;
    }
@@ -323,6 +336,11 @@ bool TestFile::WriteFileHeader(std::ofstream *fp)
    WriteInt8(fp,'d'); // Bitmap tag - must be 'd'
    WriteInt8(fp,'c'); // Bitmap tag - must be 'c'
    WriteInt8(fp,'m'); // Bitmap tag - must be 'm'
+   
+   // FIXME : Think of writting an int32, better !
+   // (('g' << 8 + 'd') << 8 + 'c') + 'm'
+   // if you want to use it to check the endianess.
+   // (and upload again *all* the .tst files ...)
    WriteInt32(fp,SizeX); // Size X
    WriteInt32(fp,SizeY); // Size Y
    WriteInt32(fp,SizeZ); // Size Z
@@ -660,6 +678,11 @@ gdcm::Debug::WarningOn();
          return 1;
       }
 
+//if (gdcmDataImages[i] == "D_CLUNIE_CT2_RLE.dcm")
+//   gdcm::Debug::DebugOn(); // track pb on BigEndian Proc
+//else 
+   gdcm::Debug::DebugOff();
+   
       ////// Step 1 (see above description):
       std::string filename = GDCM_DATA_ROOT;
       filename += "/";