]> Creatis software - gdcm.git/blobdiff - Testing/TestWriteSimple.cxx
Normalization
[gdcm.git] / Testing / TestWriteSimple.cxx
index 1399e339c3c95d5d42cd075a144b7d385cc6be72..51d04094fcff7e183de784a3c79f6944f5be99c8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/21 11:40:54 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2005/02/02 10:05:26 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -24,6 +24,7 @@
  */
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
+#include "gdcmDebug.h"
 
 #include <iostream>
 #include <sstream>
@@ -71,54 +72,54 @@ int WriteSimple(Image &img)
 
 // Step 1 : Create the header of the image
    std::cout << "        1...";
-   gdcm::File *header = new gdcm::File();
+   gdcm::File *fileToBuild = new gdcm::File();
    std::ostringstream str;
 
    // Set the image size
    str.str("");
    str << img.sizeX;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0011); // Columns
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0011); // Columns
 
    str.str("");
    str << img.sizeY;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0010); // Rows
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0010); // Rows
 
    if(img.sizeZ>1)
    {
       str.str("");
       str << img.sizeZ;
-      header->ReplaceOrCreate(str.str(),0x0028,0x0008); // Number of Frames
+      fileToBuild->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
    }
 
    // Set the pixel type
    str.str("");
    str << img.componentSize;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0100); // Bits Allocated
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
 
    str.str("");
    str << img.componentUse;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0101); // Bits Stored
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << img.componentSize - 1;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0102); // High Bit
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
 
    // Set the pixel representation
    str.str("");
    str << img.sign;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0103); // Pixel Representation
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
 
    // Set the samples per pixel
    str.str("");
    str << img.components;
-   header->ReplaceOrCreate(str.str(),0x0028,0x0002); // Samples per Pixel
+   fileToBuild->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
 
-   if( !header->IsReadable() )
+   if( !fileToBuild->IsReadable() )
    {
       std::cout << "Failed\n"
                 << "        Prepared image isn't readable\n";
 
-      delete header;
+      delete fileToBuild;
       return 1;
    }
 
@@ -155,7 +156,7 @@ int WriteSimple(Image &img)
 
 // Step 3 : Create the file of the image
    std::cout << "3...";
-   gdcm::FileHelper *file = new gdcm::FileHelper(header);
+   gdcm::FileHelper *file = new gdcm::FileHelper(fileToBuild);
    file->SetImageData(imageData,size);
 
 // Step 4 : Set the writting mode and write the image
@@ -181,7 +182,7 @@ int WriteSimple(Image &img)
                    << "        Write mode '"<<img.writeMode<<"' is undefined\n";
 
          delete file;
-         delete header;
+         delete fileToBuild;
          delete[] imageData;
          return 1;
    }
@@ -192,20 +193,20 @@ int WriteSimple(Image &img)
                 << "File in unwrittable\n";
 
       delete file;
-      delete header;
+      delete fileToBuild;
       delete[] imageData;
       return 1;
    }
 
 // Step 5 : Read the written image
    std::cout << "5...";
-   gdcm::FileHelperreread = new gdcm::FileHelper( fileName );
+   gdcm::FileHelper *reread = new gdcm::FileHelper( fileName );
    if( !reread->GetFile()->IsReadable() )
    {
      std::cerr << "Failed" << std::endl
                << "Test::TestReadWriteReadCompare: Could not reread image "
                << "written:" << fileName << std::endl;
-     delete header;
+     delete fileToBuild;
      delete file;
      delete reread;
      return 1;
@@ -214,22 +215,22 @@ int WriteSimple(Image &img)
 // Step 6 : Compare to the written image
    std::cout << "6...";
    size_t dataSizeWritten = reread->GetImageDataSize();
-   uint8_timageDataWritten = reread->GetImageData();
+   uint8_t *imageDataWritten = reread->GetImageData();
 
    // Test the image size
-   if (header->GetXSize() != reread->GetFile()->GetXSize() ||
-       header->GetYSize() != reread->GetFile()->GetYSize() ||
-       header->GetZSize() != reread->GetFile()->GetZSize())
+   if (fileToBuild->GetXSize() != reread->GetFile()->GetXSize() ||
+       fileToBuild->GetYSize() != reread->GetFile()->GetYSize() ||
+       fileToBuild->GetZSize() != reread->GetFile()->GetZSize())
    {
       std::cout << "Failed" << std::endl
          << "        X Size differs: "
-         << "X: " << header->GetXSize() << " # " 
+         << "X: " << fileToBuild->GetXSize() << " # " 
                   << reread->GetFile()->GetXSize() << " | "
-         << "Y: " << header->GetYSize() << " # " 
+         << "Y: " << fileToBuild->GetYSize() << " # " 
                   << reread->GetFile()->GetYSize() << " | "
-         << "Z: " << header->GetZSize() << " # " 
+         << "Z: " << fileToBuild->GetZSize() << " # " 
                   << reread->GetFile()->GetZSize() << std::endl;
-      delete header;
+      delete fileToBuild;
       delete file;
       delete reread;
       delete[] imageData;
@@ -243,7 +244,7 @@ int WriteSimple(Image &img)
       std::cout << "Failed" << std::endl
          << "        Pixel areas lengths differ: "
          << size << " # " << dataSizeWritten << std::endl;
-      delete header;
+      delete fileToBuild;
       delete file;
       delete reread;
       delete[] imageData;
@@ -257,7 +258,7 @@ int WriteSimple(Image &img)
       (void)res;
       std::cout << "Failed" << std::endl
                 << "        Pixel differ (as expanded in memory)." << std::endl;
-      delete header;
+      delete fileToBuild;
       delete file;
       delete reread;
       delete[] imageData;
@@ -267,7 +268,7 @@ int WriteSimple(Image &img)
 
    std::cout << "OK" << std::endl;
 
-   delete header;
+   delete fileToBuild;
    delete file;
    delete reread;
    delete[] imageData;
@@ -275,7 +276,7 @@ int WriteSimple(Image &img)
    return 0;
 }
 
-int TestWriteSimple(int argc, charargv[])
+int TestWriteSimple(int argc, char *argv[])
 {
    if (argc < 1) 
    {