]> Creatis software - clitk.git/blobdiff - common/clitkCommon.cxx
Debug default value when dividing by 0 in clitkImageArithm
[clitk.git] / common / clitkCommon.cxx
index 10f608e6ce8b7ba7c92d6085f4d1b1588a047e3d..96980bbbb6b47f3c7c20106f0ef9dd0e2cabd09d 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef CLITKCOMMON_CXX
 #define CLITKCOMMON_CXX
 
+#include <itksys/SystemTools.hxx>
+
 // clitk include 
 #include "clitkCommon.h"
 
@@ -69,6 +71,24 @@ std::string clitk::GetExtension(const std::string& filename)
 } ////
 //------------------------------------------------------------------
 
+
+//------------------------------------------------------------------
+// Return filename splitting in 1 or 2 parts : directory name (if exists) & filename
+std::vector<std::string> clitk::SplitFilename(const std::string& filename)
+{
+  std::vector<std::string> dirname;
+  std::string path = itksys::SystemTools::GetFilenamePath(filename);
+  std::vector<std::string> pathComponents;
+  itksys::SystemTools::SplitPath(filename.c_str(), pathComponents);
+  std::string fileName = pathComponents.back();
+  if (path != "")
+    dirname.push_back(path);
+  dirname.push_back(fileName);
+  return( dirname );
+} ////
+//------------------------------------------------------------------
+
+
 //------------------------------------------------------------------
 // Display progression
 void clitk::VerboseInProgress(const int nb, const int current, const int percentage)
@@ -104,6 +124,15 @@ float clitk::PixelTypeDownCast(const double & x)
 }
 //------------------------------------------------------------------
 
+//------------------------------------------------------------------
+// Convert a pixel type without casting
+template<>
+double clitk::PixelTypeDownCast(const double & x)
+{
+  return x;
+}
+//------------------------------------------------------------------
+
 //------------------------------------------------------------------
 double clitk::rad2deg(const double anglerad)
 {