]> Creatis software - clitk.git/blob - common/clitkFilterMacros.txx
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / common / clitkFilterMacros.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ===========================================================================**/
18
19 #define GGO_DefineOption_Vector(OPTION, FUNC, TYPE, NB, BOOL)           \
20   template<class ArgsInfoType>                                          \
21   void FUNC##_GGO(ArgsInfoType & mArgsInfo) {                           \
22     if (mArgsInfo.OPTION##_given == NB) {                               \
23       TYPE aaa;                                                         \
24       for(unsigned int i=0; i<NB; i++) {                                \
25         aaa[i] = mArgsInfo.OPTION##_arg[i];                             \
26       }                                                                 \
27       VerboseOption(#FUNC, mArgsInfo.OPTION##_given, mArgsInfo.OPTION##_arg); \
28       FUNC(aaa);                                                        \
29     }                                                                   \
30     else {                                                              \
31       if (BOOL && mArgsInfo.OPTION##_given != 0) {                      \
32         std::cerr << "Sorry, you give only " << mArgsInfo.OPTION##_given << " while " \
33                   << NB << " values a required for option '" << #OPTION << "'" << std::endl; \
34         exit(0);                                                        \
35       }                                                                 \
36     }                                                                   \
37   }
38
39 #define GGO_DefineOption_Multiple(OPTION, FUNC, TYPE)                   \
40   template<class ArgsInfoType>                                          \
41   void FUNC##_GGO(ArgsInfoType & mArgsInfo) {                           \
42     VerboseOption(#OPTION, mArgsInfo.OPTION##_given, mArgsInfo.OPTION##_arg); \
43     for(unsigned int i=0; i<mArgsInfo.OPTION##_given; i++) {            \
44       FUNC(mArgsInfo.OPTION##_arg[i]);                                  \
45     }                                                                   \
46   }
47
48 #define GGO_DefineOption(OPTION, FUNC, TYPE)            \
49   template<class ArgsInfoType>                          \
50   void FUNC##_GGO(ArgsInfoType & mArgsInfo) {           \
51     VerboseOption(#OPTION, mArgsInfo.OPTION##_arg);     \
52     FUNC(static_cast<TYPE>(mArgsInfo.OPTION##_arg));    \
53   }
54
55 #define GGO_DefineOption_Flag(OPTION, FUNC)              \
56   template<class ArgsInfoType>                           \
57   void FUNC##_GGO(ArgsInfoType & mArgsInfo) {            \
58     VerboseOption(#OPTION, mArgsInfo.OPTION##_flag);     \
59     FUNC(mArgsInfo.OPTION##_flag);    \
60   }
61
62 #define GGO_DefineOption_WithTest(OPTION, FUNC, TYPE, TEST)             \
63   template<class ArgsInfoType>                                          \
64   void FUNC##_GGO(ArgsInfoType & mArgsInfo) {                           \
65     VerboseOption(#OPTION, mArgsInfo.OPTION##_given, mArgsInfo.OPTION##_arg); \
66     if (mArgsInfo.OPTION##_given) {                                     \
67       VerboseOption(#OPTION, mArgsInfo.OPTION##_arg);                   \
68       FUNC(static_cast<TYPE>(mArgsInfo.OPTION##_arg));                  \
69       TEST##On();                                                       \
70     }                                                                   \
71     else TEST##Off();                                                   \
72   }
73
74 #define GGO_DefineOption_LabelParam(OPTION, FUNC, TYPE)                 \
75   template<class ArgsInfoType>                                          \
76   void FUNC##_GGO(ArgsInfoType & mArgsInfo) {                           \
77     TYPE * param = new TYPE;                                            \
78     param->SetFirstKeep(mArgsInfo.firstKeep##OPTION##_arg);             \
79     for(unsigned int i=0; i<mArgsInfo.remove##OPTION##_given; i++)      \
80       param->AddLabelToRemove(mArgsInfo.remove##OPTION##_arg[i]);       \
81     if (mArgsInfo.lastKeep##OPTION##_given) {                           \
82       param->SetLastKeep(mArgsInfo.lastKeep##OPTION##_arg);             \
83       param->UseLastKeepOn();                                           \
84     }                                                                   \
85     else param->UseLastKeepOff();                                       \
86     VerboseOption("firstKeep"#OPTION, mArgsInfo.firstKeep##OPTION##_arg); \
87     VerboseOption("lastKeep"#OPTION, mArgsInfo.lastKeep##OPTION##_given, mArgsInfo.lastKeep##OPTION##_arg ); \
88     VerboseOptionV("remove"#OPTION, mArgsInfo.remove##OPTION##_given, mArgsInfo.remove##OPTION##_arg); \
89     FUNC(param);                                                        \
90   }
91