]> Creatis software - clitk.git/blobdiff - tools/clitkRelativePositionAnalyzer.cxx
Second version of clitkRelativePositionAnalyzer
[clitk.git] / tools / clitkRelativePositionAnalyzer.cxx
index 9b16e51515f9f4dadaf68e77f945464c77d69911..1e9541e368269e457789708386f9729b9938f6c7 100644 (file)
@@ -30,9 +30,33 @@ int main(int argc, char * argv[]) {
   // Filter
   typedef clitk::RelativePositionAnalyzerGenericFilter<args_info_clitkRelativePositionAnalyzer> FilterType;
   FilterType::Pointer filter = FilterType::New();
-  
+
+  // Set filename from the AFDB if needed
+#define SetOptionFromAFDBMacro(ARGS, OPTIONNAME, OPTION)                \
+  if (ARGS.OPTIONNAME##_given) {                                        \
+    if (ARGS.OPTION##_given) {                                          \
+      std::cerr << "Warning --"#OPTION" is ignored" << std::endl;       \
+    }                                                                   \
+    std::string f = afdb->GetTagValue(ARGS.OPTIONNAME##_arg);           \
+    f = std::string(args_info.afdb_path_arg)+"/"+f;                     \
+    filter->AddInputFilename(f);                                        \
+  }                                                                     \
+  else if (!ARGS.OPTION##_given) {                                      \
+    std::cerr << "Error on the command line please provide --"#OPTION" or --"#OPTIONNAME"." << std::endl; \
+    return EXIT_FAILURE;                                                \
+  }
+
+  // Set options
   filter->SetArgsInfo(args_info);
   
+  NewAFDB(afdb, args_info.afdb_arg);
+  // The order is important. If --supportName and --support are
+  // given, the first is set before, so the second ignored
+  SetOptionFromAFDBMacro(args_info, supportName, support);
+  SetOptionFromAFDBMacro(args_info, objectName, object);
+  SetOptionFromAFDBMacro(args_info, targetName, target);
+
+  // Go !
   try {
     filter->Update();
   } catch(std::runtime_error e) {