]> Creatis software - clitk.git/commitdiff
cleanup / better handling of errors
authorschaerer <schaerer>
Tue, 9 Feb 2010 10:27:54 +0000 (10:27 +0000)
committerschaerer <schaerer>
Tue, 9 Feb 2010 10:27:54 +0000 (10:27 +0000)
19 files changed:
common/clitkImageCommon.cxx
common/clitkImageCommon.h
common/clitkTransformUtilities.h
common/old/clitkIOCommon.cxx [moved from common/clitkIOCommon.cxx with 94% similarity]
common/old/clitkIOCommon.h [moved from common/clitkIOCommon.h with 100% similarity]
common/old/clitkIOCommon.txx [moved from common/clitkIOCommon.txx with 100% similarity]
fast_make.sh
itk/clitkForwardWarpImageFilter.h
itk/clitkForwardWarpImageFilter.txx
itk/clitkGenericInterpolator.h
itk/clitkGenericVectorInterpolator.h
itk/clitkInvertVFFilter.h
tools/clitkSignalFilter.cxx
tools/clitkSignalMeanPositionTracking.cxx
tools/clitkVFMerge.cxx
tools/clitkZeroVF.cxx
tools/clitkZeroVFGenericFilter.h
vv/vvMainWindow.cxx
vv/vvQProgressDialogITKCommand.cxx

index 056df9450113ff30532c9eae7cb5ba6adb7ac833..cc211993d8abfc42bb14abeefeca56e3772b94ac 100644 (file)
@@ -78,10 +78,18 @@ gdcm::File * clitk::readDicomHeader(const std::string & filename,
 //--------------------------------------------------------------------
 
 //--------------------------------------------------------------------
-itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename) {
+itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, bool exit_on_error) {
   itk::ImageIOBase::Pointer reader =
     itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode);
-  if (!reader) return NULL;
+  if (!reader) {
+      if (exit_on_error) //default behavior for tools who don't handle the problem
+      {
+          std::cerr << "Error reading file " << filename << ", exiting immediately" << std::endl;
+          std::exit(-1);
+      }
+      else
+          return NULL;
+  }
   reader->SetFileName(filename);
   reader->ReadImageInformation();
   return reader;
index 53e1be6186347b6b8f2a9d7929811d2ab0f46195..87d01de8f6c8cf29b8cf742d4b6e90700c6dcf0b 100644 (file)
@@ -56,7 +56,7 @@ namespace clitk {
 
   //--------------------------------------------------------------------
   // Read/print image header
-  itk::ImageIOBase::Pointer readImageHeader(const std::string & filename);
+  itk::ImageIOBase::Pointer readImageHeader(const std::string & filename,bool exit_on_error=true);
   void printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os, const int level=0);
 
   //--------------------------------------------------------------------
index c8d100c30c7e405e26fc798d81eadd45c4a75dc5..8a23f9b98b7bf531513b540a57461585be13646d 100644 (file)
@@ -4,7 +4,7 @@
 #include "itkMatrix.h"
 #include "itkArray.h"
 #include "itkPoint.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 #include "clitkCommon.h"
  
  
similarity index 94%
rename from common/clitkIOCommon.cxx
rename to common/old/clitkIOCommon.cxx
index 16ec36127d677b7b3cf377d0b32f007666dddf17..be69d374edfa5caad8f08db2a7b1c689a99d37f4 100644 (file)
@@ -28,7 +28,8 @@ PURPOSE.  See the above copyright notices for more information.
    =================================================*/
 
 // clitk include
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
+#include <cstdlib>
 
 //====================================================================
 // Open a file for reading
@@ -66,10 +67,17 @@ gdcm::File * clitk::readDicomHeader(const std::string & filename,
 //====================================================================
 
 //====================================================================
-itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename) {
+itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, bool exit_on_error) {
   itk::ImageIOBase::Pointer reader =
     itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode);
-  if (!reader) return NULL;
+  if (!reader) 
+      if (exit_on_error) //default behavior for tools who don't handle the problem
+      {
+          std::cerr "Error reading file " << filename << ", exiting immediately" << std::endl;
+          std::exit(-1);
+      }
+      else
+          return NULL;
   reader->SetFileName(filename);
   reader->ReadImageInformation();
   return reader;
index 471562c515aa0da35d00b7f21ff2298046409d57..9309c87faaa5dfe660dd17662685d4be2b24860e 100755 (executable)
@@ -29,8 +29,9 @@ else #use all the available computing power by default
     cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 0 ))
 fi
 
-make -j ${cpus} $@ &
-make_pid=$(jobs -p %make)
+nice -n12 ionice -c3 make -j ${cpus} $@ &
+make_pid=$(jobs -p %nice)
+
 #watch memory use to avoid crashes
 while ps $make_pid >>/dev/null 
 do
index a02c9e5937b25ce52a40e17b3a307ce5287db5b4..86b33302ef47a0a23fe090e09c89342fbfee677d 100644 (file)
@@ -2,7 +2,7 @@
 #define __clitkForwardWarpImageFilter_h
 
 //clitk include
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 //itk include
 #include "itkImageToImageFilter.h"
index 9ea647e0c80e1bc6a551aefe185471e0f97570ac..165fe4fb231dfa0e5c572622d8a3130198a1061c 100644 (file)
@@ -2,7 +2,7 @@
 #define __clitkForwardWarpImageFilter_txx
 
 #include "clitkForwardWarpImageFilter.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 // Put the helper classes in an anonymous namespace so that it is not
 // exposed to the user
index 4ce15f60861467d0647ff500b02e1a731c080234..d9adde9f2be532dc2ee7c4f3f353eb34e71b49df 100644 (file)
@@ -2,7 +2,7 @@
 #define __clitkGenericInterpolator_h
 
 //clitk include
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 //itk include
 #include "itkNearestNeighborInterpolateImageFunction.h"
index ffb7171a53d6ca7c8a9202cab7e6bf5fffa859e5..afeeb674f4a12ae436ab5b153f490ee3bb453deb 100644 (file)
@@ -2,7 +2,7 @@
 #define __clitkGenericVectorInterpolator_h
 
 //clitk include
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 //itk include
 #include "itkVectorNearestNeighborInterpolateImageFunction.h"
index 039dc9197aefac257dae7ae434c83f3614176cde..947f157e889e5041daec29144d0fdcc96933f8d4 100644 (file)
@@ -2,7 +2,7 @@
 #define __clitkInvertVFFilter_h
 
 //clitk include
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 #include "itkImageToImageFilter.h"
 #include "itkImage.h"
index 0ac3db4d71dfd89e0f83c98026bc882db044f3e0..0a833f3133e8263216024bcb63f31cbcac847c90 100644 (file)
@@ -28,7 +28,7 @@
 #include "clitkSignalFilter_ggo.h"
 #include "clitkSignal.h"
 #include "clitkIO.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 int main(int argc, char * argv[]) {
 
index ae6a5ec994c2d03e6d512415016538831242a6fe..e63e9296c53bb088ace2d9ba53eb60614ccd1386 100644 (file)
@@ -28,7 +28,7 @@
 #include "clitkSignalMeanPositionTracking_ggo.h"
 #include "clitkSignalMeanPositionFilter.h"
 #include "clitkIO.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 int main(int argc, char * argv[]) {
 
index fa0a75e14e287ee258769b8c283708c2cf1bad6b..f8c072bbc9eb9d0c10cc2af8abbe9538a6356e2c 100644 (file)
@@ -14,7 +14,7 @@
 // clitk include
 #include "clitkVFMerge_ggo.h"
 #include "clitkIO.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 
 // itk include
 //#include "itkReadTransform.h"
index ab1dc899ff585f79487be7656191c5fae761abcf..50a91e90c9c7315f3d969d4f8c96ee21c0442776 100644 (file)
@@ -14,7 +14,7 @@
 // clitk include
 #include "clitkZeroVF_ggo.h"
 #include "clitkIO.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 #include "clitkZeroVFGenericFilter.h"
 
 int main( int argc, char *argv[] )
index 8bde1edc10071bed99c74f5e6d844adbca012052..ba894cd0a4c0ba9488f726f299aa609493aa4901 100644 (file)
@@ -2,7 +2,7 @@
 #define __clitkZeroVFGenericFilter_h
 
 //clitk include
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 #include "clitkImageCommon.h"
 
 //itk include
index 5473980f452abe3ecf85a490b898d859313a081c..c252b6ffcb7a8b6a011126959434d4c77bf35b07 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvMainWindow.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/02/07 12:00:59 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2010/02/09 10:28:07 $
+  Version:   $Revision: 1.10 $
   Author :   Pierre Seroul (pierre.seroul@gmail.com)
 
   Copyright (C) 200COLUMN_IMAGE_NAME
@@ -39,7 +39,7 @@
 #include "vvProgressDialog.h"
 #include "vvQDicomSeriesSelector.h"
 #include "vvSlicerManager.h"
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 #include "vvSlicer.h"
 #include "vvInteractorStyleNavigator.h"
 #include "vvImageWriter.h"
index 089775c23c4ec3ee21e98b79ea8632a8345de327..44fe9108eb77e72e195c7cc180f8500716c178b8 100644 (file)
@@ -24,7 +24,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef VVQPROGRESSDIALOGITKCOMMAND_CXX
 #define VVQPROGRESSDIALOGITKCOMMAND_CXX
 
-#include "clitkIOCommon.h"
+#include "clitkImageCommon.h"
 #include "vvQProgressDialogITKCommand.h"
 
 //====================================================================