]> Creatis software - clitk.git/blobdiff - common/clitkCommon.cxx
Account for ITK image direction
[clitk.git] / common / clitkCommon.cxx
index 7afeb074e4da048bdc4af1a9b6ae0e429c09dcd8..df47f51ab943d3ed55177569165d9a8fd4c24306 100644 (file)
 #ifndef CLITKCOMMON_CXX
 #define CLITKCOMMON_CXX
 
+// clitk include 
 #include "clitkCommon.h"
+
+// std include 
 #include <fstream>
 #include <iomanip>
 #include <sstream>
+#include <cerrno>
 
 //------------------------------------------------------------------
 // skip line which begin with a sharp '#'
@@ -240,7 +244,9 @@ void clitk::openFileForReading(std::ifstream & is, const std::string & filename)
 {
   is.open(filename.c_str(), std::ios::in);
   if ( is.fail() ) {
-    clitkExceptionMacro("Could not open file (for reading): " << filename);
+    clitkExceptionMacro("Could not open file for reading: " 
+                        << filename << ". Error is : <" 
+                        << strerror(errno) << ">");
   }
 }
 //--------------------------------------------------------------------
@@ -251,7 +257,9 @@ void clitk::openFileForWriting(std::ofstream & os, const std::string & filename)
 {
   os.open(filename.c_str(), std::ios::out);
   if ( os.fail() ) {
-    clitkExceptionMacro("Could not open file (for writing): " << filename);
+    clitkExceptionMacro("Could not open file for writing: " 
+                        << filename << ". Error is : <" 
+                        << strerror(errno) << ">");
   }
 }
 //--------------------------------------------------------------------
@@ -308,5 +316,20 @@ void clitk::readDoubleFromFile(const std::string & filename, std::vector<double>
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+void clitk::PrintMemoryUsed()
+{
+#if defined(unix) || defined(__APPLE__)
+  rusage usage;  
+  getrusage(RUSAGE_SELF, &usage);
+  DD(usage.ru_maxrss);        /* maximum resident set size */ 
+  // DD(usage.ru_ixrss);         /* integral shared memory size */
+  // DD(usage.ru_idrss);         /* integral unshared data size */
+  // DD(usage.ru_isrss);         /* integral unshared stack size */
+#endif
+}
+//--------------------------------------------------------------------
+
+
 #endif /* end #define CLITKCOMMON_CXX */