X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=11a6255955e8b2185c25b49334bd64158d58a8dc;hb=578e4e5a84a390592ba6b2a7e8bff22dba19ccd0;hp=31f28dc40637bd95e91dfec7974f23183edd43ac;hpb=765020625fbc092d283e221e36c83e60a1844cb7;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 31f28dc..11a6255 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -42,12 +42,37 @@ # include #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 + void MapToVecFirst(const M & m, V & v); + template + void MapToVecSecond(const M & m, V & v); + #include "clitkCommon.txx" } // end namespace