]> Creatis software - gdcm.git/blobdiff - Testing/VTKTestRead.cxx
use GDCM_NAME_SPACE:: instead of gdcm::, even in Examples ...
[gdcm.git] / Testing / VTKTestRead.cxx
index b4ba7ea1e4093b6a1cc40c5417b9154e14cd296e..4524aff436a7139ae437720cb5933dfd6ad8c46a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: VTKTestRead.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/19 13:50:11 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/09/15 15:49:21 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -15,7 +15,6 @@
      PURPOSE.  See the above copyright notices for more information.
                                                                                 
 =========================================================================*/
-#include "gdcmFile.h"
 #include "vtkGdcmReader.h"
 #include "vtkImageViewer.h"
 #include "vtkImageData.h"
 #include "vtkImageAppendComponents.h"
 #include "vtkImageShiftScale.h"
 
+#include "vtkPNGWriter.h"
+
 #include <iostream>
+#include <sstream>
 
 //Generated file:
 #include "gdcmDataImages.h"
 #endif
 
 int VTKReadTest(vtkTesting *t,vtkImageViewer *viewer,
-                std::string const & filename, 
-                std::string const & referenceFileName,
-                bool show )
+                std::string const &filename, 
+                std::string const &referenceFileName)
 {
-   int retVal = 0;  //by default this is an error
+   int retVal; // = 0; (to avoid bcc5.5 warnings)
 
    t->CleanArguments();
    t->AddArgument("-D");
@@ -49,21 +50,12 @@ int VTKReadTest(vtkTesting *t,vtkImageViewer *viewer,
    t->AddArgument("-T");
    t->AddArgument( "." );
    
-   // Instead of directly reading the dicom let's write it down to another file
-   // do a scope to be sure everything gets cleanup
-   {
-      gdcm::File file( filename );
-      file.GetImageData();
-      file.SetWriteModeToRaw();
-      file.WriteDcmExplVR( "TestWrite.dcm" );
-   }
-   // Ok for now still use the original image, 
    vtkGdcmReader *reader = vtkGdcmReader::New();
-   //reader->SetFileName( filename.c_str() );
-   reader->SetFileName( "TestWrite.dcm" );
+   reader->SetFileName( filename.c_str() );
    reader->Update();
 
+   double range[2];
+   reader->GetOutput()->GetScalarRange(range);
    int dim[3];
    reader->GetOutput()->GetDimensions( dim );
 
@@ -72,7 +64,6 @@ int VTKReadTest(vtkTesting *t,vtkImageViewer *viewer,
    {
       viewer->SetInput ( reader->GetOutput() );
 
-      vtkFloatingPointType *range = reader->GetOutput()->GetScalarRange();
       viewer->SetColorWindow (range[1] - range[0]);
       viewer->SetColorLevel (0.5 * (range[1] + range[0]));
 
@@ -125,13 +116,11 @@ int VTKReadTest(vtkTesting *t,vtkImageViewer *viewer,
 
    // Set an unsigned char image
    // Shift/Scale the image 
-   image->Update();
-   double *rng=image->GetScalarRange();
    vtkImageShiftScale *iss=vtkImageShiftScale::New();
    iss->SetInput(image);
    iss->SetOutputScalarTypeToUnsignedChar();
-   iss->SetShift(-rng[0]);
-   iss->SetScale(255.0/(rng[1]-rng[0]));
+   iss->SetShift(-range[0]);
+   iss->SetScale(255.0/(range[1]-range[0]));
    iss->ClampOverflowOn();
 
    image->UnRegister(NULL);
@@ -159,7 +148,7 @@ int VTKReadTest(vtkTesting *t,vtkImageViewer *viewer,
    //----------------------------------------------------------------------
 
    // make test
-   ostrstream str;
+   std::ostringstream str;
    retVal = t->RegressionTest(image,0.0,str);
    image->UnRegister(NULL);
 
@@ -167,7 +156,6 @@ int VTKReadTest(vtkTesting *t,vtkImageViewer *viewer,
    {
       std::cerr << str.str();
    }
-   str.rdbuf()->freeze(1);
 
    if( retVal == vtkTesting::PASSED )
    {
@@ -194,7 +182,7 @@ int VTKTestRead(int argc, char *argv[])
    }
 
    int ret = 0;
-   vtkTestingt = vtkTesting::New();
+   vtkTesting *t = vtkTesting::New();
    vtkImageViewer *viewer;
    if( show )
       viewer = vtkImageViewer::New();
@@ -209,13 +197,15 @@ int VTKTestRead(int argc, char *argv[])
    }
    else
    {
-      ret = VTKReadTest(t,viewer,argv[1+show],argv[2+show],show);
+      ret = VTKReadTest(t,viewer,argv[1+show],argv[2+show]);
       t->Delete();
       if( viewer )
          viewer->Delete();
 
       return ret;
    }
+   
+   //GDCM_NAME_SPACE::Debug::DebugOn(); // Comment out when no bug is to be tracked
 
    // Test for all images
    int i = 0;
@@ -235,7 +225,7 @@ int VTKTestRead(int argc, char *argv[])
       pngfile.insert( 0, "Baseline/");
       //std::cerr << "PNG file: " << pngfile << std::endl;
 
-      ret += VTKReadTest(t,viewer,filename,pngfile,show);
+      ret += VTKReadTest(t,viewer,filename,pngfile);
    }
    t->Delete();
    if( viewer )