]> Creatis software - clitk.git/blobdiff - common/clitkCommon.h
BUG seed_arg was used instead of seedRadius_arg
[clitk.git] / common / clitkCommon.h
index 44f9940a16189ce6814ec76174db5282bacacc18..11a6255955e8b2185c25b49334bd64158d58a8dc 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to: 
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
 
 #ifndef CLITKCOMMON_H
 #define CLITKCOMMON_H
 #  include <windows.h>
 #endif
 
+#if ITK_VERSION_MAJOR < 4
+namespace itk
+{
+  typedef unsigned int ThreadIdType;
+}
+#endif
+
 //--------------------------------------------------------------------
 namespace clitk {
 
   typedef unsigned char uchar;
   typedef unsigned short ushort;
   typedef unsigned int uint;
+  
+#define CLITK_TRY_CATCH_EXIT(func) \
+  try { \
+    func; \
+  } \
+  catch (const itk::ExceptionObject& e) { \
+    e.Print(std::cout); \
+    exit(-1);\
+  } \
+  catch (const std::exception& e) { \
+    std::cout << e.what() << std::endl; \
+    exit(-2);\
+  } \
+  catch (...) { \
+    std::cout << "Unknown excpetion" << std::endl; \
+    exit(-3); \
+  }
+    
 
   //--------------------------------------------------------------------
   // when everything goes wrong
@@ -209,6 +234,13 @@ namespace clitk {
   //--------------------------------------------------------------------
   void PrintMemoryUsed();
 
+  //--------------------------------------------------------------------
+  // Convert a map to a vector
+  template <typename M, typename V> 
+  void MapToVecFirst(const M & m, V & v);
+  template <typename M, typename V> 
+  void MapToVecSecond(const M & m, V & v);
+
 #include "clitkCommon.txx"
 
 } // end namespace