X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=97808d8d870ba778887a8ba98542cd3ea7ddf8b5;hb=5bff4d89c8ca42336267c36974e9ceb6fe2ac843;hp=00a32cfea64f4d76bcd3938c4f1fedcd4360edf1;hpb=0350f04002063f12dcf10ee765f5389590f352e7;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 00a32cf..97808d8 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -1,29 +1,28 @@ -#ifndef CLITKCOMMON_H -#define CLITKCOMMON_H +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv -/** - ------------------------------------------------------------------- - * @file clitkCommon.h - * @author David Sarrut - * @date 17 May 2006 07:57:56 + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - * @brief + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. - -------------------------------------------------------------------*/ + It is distributed under dual licence -// std include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include + - 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 + +// clitk include +#include "clitkPortability.h" +#include "clitkDD.h" +#include "clitkExceptionObject.h" // itk include (include std) #include @@ -31,22 +30,25 @@ #include #include +// std include +#include + +// Include for "rusage" +#include +#if defined(unix) || defined(__APPLE__) +# include +# include +#elif defined(WIN32) +# include +#endif + //-------------------------------------------------------------------- namespace clitk { - -#if defined(WIN32) -#define lrint(x) (floor(x+(x>0) ? 0.5 : -0.5)) -#endif - + typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; - //-------------------------------------------------------------------- - // display -#define DD(a) std::cout << #a " = [ " << a << " ]" << std::endl; -#define DDV(a,n) { std::cout << #a " = [ "; for(unsigned int _i_=0; _i_ std::string toStringVector(const T * t, const int n); template std::string toStringVector(const T & t, const int n); template std::string toStringVector(const std::vector & t); + template bool fromString(T& t, + const std::string& s, + std::ios_base& (*f)(std::ios_base&)=std::dec); //-------------------------------------------------------------------- // Display a progress % @@ -186,6 +191,9 @@ namespace clitk { void openFileForReading(std::ifstream & is, const std::string & filename); void openFileForWriting(std::ofstream & os, const std::string & filename); + //-------------------------------------------------------------------- + void readDoubleFromFile(const std::string & filename, std::vector & list); + //-------------------------------------------------------------------- double cotan(double i); double invcotan(double i); @@ -198,6 +206,16 @@ namespace clitk { template void CloneImage(const typename ImageType::Pointer & input, typename ImageType::Pointer & output); + //-------------------------------------------------------------------- + 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