r98: finished object-orient convern of Scanner & Phantom
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 18 Jun 2000 10:27:11 +0000 (10:27 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 18 Jun 2000 10:27:11 +0000 (10:27 +0000)
include/byteorder.h
include/ct.h
include/ezplot.h
include/kmath.h
src/ctrec.cpp
src/if-1.cpp
src/if-2.cpp
src/if2img.cpp
src/ifinfo.cpp
src/phm2if.cpp
src/pj2if.cpp

index 187e4fb571ab292037f19847129a68f7285eecba..94fe9598dd6609de4de8f8279de87ab571d53232 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef NETORDER_H
 #define NETORDER_H
 
 #ifndef NETORDER_H
 #define NETORDER_H
 
+#include <iostream>
+
 /* netorder.cpp */
 
 /* netorder.cpp */
 
-void *strreverse (void *dest, const void *src, size_t n);
 bool read_nint16 (kuint16 *n, int fd);
 bool write_nint16 (kuint16 const *n, int fd);
 bool read_nint32 (kuint32 *n, int fd);
 bool read_nint16 (kuint16 *n, int fd);
 bool write_nint16 (kuint16 const *n, int fd);
 bool read_nint32 (kuint32 *n, int fd);
@@ -12,7 +13,32 @@ bool read_nfloat32 (float *f, int fd);
 bool write_nfloat32 (float const *f, int fd);
 bool read_nfloat64 (double *d, int fd);
 bool write_nfloat64 (double const *d, int fd);
 bool write_nfloat32 (float const *f, int fd);
 bool read_nfloat64 (double *d, int fd);
 bool write_nfloat64 (double const *d, int fd);
-void ConvertNetworkOrder (void* buffer, size_t bytes);
-void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+void  ConvertNetworkOrder (void* buffer, size_t bytes);
+void  ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+
+class inetorderstream : public istream {
+ public:
+    inetorderstream& readInt16 (kuint16& n);
+    inetorderstream& readInt32 (kuint32& n);
+    inetorderstream& readFloat32 (kfloat32& n);
+    inetorderstream& readFloat64 (kfloat64& n);
+};
+
+class onetorderstream : public ostream {
+ public:
+    onetorderstream& writeInt16 (kuint16 n);
+    onetorderstream& writeInt32 (kuint32 n);
+    onetorderstream& writeFloat32 (kfloat32 n);
+    onetorderstream& writeFloat64 (kfloat64 n);
+};
+
+void read_rnint16 (kuint16& n, istream istr);
+void write_rnint16 (kuint16 n, ostream ostr);
+void read_rnint32 (kuint32& n, istream istr);
+void write_rnint32 (kuint32 n, ostream ostr);
+void read_rnfloat32 (kfloat32& n, istream istr);
+void write_rnfloat32 (kfloat32 n, ostream ostr);
+void read_rnfloat64 (kfloat64& n, istream istr);
+void write_rnfloat64 (kfloat64 n, ostream ostr);
 
 #endif
 
 #endif
index 4817fb35424e7a736f680f7eabe2daee21b949b3..937a885bcfdbfc5b0473686e0cf5f0cb86dea51a 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ct.h,v 1.15 2000/06/17 20:12:14 kevin Exp $
+**  $Id: ct.h,v 1.16 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
 **
 **  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
@@ -125,6 +125,7 @@ extern "C" {
   #include "sgp.h"
 #endif
 
   #include "sgp.h"
 #endif
 
+#include <fstream>
 #include <iostream>
 #include <sstream>
 #include <string>
 #include <iostream>
 #include <sstream>
 #include <string>
index 744a33d42143d3bfa17afa1c349071ef799e61e5..4beb8ff58c2f6c19a45ebf86f8275eae06424ce0 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ezplot.h,v 1.5 2000/06/13 16:20:31 kevin Exp $
+**  $Id: ezplot.h,v 1.6 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
 **
 **  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
@@ -54,7 +54,7 @@ struct ezp_curve_st {
 };
 
 #define XBUF_DEF     600
 };
 
 #define XBUF_DEF     600
-#define YBUF_DEF     XBUF_DEF * (72. / 120.) * 0.75
+#define YBUF_DEF     600
 #define PRTMODE_DEF  1
 
 /*----------------------------------------------------------------------*/
 #define PRTMODE_DEF  1
 
 /*----------------------------------------------------------------------*/
index bb30f05d683f8caf073e37e742ef6bb5c706ed8f..0ed4f2a3cb3de6319d8dbd75fbfa7acbb1b2c667 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: kmath.h,v 1.14 2000/06/17 20:12:14 kevin Exp $
+**  $Id: kmath.h,v 1.15 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
 **
 **  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
@@ -68,6 +68,18 @@ template<class T>
 inline T lineLength (T x1, T y1, T x2, T y2)
 { return static_cast<T>( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); }
 
 inline T lineLength (T x1, T y1, T x2, T y2)
 { return static_cast<T>( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); }
 
+template<class T>
+inline void minmax_array (const T* array, const int n, T& min, T& max)
+{
+  max = min = array[0];
+
+  for (int i = 1; i < n; i++)
+    if (array[i] < min)
+      min = array[i];
+    else if (array[i] > max)
+      max = array[i];
+}
+
 /* clip.cpp */
 int clip_rect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);
 int clip_segment(double *x1, double *y1, double *x2, double *y2, const double u, const double v);
 /* clip.cpp */
 int clip_rect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);
 int clip_segment(double *x1, double *y1, double *x2, double *y2, const double u, const double v);
@@ -92,8 +104,4 @@ void scale2d(double x[], double y[], int pts, double xfact, double yfact);
 /* simpson.cpp */
 double simpson(const double xmin, const double xmax, const double *y, const int np);
 
 /* simpson.cpp */
 double simpson(const double xmin, const double xmax, const double *y, const int np);
 
-/* minmax.cpp */
-void minmax_dvector(const double array[], const int pts, double *xmin, double *xmax);
-
-
 #endif
 #endif
index 0ec840217f0944b6a759c9235a57913c116dea91..42dadc0ca9310632c665eefc34465e26c9ad75b2 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctrec.cpp,v 1.10 2000/06/17 20:12:15 kevin Exp $
+**  $Id: ctrec.cpp,v 1.11 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
 **
 **  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
@@ -107,7 +107,6 @@ ctrec_main (int argc, char * argv[])
   Projections projGlobal;
   char *pj_name, *im_filename = NULL;
   string remark;
   Projections projGlobal;
   char *pj_name, *im_filename = NULL;
   string remark;
-  char filt_name[80];
   char *endptr;
   int opt_verbose = 0;
   int opt_debug = 0;
   char *endptr;
   int opt_verbose = 0;
   int opt_debug = 0;
@@ -204,14 +203,14 @@ ctrec_main (int argc, char * argv[])
     nx = strtol(argv[optind + 2], &endptr, 10);
     ny = strtol(argv[optind + 3], &endptr, 10);
   
     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)
     if (opt_filter == FILTER_G_HAMMING || opt_filter == FILTER_ABS_G_HAMMING)
-      snprintf (filt_name, sizeof(filt_name), "%s: alpha = %.2f",
-              name_of_filter (opt_filter), opt_filter_param); 
+      filt_name << name_of_filter (opt_filter) << ": alpha=" << opt_filter_param; 
     else
     else
-      snprintf (filt_name, sizeof(filt_name), "%s", name_of_filter (opt_filter));
+      filt_name << name_of_filter (opt_filter);
   
     ostringstream label;
   
     ostringstream label;
-    label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
+    label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name.str() << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
     remark = label.str();
   
     if (opt_verbose)
     remark = label.str();
   
     if (opt_verbose)
index 3150cf9e6044c9a94a8f09f5b4bb19915b17647e..f85a269176bcfd981eb369adbffca8beca75b4e2 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: if-1.cpp,v 1.6 2000/06/13 16:20:31 kevin Exp $
+**  $Id: if-1.cpp,v 1.7 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
 **
 **  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
@@ -49,17 +49,17 @@ static struct option my_options[] =
 void 
 if1_usage (const char *program)
 {
 void 
 if1_usage (const char *program)
 {
-  fprintf(stdout, "if1_usage: %s infile outfile [OPTIONS]\n", fileBasename(program));
-  fprintf(stdout, "Generate a IF file from a IF file\n");
-  fprintf(stdout, "\n");
-  fprintf(stdout, "     --invert   Invert image\n");
-  fprintf(stdout, "     --log      Natural logrithm of image\n");
-  fprintf(stdout, "     --exp      Natural exponential of image\n");
-  fprintf(stdout, "     --sqr      Square of image\n");
-  fprintf(stdout, "     --sqrt     Square root of image\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) << " infile outfile [OPTIONS]" << endl;
+  cout << "Generate a IF file from a IF file" << endl;
+  cout << endl;
+  cout << "     --invert   Invert image" << endl;
+  cout << "     --log      Natural logrithm of image" << endl;
+  cout << "     --exp      Natural exponential of image" << endl;
+  cout << "     --sqr      Square of image" << endl;
+  cout << "     --sqrt     Square root of image" << endl;
+  cout << "     --verbose  Verbose modem" << endl;
+  cout << "     --version  Print version" << endl;
+  cout << "     --help     Print this help message" << endl;
 }
 
 int 
 }
 
 int 
@@ -105,11 +105,11 @@ if1_main (int argc, char *const argv[])
          break;
         case O_VERSION:
 #ifdef VERSION
          break;
         case O_VERSION:
 #ifdef VERSION
-         fprintf(stdout, "Version %s\n", VERSION);
+         cout << "Version " <<  VERSION << endl;
 #else
 #else
-         fprintf(stderr, "Unknown version number");
+          cout << "Unknown version number" << endl;
 #endif
 #endif
-         exit(0);
+         return (0);
        case O_HELP:
        case '?':
          if1_usage(argv[0]);
        case O_HELP:
        case '?':
          if1_usage(argv[0]);
index 29aef012299889f0a2cb6dcfbccc4c25db3e441c..89e6cc811d0528f11485c0b8a652abf93305c156 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  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
 **
 **  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
 ******************************************************************************/
 
 /* 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"
  */
 
 #include "ct.h"
@@ -46,25 +46,25 @@ static struct option my_options[] =
 };
 
 void 
 };
 
 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 
 }
 
 int 
-sdf2_main (int argc, char *const argv[])
+if2_main (int argc, char *const argv[])
 {
   ImageFile* pim_in1;
   ImageFile* pim_in2;
 {
   ImageFile* pim_in1;
   ImageFile* pim_in2;
@@ -102,23 +102,23 @@ sdf2_main (int argc, char *const argv[])
       break;
     case O_VERSION:
 #ifdef VERSION
       break;
     case O_VERSION:
 #ifdef VERSION
-      fprintf(stdout, "Version %s\n", VERSION);
+      cout << "Version " << VERSION << endl;
 #else
 #else
-      fprintf(stderr, "Unknown version number");
+      cout << "Unknown version number" << endl;
 #endif
 #endif
-      exit(0);
+      return (0);
     case O_HELP:
     case '?':
     case O_HELP:
     case '?':
-      sdf2_usage(argv[0]);
+      if2_usage(argv[0]);
       return (0);
     default:
       return (0);
     default:
-      sdf2_usage(argv[0]);
+      if2_usage(argv[0]);
       return (1);
     }
   }
   
   if (optind + 3 != argc) {
       return (1);
     }
   }
   
   if (optind + 3 != argc) {
-    sdf2_usage(argv[0]);
+    if2_usage(argv[0]);
     return (1);
   }
   
     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()) {
   }
 
   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) {
            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);
   }
 
       return(1);
   }
 
@@ -199,7 +199,7 @@ sdf2_main (int argc, char *const argv[])
       }
     }
     abs_error /= (im_in1.nx() * im_in1.ny());
       }
     }
     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();
   }
 
   im_out.arrayDataWrite();
@@ -216,7 +216,7 @@ sdf2_main (int argc, char *const argv[])
 int 
 main (int argc, char *const argv[])
 {
 int 
 main (int argc, char *const argv[])
 {
-  return (sdf2_main(argc, argv));
+  return (if2_main(argc, argv));
 }
 #endif
 
 }
 #endif
 
index 85237a700c13fd07158417e372787d1791dffe38..018e504abf6027fc741ce9fe555d8ea47475515b 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: if2img.cpp,v 1.5 2000/06/17 20:12:15 kevin Exp $
+**  $Id: if2img.cpp,v 1.6 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
 **
 **  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
@@ -83,41 +83,41 @@ enum { O_FORMAT_GIF, O_FORMAT_PNG, O_FORMAT_PNG16, O_FORMAT_PGM, O_FORMAT_PGMASC
 void 
 if2img_usage (const char *program)
 {
 void 
 if2img_usage (const char *program)
 {
-  fprintf(stdout, "usage: %s sdfname outfile [OPTIONS]\n", fileBasename(program));
-  fprintf(stdout, "Convert IF file to an image file\n");
-  fprintf(stdout, "\n");
-  fprintf(stdout, "     sdfname    Name of input SDF file\n");
-  fprintf(stdout, "     outfile    Name of output file\n");
-  fprintf(stdout, "     --format   Output format\n");
-  fprintf(stdout, "         pgm    PGM (portable graymap) format (default)\n");
-  fprintf(stdout, "         pgmasc PGM (portable graymap) ASCII format\n");
+  cout << "usage: " << fileBasename(program) << " ifname outfile [OPTIONS]" << endl;
+  cout << "Convert IF file to an image file" << endl;
+  cout << endl;
+  cout << "     sdfname    Name of input SDF file" << endl;
+  cout << "     outfile    Name of output file" << endl;
+  cout << "     --format   Output format" << endl;
+  cout << "         pgm    PGM (portable graymap) format (default)" << endl;
+  cout << "         pgmasc PGM (portable graymap) ASCII format" << endl;
 #ifdef HAVE_PNG
 #ifdef HAVE_PNG
-  fprintf(stdout, "         png    PNG (8-bit) format\n");
-  fprintf(stdout, "         png16  PNG (16-bit) format\n");
+  cout << "         png    PNG (8-bit) format" << endl;
+  cout << "         png16  PNG (16-bit) format" << endl;
 #endif
 #ifdef HAVE_GIF
 #endif
 #ifdef HAVE_GIF
-  fprintf(stdout, "         gif    GIF format\n");
+  cout << "         gif    GIF format" << endl;
 #endif
 #endif
-  fprintf(stdout, "         disp   Display on screen\n");
-  fprintf(stdout, "     --center   Center of window\n");
-  fprintf(stdout, "         mode   Mode is center of window (default)\n");
-  fprintf(stdout, "         mean   Mean is center of window\n");
-  fprintf(stdout, "     --auto     Set auto window\n");
-  fprintf(stdout, "         full   Use full window (default)\n");
-  fprintf(stdout, "         std0.1 Use 0.1 standard deviation about center\n");
-  fprintf(stdout, "         std0.5 Use 0.5 standard deviation about center\n");
-  fprintf(stdout, "         std1   Use one standard deviation about center\n");
-  fprintf(stdout, "         std2   Use two standard deviations about center\n");
-  fprintf(stdout, "         std3   Use three standard deviations about center\n");
-  fprintf(stdout, "     --scale    Scaling factor for output size\n");
-  fprintf(stdout, "     --min      Set minimum intensity\n");
-  fprintf(stdout, "     --max      Set maximum intensity\n");
-  fprintf(stdout, "     --stats    Print image statistics\n");
-  fprintf(stdout, "     --labels   Print image labels\n");
-  fprintf(stdout, "     --debug    Set debug mode\n");
-  fprintf(stdout, "     --verbose  Set verbose mode\n");
-  fprintf(stdout, "     --version  Print version\n");
-  fprintf(stdout, "     --help     Print this help message\n");
+  cout << "         disp   Display on screen" << endl;
+  cout << "     --center   Center of window" << endl;
+  cout << "         mode   Mode is center of window (default)" << endl;
+  cout << "         mean   Mean is center of window" << endl;
+  cout << "     --auto     Set auto window" << endl;
+  cout << "         full   Use full window (default)" << endl;
+  cout << "         std0.1 Use 0.1 standard deviation about center" << endl;
+  cout << "         std0.5 Use 0.5 standard deviation about center" << endl;
+  cout << "         std1   Use one standard deviation about center" << endl;
+  cout << "         std2   Use two standard deviations about center" << endl;
+  cout << "         std3   Use three standard deviations about center" << endl;
+  cout << "     --scale    Scaling factor for output size" << endl;
+  cout << "     --min      Set minimum intensity" << endl;
+  cout << "     --max      Set maximum intensity" << endl;
+  cout << "     --stats    Print image statistics" << endl;
+  cout << "     --labels   Print image labels" << endl;
+  cout << "     --debug    Set debug mode" << endl;
+  cout << "     --verbose  Set verbose mode" << endl;
+  cout << "     --version  Print version" << endl;
+  cout << "     --help     Print this help message" << endl;
 }
 
 
 }
 
 
@@ -156,7 +156,7 @@ if2img_main (int argc, char *const argv[])
          endstr = optarg + strlen(optarg);
          if (endptr != endstr)
            {
          endstr = optarg + strlen(optarg);
          if (endptr != endstr)
            {
-             fprintf(stderr, "Error setting --min to %s\n", optarg);
+             sys_error (ERR_SEVERE, "Error setting --min to %s", optarg);
              if2img_usage(argv[0]);
              return (1);
            }
              if2img_usage(argv[0]);
              return (1);
            }
@@ -167,7 +167,7 @@ if2img_main (int argc, char *const argv[])
          endstr = optarg + strlen(optarg);
          if (endptr != endstr)
            {
          endstr = optarg + strlen(optarg);
          if (endptr != endstr)
            {
-             fprintf(stderr, "Error setting --max to %s\n", optarg);
+             sys_error (ERR_SEVERE, "Error setting --max to %s", optarg);
              if2img_usage(argv[0]);
              return (1);
            }
              if2img_usage(argv[0]);
              return (1);
            }
@@ -177,7 +177,7 @@ if2img_main (int argc, char *const argv[])
          endstr = optarg + strlen(optarg);
          if (endptr != endstr)
            {
          endstr = optarg + strlen(optarg);
          if (endptr != endstr)
            {
-             fprintf(stderr,"Error setting --scale to %s\n", optarg);
+             sys_error (ERR_SEVERE, "Error setting --scale to %s", optarg);
              if2img_usage(argv[0]);
              return (1);
            }
              if2img_usage(argv[0]);
              return (1);
            }
@@ -197,7 +197,7 @@ if2img_main (int argc, char *const argv[])
            opt_auto = O_AUTO_STD3;
          else
            {
            opt_auto = O_AUTO_STD3;
          else
            {
-             fprintf(stderr, "Invalid auto mode %s\n", optarg);
+             sys_error (ERR_SEVERE, "Invalid auto mode %s", optarg);
              if2img_usage(argv[0]);
              return (1);
            }
              if2img_usage(argv[0]);
              return (1);
            }
@@ -209,11 +209,11 @@ if2img_main (int argc, char *const argv[])
            opt_center = O_CENTER_MODE;
          else
            {
            opt_center = O_CENTER_MODE;
          else
            {
-             fprintf(stderr, "Invalid center mode %s\n", optarg);
+             sys_error (ERR_SEVERE, "Invalid center mode %s", optarg);
              if2img_usage(argv[0]);
              return (1);
            }
              if2img_usage(argv[0]);
              return (1);
            }
-               break;
+         break;
        case O_FORMAT:
          if (strcmp(optarg, O_FORMAT_PGM_STR) == 0)
            opt_format = O_FORMAT_PGM;
        case O_FORMAT:
          if (strcmp(optarg, O_FORMAT_PGM_STR) == 0)
            opt_format = O_FORMAT_PGM;
@@ -232,7 +232,7 @@ if2img_main (int argc, char *const argv[])
          else if (strcmp(optarg, O_FORMAT_DISP_STR) == 0)
            opt_format = O_FORMAT_DISP;
          else {
          else if (strcmp(optarg, O_FORMAT_DISP_STR) == 0)
            opt_format = O_FORMAT_DISP;
          else {
-             fprintf(stderr, "Invalid format mode %s\n", optarg);
+             sys_error (ERR_SEVERE, "Invalid format mode %s", optarg);
              if2img_usage(argv[0]);
              return (1);
            }
              if2img_usage(argv[0]);
              return (1);
            }
@@ -251,9 +251,9 @@ if2img_main (int argc, char *const argv[])
          break;
         case O_VERSION:
 #ifdef VERSION
          break;
         case O_VERSION:
 #ifdef VERSION
-         fprintf(stdout, "Version %s\n", VERSION);
+         cout << "Version " << VERSION;
 #else
 #else
-         fprintf(stderr, "Unknown version number");
+          cout << "Unknown version number" << endl;
 #endif
          exit(0);
        case O_HELP:
 #endif
          exit(0);
        case O_HELP:
@@ -282,7 +282,7 @@ if2img_main (int argc, char *const argv[])
   pim = new ImageFile (in_file);
   ImageFile& im = *pim;
   if (! im.fileRead()) {
   pim = new ImageFile (in_file);
   ImageFile& im = *pim;
   if (! im.fileRead()) {
-    fprintf(stderr, "File %s does not exist\n", in_file);
+    sys_error (ERR_SEVERE, "File %s does not exist", in_file);
     return (1);
   }
 
     return (1);
   }
 
@@ -377,18 +377,18 @@ if2img_main (int argc, char *const argv[])
       else if (opt_auto == O_AUTO_STD3)
        window = stddev * 3;
       else {
       else if (opt_auto == O_AUTO_STD3)
        window = stddev * 3;
       else {
-       fprintf(stderr, "Internal Error: Invalid auto mode %d\n", opt_auto);
+       sys_error (ERR_SEVERE, "Internal Error: Invalid auto mode %d", opt_auto);
        return (1);
       }
     }
     if (opt_stats) {
        return (1);
       }
     }
     if (opt_stats) {
-      fprintf(stdout,"nx=%d\n", nx);
-      fprintf(stdout,"ny=%d\n", ny);
-      fprintf(stdout,"min=%f\n", minfound);
-      fprintf(stdout,"max=%f\n", maxfound);
-      fprintf(stdout,"mean=%f\n", mean);
-      fprintf(stdout,"mode=%f\n", mode);
-      fprintf(stdout,"stddev=%f\n", stddev);
+      cout <<"nx: " << nx << endl;
+      cout <<"ny: " << ny << endl;
+      cout <<"min: " << minfound << endl;
+      cout <<"max: " << maxfound << endl;
+      cout <<"mean: " << mean << endl;
+      cout <<"mode: " << mode << endl;
+      cout <<"stddev: " << stddev << endl;
     }
     if (opt_auto != O_AUTO_FULL) {
       double center;
     }
     if (opt_auto != O_AUTO_FULL) {
       double center;
@@ -398,7 +398,7 @@ if2img_main (int argc, char *const argv[])
       else if (opt_center == O_CENTER_MEAN)
        center = mean;
       else {
       else if (opt_center == O_CENTER_MEAN)
        center = mean;
       else {
-       fprintf(stderr, "Internal Error: Invalid center mode %d\n", opt_center);
+       sys_error (ERR_SEVERE, "Internal Error: Invalid center mode %d", opt_center);
        return (1);
       }
       if (! opt_set_max)
        return (1);
       }
       if (! opt_set_max)
@@ -409,8 +409,8 @@ if2img_main (int argc, char *const argv[])
   }
   
   if (opt_stats) {
   }
   
   if (opt_stats) {
-    fprintf(stdout,"min_disp=%f\n", densmin);
-    fprintf(stdout,"max_disp=%f\n", densmax);
+    cout << "min display: " << densmin << endl;
+    cout << "max display: " << densmax << endl;
   }
   
   if (opt_format == O_FORMAT_PGM)
   }
   
   if (opt_format == O_FORMAT_PGM)
@@ -436,7 +436,7 @@ if2img_main (int argc, char *const argv[])
   }
   else
     {
   }
   else
     {
-      fprintf(stderr, "Internal Error: Invalid format mode %d\n", opt_format);
+      sys_error (ERR_SEVERE, "Internal Error: Invalid format mode %d", opt_format);
       return (1);
     }
   return (0);
       return (1);
     }
   return (0);
@@ -631,14 +631,14 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm
   delete rowp;
 
   if ((out = fopen(outfile,"w")) == NULL) {
   delete rowp;
 
   if ((out = fopen(outfile,"w")) == NULL) {
-    fprintf(stderr,"Error opening output file %s for writing\n", outfile);
+    sys_error(ERR_SEVERE,"Error opening output file %s for writing", outfile);
     exit(1);
   }
   gdImageGif(gif,out);
   fclose(out);
   gdImageDestroy(gif);
 #else
     exit(1);
   }
   gdImageGif(gif,out);
   fclose(out);
   gdImageDestroy(gif);
 #else
-  fprintf(stderr, "This version does not support GIF");
+  cout << "This version does not support GIF" << endl;
 #endif
 }
 
 #endif
 }
 
index a054f2a989d6d397e47fa31df246bbff2dab7629..f0a475d8fcd84442c469f22b43d4e8ab2d7977c4 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ifinfo.cpp,v 1.7 2000/06/17 20:12:15 kevin Exp $
+**  $Id: ifinfo.cpp,v 1.8 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
 **
 **  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
@@ -49,19 +49,19 @@ static struct option my_options[] =
 void 
 ifinfo_usage (const char *program)
 {
 void 
 ifinfo_usage (const char *program)
 {
-  fprintf(stdout, "usage: %s infile [OPTIONS]\n", fileBasename(program));
-  fprintf(stdout, "Imagefile information\n");
-  fprintf(stdout, "\n");
-  fprintf(stdout, "     infile       Name of input SDF file\n");
-  fprintf(stdout, "     --display    Display image\n");
-  fprintf(stdout, "     --labels     Print image labels (default)\n");
-  fprintf(stdout, "     --no-labels  Do not print image labels\n");
-  fprintf(stdout, "     --stats      Print image statistics (default)\n");
-  fprintf(stdout, "     --no-stats   Do not print image statistics\n");
-  fprintf(stdout, "     --debug      Debug mode\n");
-  fprintf(stdout, "     --verbose    Verbose mode\n");
-  fprintf(stdout, "     --version    Print version\n");
-  fprintf(stdout, "     --help       Print this help message\n");
+  cout << "usage: " << fileBasename(program) << " infile [OPTIONS]" << endl;
+  cout << "Imagefile information" << endl;
+  cout << endl;
+  cout << "     infile       Name of input IF file" << endl;
+  cout << "     --display    Display image" << endl;
+  cout << "     --labels     Print image labels (default)" << endl;
+  cout << "     --no-labels  Do not print image labels" << endl;
+  cout << "     --stats      Print image statistics (default)" << endl;
+  cout << "     --no-stats   Do not print image statistics" << endl;
+  cout << "     --debug      Debug mode" << endl;
+  cout << "     --verbose    Verbose mode" << endl;
+  cout << "     --version    Print version" << endl;
+  cout << "     --help       Print this help message" << endl;
 }
 
 int 
 }
 
 int 
@@ -103,11 +103,11 @@ ifinfo_main (int argc, char *const argv[])
          break;
         case O_VERSION:
 #ifdef VERSION
          break;
         case O_VERSION:
 #ifdef VERSION
-         fprintf(stdout, "Version %s\n", VERSION);
+          cout << "Version " <<  VERSION << endl;
 #else
 #else
-         fprintf(stderr, "Unknown version number");
+          cout << "Unknown version number" << endl;
 #endif
 #endif
-         exit(0);
+         return (0);
        case O_HELP:
        case '?':
          ifinfo_usage(argv[0]);
        case O_HELP:
        case '?':
          ifinfo_usage(argv[0]);
index 3e82eefaadebc2802b5a430352af2f4ef191e13a..573cb7c697525de4790f1143c8fd8b5d72b4adff 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.9 2000/06/15 19:07:10 kevin Exp $
+**  $Id: phm2if.cpp,v 1.10 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
 **
 **  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,13 +112,13 @@ phm2if_main (int argc, char* argv[])
   DomainType opt_filter_domain = D_SPATIAL;
   char *opt_outfile = NULL;
   int opt_debug = 0;
   DomainType opt_filter_domain = D_SPATIAL;
   char *opt_outfile = NULL;
   int opt_debug = 0;
-  char str[256];
-  char opt_desc[256], opt_phmfilename[256];
+  string opt_desc;
+  string opt_phmfilename;
   char *endstr, *endptr;
   double opt_filter_param = 1;
   double opt_filter_bw = 1.;
   int opt_trace = TRACE_NONE;
   char *endstr, *endptr;
   double opt_filter_param = 1;
   double opt_filter_bw = 1.;
   int opt_trace = TRACE_NONE;
-  int opt_verbose = 0;
+  bool opt_verbose = false;
 #ifdef HAVE_MPI
   ImageFile* imLocal = NULL;
   MPIWorld mpiWorld (argc, argv);
 #ifdef HAVE_MPI
   ImageFile* imLocal = NULL;
   MPIWorld mpiWorld (argc, argv);
@@ -129,8 +129,6 @@ phm2if_main (int argc, char* argv[])
 #ifdef HAVE_MPI
   if (mpiWorld.getRank() == 0) {
 #endif
 #ifdef HAVE_MPI
   if (mpiWorld.getRank() == 0) {
 #endif
-    strcpy(opt_desc, "");
-    strcpy(opt_phmfilename, "");
     while (1) {
       int c = getopt_long(argc, argv, "", my_options, NULL);
       char *endptr = NULL;
     while (1) {
       int c = getopt_long(argc, argv, "", my_options, NULL);
       char *endptr = NULL;
@@ -147,8 +145,8 @@ phm2if_main (int argc, char* argv[])
        }
        break;
       case O_PHMFILE:
        }
        break;
       case O_PHMFILE:
-       strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
-       phm.createFromFile(opt_phmfilename);
+       opt_phmfilename = optarg;
+       phm.createFromFile(opt_phmfilename.c_str());
 #ifdef HAVE_MPI
        if (mpiWorld.getRank() == 0) 
          cerr << "Can't use phantom from file in MPI mode" << endl;
 #ifdef HAVE_MPI
        if (mpiWorld.getRank() == 0) 
          cerr << "Can't use phantom from file in MPI mode" << endl;
@@ -156,7 +154,7 @@ phm2if_main (int argc, char* argv[])
 #endif
        break;
       case O_VERBOSE:
 #endif
        break;
       case O_VERBOSE:
-       opt_verbose = 1;
+       opt_verbose = true;
        break;
       case O_DEBUG:
        opt_debug = 1;
        break;
       case O_DEBUG:
        opt_debug = 1;
@@ -180,13 +178,13 @@ phm2if_main (int argc, char* argv[])
        }
        break;
       case O_DESC:
        }
        break;
       case O_DESC:
-       strncpy(opt_desc, optarg, sizeof(opt_desc));
+       opt_desc =  optarg;
        break;
       case O_FILTER_BW:
        opt_filter_bw = strtod(optarg, &endptr);
        endstr = optarg + strlen(optarg);
        if (endptr != endstr) {
        break;
       case O_FILTER_BW:
        opt_filter_bw = strtod(optarg, &endptr);
        endstr = optarg + strlen(optarg);
        if (endptr != endstr) {
-         fprintf(stderr,"Error setting --filter-bw to %s\n", optarg);
+         sys_error(ERR_SEVERE,"Error setting --filter-bw to %s\n", optarg);
          phm2if_usage(argv[0]);
          return (1);
        }
          phm2if_usage(argv[0]);
          return (1);
        }
@@ -195,7 +193,7 @@ phm2if_main (int argc, char* argv[])
        opt_filter_param = strtod(optarg, &endptr);
        endstr = optarg + strlen(optarg);
        if (endptr != endstr) {
        opt_filter_param = strtod(optarg, &endptr);
        endstr = optarg + strlen(optarg);
        if (endptr != endstr) {
-         fprintf(stderr,"Error setting --filter-param to %s\n", optarg);
+         sys_error(ERR_SEVERE,"Error setting --filter-param to %s\n", optarg);
          phm2if_usage(argv[0]);
          return (1);
        }
          phm2if_usage(argv[0]);
          return (1);
        }
@@ -204,7 +202,7 @@ phm2if_main (int argc, char* argv[])
        opt_nsample = strtol(optarg, &endptr, 10);
        endstr = optarg + strlen(optarg);
        if (endptr != endstr) {
        opt_nsample = strtol(optarg, &endptr, 10);
        endstr = optarg + strlen(optarg);
        if (endptr != endstr) {
-         fprintf(stderr,"Error setting --nsample to %s\n", optarg);
+         sys_error(ERR_SEVERE,"Error setting --nsample to %s\n", optarg);
          phm2if_usage(argv[0]);
          return (1);
        }
          phm2if_usage(argv[0]);
          return (1);
        }
@@ -239,38 +237,31 @@ phm2if_main (int argc, char* argv[])
     opt_nx = strtol(argv[optind+1], &endptr, 10);
     endstr = argv[optind+1] + strlen(argv[optind+1]);
     if (endptr != endstr) {
     opt_nx = strtol(argv[optind+1], &endptr, 10);
     endstr = argv[optind+1] + strlen(argv[optind+1]);
     if (endptr != endstr) {
-      fprintf(stderr,"Error setting nx to %s\n", argv[optind+1]);
+      sys_error(ERR_SEVERE,"Error setting nx to %s\n", argv[optind+1]);
       phm2if_usage(argv[0]);
       return (1);
     }
     opt_ny = strtol(argv[optind+2], &endptr, 10);
     endstr = argv[optind+2] + strlen(argv[optind+2]);
     if (endptr != endstr) {
       phm2if_usage(argv[0]);
       return (1);
     }
     opt_ny = strtol(argv[optind+2], &endptr, 10);
     endstr = argv[optind+2] + strlen(argv[optind+2]);
     if (endptr != endstr) {
-      fprintf(stderr,"Error setting ny to %s\n", argv[optind+2]);
+      sys_error(ERR_SEVERE,"Error setting ny to %s\n", argv[optind+2]);
       phm2if_usage(argv[0]);
       return (1);
     }
     
       phm2if_usage(argv[0]);
       return (1);
     }
     
-    snprintf(str, sizeof(str), "nx=%d, ny=%d, nsample=%d, ", opt_nx, opt_ny, opt_nsample);
-    if (opt_phmfilename[0]) {
-      strncat(str, "phantom=", sizeof(str));
-      strncat(str, opt_phmfilename, sizeof(str));
-    }
-    else if (opt_phmnum != -1) {
-      strncat(str, "phantom=", sizeof(str));
-      strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
-    }
+    ostringstream oss;
+    oss << "nx=" << opt_nx << ", ny=" << opt_ny << ", nsample=" << opt_nsample << ", ";
+    if (opt_phmfilename.length())
+      oss << "phantom=" << opt_phmfilename;
+    else if (opt_phmnum != -1)
+      oss << "phantom=" << name_of_phantom(opt_phmnum);
     else if (opt_filter != -1) {
     else if (opt_filter != -1) {
-      strncat(str, "filter=", sizeof(str));
-      strncat(str, name_of_filter(opt_filter), sizeof(str));
-      strncat(str, " - ", sizeof(str));
-      strncat(str, name_of_filter_domain(opt_filter_domain), sizeof(str));
-    }
-    if (opt_desc[0]) {
-      strncat(str, ": ", sizeof(str));
-      strncat(str, opt_desc, sizeof(str));
+      oss << "filter=" << name_of_filter(opt_filter);
+      oss << " - " << name_of_filter_domain(opt_filter_domain);
     }
     }
-    strncpy(opt_desc, str, sizeof(opt_desc));
+    if (opt_desc.length())
+      oss << ": " << opt_desc;
+    opt_desc = oss.str();
     
     if (opt_verbose)
       cout << "Rasterize Phantom to Image" << endl << endl;
     
     if (opt_verbose)
       cout << "Rasterize Phantom to Image" << endl << endl;
@@ -363,7 +354,7 @@ phm2if_main (int argc, char* argv[])
   {
     imGlobal->arrayDataWrite ();
     double calctime = timerProgram.timerEnd ();
   {
     imGlobal->arrayDataWrite ();
     double calctime = timerProgram.timerEnd ();
-    imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc, calctime);
+    imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
     imGlobal->fileClose ();
     if (opt_verbose)
       cout << "Time to rasterized phantom: " << calctime << " seconds" << endl;
     imGlobal->fileClose ();
     if (opt_verbose)
       cout << "Time to rasterized phantom: " << calctime << " seconds" << endl;
index c77f901c9bf538bb8d01ac99bc1b4127b7fdb13c..530f23be1537bf1fe6eeffbcb5fea650eec0ef67 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
 ** FILE IDENTIFICATION
 **
 /*****************************************************************************
 ** FILE IDENTIFICATION
 **
-**   Name:          proj2if.cpp
+**   Name:          pj2if.cpp
 **   Purpose:       Convert an projection data file to an image file
 **   Programmer:    Kevin Rosenberg
 **   Date Started:  April 2000
 **   Purpose:       Convert an projection data file to an image file
 **   Programmer:    Kevin Rosenberg
 **   Date Started:  April 2000
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pj2if.cpp,v 1.1 2000/06/17 20:12:15 kevin Exp $
+**  $Id: pj2if.cpp,v 1.2 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
 **
 **  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
 ******************************************************************************/
 
 /* FILE
- *   proj2if.c                 Convert Raysum to image
+ *   pj2if.c                   Convert Raysum to image
  *
  * DATE
  *   Apr 1999
  *
  * DATE
  *   Apr 1999
@@ -47,22 +47,22 @@ static struct option my_options[] =
 
 
 void 
 
 
 void 
-proj2if_usage (const char *program)
+pj2if_usage (const char *program)
 {
 {
-  fprintf(stdout, "usage: %s in-proj-file out-if-file [OPTIONS]\n", fileBasename(program));
-  fprintf(stdout, "This program converts a projection file to a IF file\n");
-  fprintf(stdout, "\n");
-  fprintf(stdout, "   --verbose   Verbose mode\n");
-  fprintf(stdout, "   --version   Print version\n");
-  fprintf(stdout, "   --help      Print this help message\n");
+  cout << "usage: " << fileBasename(program) << " in-proj-file out-if-file [OPTIONS]" << endl;
+  cout << "Converts a projection file to a IF file" << endl;
+  cout << endl;
+  cout << "   --verbose   Verbose mode" << endl;
+  cout << "   --version   Print version" << endl;
+  cout << "   --help      Print this help message" << endl;
 }
 
          
 
 int 
 }
 
          
 
 int 
-proj2if_main (const int argc, char *const argv[])
+pj2if_main (const int argc, char *const argv[])
 {
 {
-  char *proj_name, *im_name;
+  char *pj_name, *im_name;
   int ix, iy;
   bool opt_verbose = false;
   extern int optind;
   int ix, iy;
   bool opt_verbose = false;
   extern int optind;
@@ -80,47 +80,47 @@ proj2if_main (const int argc, char *const argv[])
          break;
         case O_VERSION:
 #ifdef VERSION
          break;
         case O_VERSION:
 #ifdef VERSION
-         fprintf(stdout, "Version %s\n", VERSION);
+          cout << "Version " << VERSION << endl;
 #else
 #else
-         fprintf(stderr, "Unknown version number");
+          cout << "Unknown version number" << endl;
 #endif
 #endif
-         exit(0);
+         return (0);
        case O_HELP:
        case '?':
        case O_HELP:
        case '?':
-         proj2if_usage(argv[0]);
+         pj2if_usage(argv[0]);
          return (0);
        default:
          return (0);
        default:
-         proj2if_usage(argv[0]);
+         pj2if_usage(argv[0]);
          return (1);
        }
     }
   
   if (argc - optind != 2) {
          return (1);
        }
     }
   
   if (argc - optind != 2) {
-    proj2if_usage(argv[0]);
+    pj2if_usage(argv[0]);
     return (1);
   }
 
     return (1);
   }
 
-  proj_name = argv[optind];
+  pj_name = argv[optind];
   im_name = argv[optind + 1];
 
   im_name = argv[optind + 1];
 
-  Projections proj;
-  if (! proj.read (proj_name)) {
-    sys_error (ERR_SEVERE, "Can not open projection file %s", proj_name);
+  Projections pj;
+  if (! pj.read (pj_name)) {
+    sys_error (ERR_SEVERE, "Can not open projection file %s", pj_name);
     return (1);
   }
 
   if (opt_verbose)
     return (1);
   }
 
   if (opt_verbose)
-      proj.printScanInfo();
+      pj.printScanInfo();
   
   
-  ImageFile im (im_name, proj.nDet(), proj.nView());
+  ImageFile im (im_name, pj.nDet(), pj.nView());
   
   ImageFileArray v = im.getArray();
 
   
   ImageFileArray v = im.getArray();
 
-  for (iy = 0; iy < proj.nView(); iy++)
+  for (iy = 0; iy < pj.nView(); iy++)
     {
     {
-      DetectorArray& detarray = proj.getDetectorArray (iy);
+      DetectorArray& detarray = pj.getDetectorArray (iy);
       const DetectorValue* detval = detarray.detValues();
       const DetectorValue* detval = detarray.detValues();
-      for (ix = 0; ix < proj.nDet(); ix++)
+      for (ix = 0; ix < pj.nDet(); ix++)
        {
          v[ix][iy] = detval[ix];
        }
        {
          v[ix][iy] = detval[ix];
        }
@@ -128,7 +128,7 @@ proj2if_main (const int argc, char *const argv[])
 
   im.fileCreate ();
   im.arrayDataWrite ();
 
   im.fileCreate ();
   im.arrayDataWrite ();
-  im.labelAdd (Array2dFileLabel::L_HISTORY, proj.remark(), proj.calcTime());
+  im.labelAdd (Array2dFileLabel::L_HISTORY, pj.remark(), pj.calcTime());
   im.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .pj to .if");
   im.fileClose ();
   
   im.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .pj to .if");
   im.fileClose ();
   
@@ -140,6 +140,6 @@ proj2if_main (const int argc, char *const argv[])
 int 
 main (const int argc, char *const argv[])
 {
 int 
 main (const int argc, char *const argv[])
 {
-  return (proj2if_main(argc, argv));
+  return (pj2if_main(argc, argv));
 }
 #endif
 }
 #endif