]> Creatis software - clitk.git/blob - tools/clitkRelativePositionAnalyzer.cxx
Second version of clitkRelativePositionAnalyzer
[clitk.git] / tools / clitkRelativePositionAnalyzer.cxx
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 // clitk
20 #include "clitkRelativePositionAnalyzer_ggo.h"
21 #include "clitkRelativePositionAnalyzerGenericFilter.h"
22
23 //--------------------------------------------------------------------
24 int main(int argc, char * argv[]) {
25
26   // Init command line
27   GGO(clitkRelativePositionAnalyzer, args_info);
28   CLITK_INIT;
29
30   // Filter
31   typedef clitk::RelativePositionAnalyzerGenericFilter<args_info_clitkRelativePositionAnalyzer> FilterType;
32   FilterType::Pointer filter = FilterType::New();
33
34   // Set filename from the AFDB if needed
35 #define SetOptionFromAFDBMacro(ARGS, OPTIONNAME, OPTION)                \
36   if (ARGS.OPTIONNAME##_given) {                                        \
37     if (ARGS.OPTION##_given) {                                          \
38       std::cerr << "Warning --"#OPTION" is ignored" << std::endl;       \
39     }                                                                   \
40     std::string f = afdb->GetTagValue(ARGS.OPTIONNAME##_arg);           \
41     f = std::string(args_info.afdb_path_arg)+"/"+f;                     \
42     filter->AddInputFilename(f);                                        \
43   }                                                                     \
44   else if (!ARGS.OPTION##_given) {                                      \
45     std::cerr << "Error on the command line please provide --"#OPTION" or --"#OPTIONNAME"." << std::endl; \
46     return EXIT_FAILURE;                                                \
47   }
48
49   // Set options
50   filter->SetArgsInfo(args_info);
51   
52   NewAFDB(afdb, args_info.afdb_arg);
53   // The order is important. If --supportName and --support are
54   // given, the first is set before, so the second ignored
55   SetOptionFromAFDBMacro(args_info, supportName, support);
56   SetOptionFromAFDBMacro(args_info, objectName, object);
57   SetOptionFromAFDBMacro(args_info, targetName, target);
58
59   // Go !
60   try {
61     filter->Update();
62   } catch(std::runtime_error e) {
63     std::cout << e.what() << std::endl;
64     return EXIT_FAILURE;
65   }
66
67   return EXIT_SUCCESS;
68 } // This is the end, my friend
69 //--------------------------------------------------------------------