r117: *** empty log message ***
[ctsim.git] / src / ctrec.cpp
index 42dadc0ca9310632c665eefc34465e26c9ad75b2..39688cfb817e74967519ceff0de6100b60c1385f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctrec.cpp,v 1.11 2000/06/18 10:27:11 kevin Exp $
+**  $Id: ctrec.cpp,v 1.13 2000/06/22 10:17:28 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -112,10 +112,10 @@ ctrec_main (int argc, char * argv[])
   int opt_debug = 0;
   int opt_trace = TRACE_NONE;
   double opt_filter_param = 1;
-  FilterType opt_filter = FILTER_ABS_BANDLIMIT;
-  InterpolationType opt_interp = I_LINEAR;
+  string optFilterName = "abs_bandlimit";
+  string optInterpName = "linear";
+  string optBackprojName = "idiff2";
   int opt_interp_param = 1;
-  BackprojType opt_backproj = O_BPROJ_DIFF2;
   int nx, ny;
 #ifdef HAVE_MPI
   ImageFile *imLocal;
@@ -139,22 +139,13 @@ ctrec_main (int argc, char * argv[])
       switch (c)
        {
        case O_INTERP:
-         if ((opt_interp = opt_set_interpolation(optarg)) < 0) {
-           ctrec_usage(argv[0]);
-           return (1);
-         }
+         optInterpName = optarg;
          break;
        case O_FILTER:
-         if ((opt_filter = opt_set_filter(optarg)) < 0) {
-           ctrec_usage(argv[0]);
-           return (1);
-         }
+         optFilterName = optarg;
          break;
        case O_BACKPROJ:
-         if ((opt_backproj = opt_set_backproj(optarg)) < 0) {
-             ctrec_usage(argv[0]);
-             return (1);
-         }
+         optBackprojName = optarg;
          break;
        case O_FILTER_PARAM:
          opt_filter_param = strtod(optarg, &endptr);
@@ -176,11 +167,11 @@ ctrec_main (int argc, char * argv[])
          break;
         case O_VERSION:
 #ifdef VERSION
-       cout <<  "Version " <<  VERSION << endl;
+         cout <<  "Version " <<  VERSION << endl;
 #else
-        cout << "Unknown version number" << endl;
+          cout << "Unknown version number" << endl;
 #endif
-         exit(0);
+         return (0);
        case O_HELP:
        case '?':
          ctrec_usage(argv[0]);
@@ -203,14 +194,14 @@ ctrec_main (int argc, char * argv[])
     nx = strtol(argv[optind + 2], &endptr, 10);
     ny = strtol(argv[optind + 3], &endptr, 10);
   
-    ostringstream filt_name;
-    if (opt_filter == FILTER_G_HAMMING || opt_filter == FILTER_ABS_G_HAMMING)
-      filt_name << name_of_filter (opt_filter) << ": alpha=" << opt_filter_param; 
+    ostringstream filterDesc;
+    if (opt_filter_param >= 0)
+      filterDesc << optFilterName << ": alpha=" << opt_filter_param; 
     else
-      filt_name << name_of_filter (opt_filter);
-  
+      filterDesc << optFilterName;
+
     ostringstream label;
-    label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name.str() << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
+    label << "Reconstruct: " << nx << "x" << ny << ", " << filterDesc.str() << ", " << optInterpName << ", " << optBackprojName;
     remark = label.str();
   
     if (opt_verbose)
@@ -233,14 +224,14 @@ ctrec_main (int argc, char * argv[])
   }
 
   TimerCollectiveMPI timerBcast (mpiWorld.getComm());
+  mpiWorld.BcastString (optBackprojName);
+  mpiWorld.BcastString (optFilterName);
+  mpiWorld.BcastString (optInterpName);
   mpiWorld.getComm().Bcast (&opt_verbose, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&opt_debug, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0);
-  mpiWorld.getComm().Bcast (&opt_filter, 1, MPI::INT, 0);
-  mpiWorld.getComm().Bcast (&opt_interp, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
   mpiWorld.getComm().Bcast (&opt_interp_param, 1, MPI::INT, 0);
-  mpiWorld.getComm().Bcast (&opt_backproj, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&mpi_ndet, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&mpi_nview, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&mpi_detinc, 1, MPI::DOUBLE, 0);
@@ -280,7 +271,7 @@ ctrec_main (int argc, char * argv[])
 
 #ifdef HAVE_MPI
   TimerCollectiveMPI timerReconstruct (mpiWorld.getComm());
-  proj_reconst (*imLocal, projLocal, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace);
+  projLocal.reconstruct (*imLocal, optFilterName.c_str(), opt_filter_param, optInterpName.c_str(), opt_interp_param, optBackprojName.c_str(), opt_trace);
   if (opt_verbose)
       timerReconstruct.timerEndAndReport ("Time to reconstruct");
 
@@ -289,7 +280,7 @@ ctrec_main (int argc, char * argv[])
   if (opt_verbose)
       timerReduce.timerEndAndReport ("Time to reduce image");
 #else
-  proj_reconst (*imGlobal, projGlobal, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace);
+  projGlobal.reconstruct (*imGlobal, optFilterName.c_str(), opt_filter_param, optInterpName.c_str(), opt_interp_param, optBackprojName.c_str(), opt_trace);
 #endif
 
 #ifdef HAVE_MPI
@@ -370,7 +361,17 @@ ReduceImageMPI (MPIWorld& mpiWorld, ImageFile* imLocal, ImageFile* imGlobal)
 int 
 main (int argc, char* argv[])
 {
-  return (ctrec_main(argc, argv));
+  int retval = 1;
+
+  try {
+    retval = ctrec_main(argc, argv);
+  } catch (exception e) {
+    cerr << "Exception: " << e.what() << endl;
+  } catch (...) {
+    cerr << "Unknown exception" << endl;
+  }
+
+  return (retval);
 }
 #endif