r98: finished object-orient convern of Scanner & Phantom
[ctsim.git] / src / if-2.cpp
index 29aef012299889f0a2cb6dcfbccc4c25db3e441c..89e6cc811d0528f11485c0b8a652abf93305c156 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: if-2.cpp,v 1.4 2000/06/13 16:20:31 kevin Exp $
+**  $Id: if-2.cpp,v 1.5 2000/06/18 10:27:11 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
@@ -26,7 +26,7 @@
 ******************************************************************************/
 
 /* FILE
- *   sdf-2.c         Generate a SDF file from two input SDF files
+ *   if-2.c         Generate a IF file from two input IF files
  */
 
 #include "ct.h"
@@ -46,25 +46,25 @@ static struct option my_options[] =
 };
 
 void 
-sdf2_usage (const char *program)
+if2_usage (const char *program)
 {
-  fprintf(stdout, "sdf2_usage: %s infile1 infile2 outfile [OPTIONS]\n", fileBasename(program));
-  fprintf(stdout, "Generate an SDF2D file from two input SDF2D files\n");
-  fprintf(stdout, "\n");
-  fprintf(stdout, "     infile1    Name of first input SDF file\n");
-  fprintf(stdout, "     infile2    Name of second input SDF file\n");
-  fprintf(stdout, "     outfile    Name of output SDF file\n");
-  fprintf(stdout, "     --add      Add images\n");
-  fprintf(stdout, "     --sub      Subtract image 2 from image 1\n");
-  fprintf(stdout, "     --mul      Multiply images\n");
-  fprintf(stdout, "     --comp     Compare images\n");
-  fprintf(stdout, "     --verbose  Verbose modem\n");
-  fprintf(stdout, "     --version  Print version\n");
-  fprintf(stdout, "     --help     Print this help message\n");
+  cout << "usage: " << fileBasename(program) << " infile1 infile2 outfile [OPTIONS]" << endl;
+  cout << "Generate an image file from two input image files files" << endl;
+  cout << endl;
+  cout << "     infile1    Name of first input IF file" << endl;
+  cout << "     infile2    Name of second input IF file" << endl;
+  cout << "     outfile    Name of output IF file" << endl;
+  cout << "     --add      Add images" << endl;
+  cout << "     --sub      Subtract image 2 from image 1" << endl;
+  cout << "     --mul      Multiply images" << endl;
+  cout << "     --comp     Compare images" << endl;
+  cout << "     --verbose  Verbose modem" << endl;
+  cout << "     --version  Print version" << endl;
+  cout << "     --help     Print this help message" << endl;
 }
 
 int 
-sdf2_main (int argc, char *const argv[])
+if2_main (int argc, char *const argv[])
 {
   ImageFile* pim_in1;
   ImageFile* pim_in2;
@@ -102,23 +102,23 @@ sdf2_main (int argc, char *const argv[])
       break;
     case O_VERSION:
 #ifdef VERSION
-      fprintf(stdout, "Version %s\n", VERSION);
+      cout << "Version " << VERSION << endl;
 #else
-      fprintf(stderr, "Unknown version number");
+      cout << "Unknown version number" << endl;
 #endif
-      exit(0);
+      return (0);
     case O_HELP:
     case '?':
-      sdf2_usage(argv[0]);
+      if2_usage(argv[0]);
       return (0);
     default:
-      sdf2_usage(argv[0]);
+      if2_usage(argv[0]);
       return (1);
     }
   }
   
   if (optind + 3 != argc) {
-    sdf2_usage(argv[0]);
+    if2_usage(argv[0]);
     return (1);
   }
   
@@ -137,12 +137,12 @@ sdf2_main (int argc, char *const argv[])
   }
 
   if (im_in1.nx() != im_in2.nx() || im_in1.ny() != im_in2.ny()) {
-    fprintf(stderr, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match\n",
+    sys_error (ERR_SEVERE, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match",
            im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
     return(1);
   }
   if (im_in1.nx() < 0 || im_in1.ny() < 0) {
-      fprintf(stderr, "Error: Size of image < 0");
+      sys_error (ERR_SEVERE, "Error: Size of image < 0");
       return(1);
   }
 
@@ -199,7 +199,7 @@ sdf2_main (int argc, char *const argv[])
       }
     }
     abs_error /= (im_in1.nx() * im_in1.ny());
-    fprintf(stdout, "Average Error = %f\n", abs_error);
+    cout << "Average Error: " << abs_error << endl;
   }
 
   im_out.arrayDataWrite();
@@ -216,7 +216,7 @@ sdf2_main (int argc, char *const argv[])
 int 
 main (int argc, char *const argv[])
 {
-  return (sdf2_main(argc, argv));
+  return (if2_main(argc, argv));
 }
 #endif