]> Creatis software - clitk.git/blobdiff - vv/vvImageWriter.txx
several 4D sequences allowed resulting in several 4D mhd files
[clitk.git] / vv / vvImageWriter.txx
index a62578f7d961e9060a8ccdf326bf358ddb7afdcc..66e9d0300d4420332853095deb97320753960549 100644 (file)
@@ -1,7 +1,7 @@
 /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
-  Authors belong to: 
+  Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 ======================================================================-====*/
 #ifndef vvImageWriter_TXX
 #define vvImageWriter_TXX
+
 #include <itkImageFileWriter.h>
 #include "vvToITK.h"
+#include "clitkDD.h"
 
 //====================================================================
 template<unsigned int VImageDimension>
 void vvImageWriter::UpdateWithDim(std::string OutputPixelType)
 {
-    if (OutputPixelType == "short")
-    {
-        UpdateWithDimAndOutputPixelType<short,VImageDimension>();
-    }
-    else if (OutputPixelType == "unsigned short")
-    {
-        UpdateWithDimAndOutputPixelType<unsigned short,VImageDimension>();
-    }
-    else if (OutputPixelType == "unsigned_short")
-    {
-        UpdateWithDimAndOutputPixelType<unsigned short,VImageDimension>();
-    }
-    else if (OutputPixelType == "char")
-    {
-        UpdateWithDimAndOutputPixelType<char,VImageDimension>();
-    }
-    else if (OutputPixelType == "unsigned_char")
-    {
-        UpdateWithDimAndOutputPixelType<unsigned char,VImageDimension>();
-    }
-    else if (OutputPixelType == "int")
-    {
-        UpdateWithDimAndOutputPixelType<int,VImageDimension>();
-    }
-    else if (OutputPixelType == "double")
-    {
-        UpdateWithDimAndOutputPixelType<double,VImageDimension>();
-    }
-    else if (OutputPixelType == "float")
-    {
-        UpdateWithDimAndOutputPixelType<float,VImageDimension>();
-    }
-    else
-    {
-        std::cerr << "Error, output pixel type : \"" << OutputPixelType << "\" unknown !" << std::endl;
-    }
+  if (OutputPixelType == "short") {
+    UpdateWithDimAndOutputPixelType<short,VImageDimension>();
+  } else if (OutputPixelType == "unsigned short") {
+    UpdateWithDimAndOutputPixelType<unsigned short,VImageDimension>();
+  } else if (OutputPixelType == "unsigned_short") {
+    UpdateWithDimAndOutputPixelType<unsigned short,VImageDimension>();
+  } else if (OutputPixelType == "char") {
+    UpdateWithDimAndOutputPixelType<char,VImageDimension>();
+  } else if (OutputPixelType == "unsigned_char") {
+    UpdateWithDimAndOutputPixelType<unsigned char,VImageDimension>();
+  } else if (OutputPixelType == "int") {
+    UpdateWithDimAndOutputPixelType<int,VImageDimension>();
+  } else if (OutputPixelType == "double") {
+    UpdateWithDimAndOutputPixelType<double,VImageDimension>();
+  } else if (OutputPixelType == "float") {
+    UpdateWithDimAndOutputPixelType<float,VImageDimension>();
+  } else {
+    std::cerr << "Error, output pixel type : \"" << OutputPixelType << "\" unknown !" << std::endl;
+  }
 }
 //====================================================================
 
@@ -67,26 +52,25 @@ void vvImageWriter::UpdateWithDim(std::string OutputPixelType)
 template<class OutputPixelType, unsigned int VImageDimension>
 void vvImageWriter::UpdateWithDimAndOutputPixelType()
 {
-    //Create the writer
-    typedef itk::Image< OutputPixelType, VImageDimension > OutputImageType;
-    typedef itk::ImageFileWriter<OutputImageType> WriterType;
-    typename WriterType::Pointer writer = WriterType::New();
-    writer->SetFileName(mOutputFilename);
-    writer->SetInput(vvImageToITK<OutputImageType>(mImage));
-    if (mUseAnObserver) {
-        writer->AddObserver(itk::ProgressEvent(), mObserver);
-    }
-    try {
-        writer->Update();
-    }
-    catch ( itk::ExceptionObject & err ) {
-        std::cerr << "Error while reading " << mOutputFilename.c_str()
-                  << " " << err << std::endl;
-        std::stringstream error;
-        error << err;
-        mLastError = error.str();
-        return;
-    }
+  //Create the writer
+  typedef itk::Image< OutputPixelType, VImageDimension > OutputImageType;
+  typedef itk::ImageFileWriter<OutputImageType> WriterType;
+  typename WriterType::Pointer writer = WriterType::New();
+  writer->SetFileName(mOutputFilename);
+  writer->SetInput(vvImageToITK<OutputImageType>(mImage));
+  if (mUseAnObserver) {
+    writer->AddObserver(itk::ProgressEvent(), mObserver);
+  }
+  try {
+    writer->Update();
+  } catch ( itk::ExceptionObject & err ) {
+    std::cerr << "Error while reading " << mOutputFilename.c_str()
+              << " " << err << std::endl;
+    std::stringstream error;
+    error << err;
+    mLastError = error.str();
+    return;
+  }
 }
 //====================================================================