r83: Converted to IF data files and C++
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 7 Jun 2000 07:43:19 +0000 (07:43 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 7 Jun 2000 07:43:19 +0000 (07:43 +0000)
src/Makefile.am
src/ctrec.cpp
src/if-1.cpp
src/if-2.cpp [new file with mode: 0644]
src/ifinfo.cpp
src/phm2if.cpp
src/rs2if.cpp

index e3e0bfe09715d1e4a669eff852b9c0078513d13a..ae3993856b0be392364102a39d5bd95793a3e54e 100644 (file)
@@ -1,6 +1,6 @@
-bin_PROGRAMS = ctsim sdf2img ctrec phm2rs phm2sdf rs2sdf rs2if sdf-1 sdf-2 sdfinfo @lamprograms@  ifinfo phm2if if-1
+bin_PROGRAMS = ctsim ctrec phm2rs rs2if @lamprograms@  ifinfo phm2if if-1 if-2 if2img 
 bin_SCRIPTS = sample-ctrec.sh
-EXTRA_PROGRAMS = ctrec-lam phm2sdf-lam phm2rs-lam phm2if-lam
+EXTRA_PROGRAMS = ctrec-lam phm2rs-lam phm2if-lam
 INCLUDES=@my_includes@
 EXTRA_DIST=Makefile.nt
 
@@ -10,31 +10,21 @@ ctrec_SOURCES = ctrec.cpp
 ctrec_LDADD=@ctlibs@
 phm2rs_SOURCES=phm2rs.cpp
 phm2rs_LDADD=@ctlibs@
-phm2sdf_SOURCES = phm2sdf.cpp
-phm2sdf_LDADD=@ctlibs@
 phm2if_SOURCES = phm2if.cpp
 phm2if_LDADD=@ctlibs@
-sdf2img_SOURCES = sdf2img.cpp
-sdf2img_LDADD=@ctlibs@
-rs2sdf_SOURCES = rs2sdf.cpp
-rs2sdf_LDADD=@ctlibs@
+if2img_SOURCES = if2img.cpp
+if2img_LDADD=@ctlibs@
 rs2if_SOURCES = rs2if.cpp
 rs2if_LDADD=@ctlibs@
-sdf_1_SOURCES=sdf-1.cpp
-sdf_1_LDADD=@ctlibs@
 if_1_SOURCES=if-1.cpp
 if_1_LDADD=@ctlibs@
-sdf_2_SOURCES=sdf-2.cpp
-sdf_2_LDADD=@ctlibs@
-sdfinfo_SOURCES = sdfinfo.cpp
-sdfinfo_LDADD=@ctlibs@
+if_2_SOURCES=if-2.cpp
+if_2_LDADD=@ctlibs@
 ifinfo_SOURCES = ifinfo.cpp
 ifinfo_LDADD=@ctlibs@
 
 ctrec_lam_SOURCES=ctrec.cpp
 ctrec_lam_LDADD=@ctlamlibs@
-phm2sdf_lam_SOURCES=phm2sdf.cpp
-phm2sdf_lam_LDADD=@ctlamlibs@
 phm2if_lam_SOURCES=phm2if.cpp
 phm2if_lam_LDADD=@ctlamlibs@
 phm2rs_lam_SOURCES=phm2rs.cpp
@@ -46,16 +36,16 @@ CC_LAM = $(lamdir)/bin/balky
 ctrec-lam: ctrec.cpp
        $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT ctrec.cpp -o ctrec-lam $(LDFLAGS) @ctlamlibs@
 
-phm2sdf-lam: phm2sdf.cpp
-       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2sdf.cpp -o phm2sdf-lam $(LDFLAGS) @ctlamlibs@
-
 phm2rs-lam: phm2rs.cpp
        $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2rs.cpp -o phm2rs-lam $(LDFLAGS) @ctlamlibs@
 
+phm2if-lam: phm2if.cpp
+       $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2if.cpp -o phm2if-lam $(LDFLAGS) @ctlamlibs@
+
 endif
 
-shared: ctrec.cpp phm2rs.cpp phm2sdf.cpp sdf2img.cpp rs2sdf.cpp  sdf-2.cpp sdf-1.cpp sdfinfo.cpp
-       $(CC) @DEFS@ $(CFLAGS) $(INCLUDES) -DNO_MAIN -shared phm2rs.cpp phm2sdf.cpp sdf2img.cpp rs2sdf.cpp sdf-1.cpp sdf-2.cpp sdfinfo.cpp @ctlibs@ $(LDFLAGS) -o ir.so
+shared: ctrec.cpp phm2rs.cpp 
+       $(CC) @DEFS@ $(CFLAGS) $(INCLUDES) -DNO_MAIN -shared phm2rs.cpp ctrec.cpp @ctlibs@ $(LDFLAGS) -o ir.so
 
 
 
index f48fc584de6d60b110b1835060df5ebaf71d44d6..a7b8ee575f98a6d575a8c0317c5ad405ec69177e 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctrec.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
+**  $Id: ctrec.cpp,v 1.2 2000/06/07 07:43:19 kevin Exp $
 **  $Log: ctrec.cpp,v $
+**  Revision 1.2  2000/06/07 07:43:19  kevin
+**  Converted to IF data files and C++
+**
 **  Revision 1.1  2000/06/07 02:29:05  kevin
 **  Initial C++ versions
 **
@@ -147,12 +150,11 @@ static void print_raysum_info(const RAYSUM *rs);
 int 
 ctrec_main (const int argc, char *const argv[])
 {
-  IMAGE *im_global = NULL;
+  ImageFile *im_global = NULL;
   RAYSUM *rs_global = NULL;
   char *rs_name, *im_filename = NULL;
   char remark[MAXREMARK];
   char filt_name[80];
-  int nx, ny;
   double time_start = 0, time_end = 0;
   char *endptr;
   int opt_verbose = 0;
@@ -163,15 +165,15 @@ ctrec_main (const int argc, char *const argv[])
   InterpolationType opt_interp = I_LINEAR;
   int opt_interp_param = 1;
   BackprojType opt_backproj = O_BPROJ_DIFF2;
+  int nx, ny;
 #ifdef MPI_CT
-  IMAGE *im_local;
+  ImageFile *im_local;
   RAYSUM *rs_local;
   int mpi_argc = argc;
   char **mpi_argv = (char **) argv;
   int mpi_nview, mpi_ndet;
   double mpi_detinc, mpi_rotinc, mpi_phmlen;
   double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
-  int ix;
 
   MPI_Init(&mpi_argc, &mpi_argv);
   MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm);
@@ -343,11 +345,10 @@ ctrec_main (const int argc, char *const argv[])
   }
 
   if (mpi_ct.my_rank == 0) {
-    im_global = image_create (im_filename, nx, ny);
-    sdf_add_label (LT_HISTORY, rs_global->remark, rs_global->calctime, im_global->dfp_2d->dfp);
-    sdf_add_empty_label (im_global->dfp_2d->dfp);
+    im_global = new ImageFile (im_filename, nx, ny);
+    im_global->adf.fileCreate();
   }
-  im_local = image_create (NULL, nx, ny);
+  im_local = new ImageFile (nx, ny);
 
 #else
   rs_global = raysum_open (rs_name);
@@ -355,14 +356,14 @@ ctrec_main (const int argc, char *const argv[])
   if (opt_verbose)
     print_raysum_info(rs_global);
 
-  im_global = image_create (im_filename, nx, ny);
-  sdf_add_label (LT_HISTORY, rs_global->remark, rs_global->calctime, im_global->dfp_2d->dfp);
-  sdf_add_empty_label (im_global->dfp_2d->dfp);
+  im_global = new ImageFile (im_filename, nx, ny);
+  im_global->adf.fileCreate();
+
 #endif
 
 #ifdef MPI_CT
   mpi_t1 = MPI_Wtime();
-  image_reconst (im_local, rs_local, opt_filter, opt_filter_param, 
+  proj_reconst (*im_local, rs_local, opt_filter, opt_filter_param, 
                 opt_interp, opt_interp_param, opt_backproj, opt_trace);
   mpi_t2 = MPI_Wtime();
   mpi_t = mpi_t2 - mpi_t1;
@@ -370,7 +371,7 @@ ctrec_main (const int argc, char *const argv[])
   if (mpi_ct.my_rank == 0 && opt_verbose)
     printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g);
 #else
-  image_reconst (im_global, rs_global, opt_filter, opt_filter_param, 
+  proj_reconst (*im_global, rs_global, opt_filter, opt_filter_param, 
                 opt_interp, opt_interp_param, opt_backproj, opt_trace);
 #endif
 
@@ -378,12 +379,17 @@ ctrec_main (const int argc, char *const argv[])
   if (opt_verbose)
     mpi_t1 = MPI_Wtime();
 
-  for (ix = 0; ix < im_local->nx; ix++) {
+  int nxLocal = im_local->adf.nx();
+  int nyLocal = im_local->adf.ny();
+  ImageFileArray vLocal = im_local->getArray();
+  ImageFileArray vGlobal = im_global->getArray();
+
+  for (int ix = 0; ix < nxLocal; ix++) {
     void *recvbuf = NULL;
     if (mpi_ct.my_rank == 0)
-      recvbuf = im_global->v[ix];
+      recvbuf = vGlobal[ix];
 
-    MPI_Reduce(im_local->v[ix], recvbuf, im_local->ny, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm);
+    MPI_Reduce(vLocal[ix], recvbuf, nyLocal, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm);
   }
 
   if (opt_verbose) {
@@ -406,11 +412,13 @@ ctrec_main (const int argc, char *const argv[])
 #endif
     {
       raysum_close (rs_global);
-      strncpy (im_global->remark, remark, sizeof(im_global->remark));
-      im_global->calctime = time_end - time_start;
-      image_save (im_global);
+      double calctime = time_end - time_start;
+      im_global->adf.arrayDataWrite ();
+      im_global->adf.labelAdd (Array2dFileLabel::L_HISTORY, rs_global->remark, rs_global->calctime);
+      im_global->adf.labelAdd (Array2dFileLabel::L_HISTORY, remark, calctime);
+      im_global->adf.fileClose ();
       if (opt_verbose)
-         fprintf (stdout, "Time active = %.2f\n", im_global->calctime);
+       cout << "Time active = " << calctime << " sec" << endl;
     }
 
 #ifdef MPI_CT
index b28ac181baad166d2cbf481ff4cc072d59694fa5..8d2330c9cec89809f46752dc3cfe69fb973104d5 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: if-1.cpp,v 1.2 2000/06/07 03:50:27 kevin Exp $
+**  $Id: if-1.cpp,v 1.3 2000/06/07 07:43:19 kevin Exp $
 **  $Log: if-1.cpp,v $
+**  Revision 1.3  2000/06/07 07:43:19  kevin
+**  Converted to IF data files and C++
+**
 **  Revision 1.2  2000/06/07 03:50:27  kevin
 **  *** empty log message ***
 **
@@ -156,13 +159,13 @@ if1_main (int argc, char *const argv[])
 
     im_in = new ImageFile (in_file);
     im_in->adf.fileRead ();
-    int nx = im_in->adf.nx();
-    int ny = im_in->adf.ny();
+    int nx = im_in->nx();
+    int ny = im_in->ny();
     im_out = new ImageFile (out_file, nx, ny);
     im_out->adf.fileCreate ();
 
-    ImageFileArray vIn = im_in->adf.getArray();
-    ImageFileArray vOut = im_out->adf.getArray();
+    ImageFileArray vIn = im_in->getArray();
+    ImageFileArray vOut = im_out->getArray();
 
     if (opt_invert) {
       for (ix = 0; ix < nx; ix++)
@@ -196,11 +199,7 @@ if1_main (int argc, char *const argv[])
     }
 
     im_out->adf.arrayDataWrite ();
-    for (int i = 0; i < im_in->adf.getNumLabels(); i++) {
-      Array2dFileLabel l;
-      im_in->adf.labelRead (l, i);
-      im_out->adf.labelAdd (l);
-    }
+    im_out->adf.labelsCopy (im_in->adf);
     im_out->adf.labelAdd (Array2dFileLabel::L_HISTORY, histString.c_str());
     im_out->adf.fileClose ();
   }
diff --git a/src/if-2.cpp b/src/if-2.cpp
new file mode 100644 (file)
index 0000000..6b9532b
--- /dev/null
@@ -0,0 +1,238 @@
+/*****************************************************************************
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: if-2.cpp,v 1.1 2000/06/07 07:43:19 kevin Exp $
+**  $Log: if-2.cpp,v $
+**  Revision 1.1  2000/06/07 07:43:19  kevin
+**  Converted to IF data files and C++
+**
+**  Revision 1.1  2000/06/07 02:29:05  kevin
+**  Initial C++ versions
+**
+**  Revision 1.5  2000/05/24 22:50:04  kevin
+**  Added support for new SGP library
+**
+**  Revision 1.4  2000/05/16 04:33:59  kevin
+**  Improved option processing
+**
+**  Revision 1.3  2000/05/11 01:06:30  kevin
+**  Changed sprintf to snprintf
+**
+**  Revision 1.2  2000/05/08 20:02:32  kevin
+**  ANSI C changes
+**
+**  Revision 1.1.1.1  2000/04/28 13:02:44  kevin
+**  Initial CVS import for first public release
+**
+**
+**
+**  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
+**  published by the Free Software Foundation.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+******************************************************************************/
+
+/* FILE
+ *   sdf-2.c         Generate a SDF file from two input SDF files
+ */
+
+#include "ct.h"
+
+enum {O_ADD, O_SUB, O_MUL, O_COMP, O_VERBOSE, O_HELP, O_VERSION};
+
+static struct option my_options[] =
+{
+  {"add", 0, 0, O_ADD},
+  {"sub", 0, 0, O_SUB},
+  {"mul", 0, 0, O_MUL},
+  {"comp", 0, 0, O_COMP},
+  {"verbose", 0, 0, O_VERBOSE},
+  {"help", 0, 0, O_HELP},
+  {"version", 0, 0, O_VERSION},
+  {0, 0, 0, 0}
+};
+
+void 
+sdf2_usage (const char *program)
+{
+  fprintf(stdout, "sdf2_usage: %s infile1 infile2 outfile [OPTIONS]\n", kbasename(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");
+}
+
+int 
+sdf2_main (int argc, char *const argv[])
+{
+  ImageFile* pim_in1;
+  ImageFile* pim_in2;
+  ImageFile* pim_out;
+  char *in_file1;
+  char *in_file2;
+  char *out_file;
+  int opt_verbose = 0;
+  int opt_add = 0;
+  int opt_sub = 0;
+  int opt_mul = 0;
+  int opt_comp = 0;
+
+  while (1) {
+    int c = getopt_long (argc, argv, "", my_options, NULL);
+      
+    if (c == -1)
+      break;
+      
+    switch (c) {
+    case O_ADD:
+      opt_add = 1;
+      break;
+    case O_SUB :
+      opt_sub = 1;
+      break;
+    case O_MUL:
+      opt_mul = 1;
+      break;
+    case O_COMP:
+      opt_comp = 1;
+      break;
+    case O_VERBOSE:
+      opt_verbose = 1;
+      break;
+    case O_VERSION:
+#ifdef VERSION
+      fprintf(stdout, "Version %s\n", VERSION);
+#else
+      fprintf(stderr, "Unknown version number");
+#endif
+      exit(0);
+    case O_HELP:
+    case '?':
+      sdf2_usage(argv[0]);
+      return (0);
+    default:
+      sdf2_usage(argv[0]);
+      return (1);
+    }
+  }
+  
+  if (optind + 3 != argc) {
+    sdf2_usage(argv[0]);
+    return (1);
+  }
+  
+  in_file1 = argv[optind];
+  in_file2 = argv[optind + 1];
+  out_file = argv[optind + 2];
+
+  pim_in1 = new ImageFile (in_file1);
+  pim_in2 = new ImageFile (in_file2);
+  ImageFile& im_in1 = *pim_in1;
+  ImageFile& im_in2 = *pim_in2;
+
+  if (! im_in1.adf.fileRead() || ! im_in2.adf.fileRead()) {
+      sys_error (ERR_WARNING, "Error reading an image");
+      return (1);
+  }
+
+  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",
+           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");
+      return(1);
+  }
+
+  pim_out = new ImageFile (out_file, im_in1.nx(), im_in1.ny());
+  ImageFile& im_out = *pim_out;
+  if (! im_out.adf.fileCreate()) {
+    sys_error (ERR_WARNING, "Could not open output file %s", out_file);
+    return (1);
+  }
+
+  string strOperation;
+  ImageFileArray v1 = im_in1.getArray();
+  ImageFileArray v2 = im_in2.getArray();
+  ImageFileArray vout = im_out.getArray();
+
+  if (opt_add) {
+    strOperation = "Add Images";
+    for (int ix = 0; ix < im_in1.nx(); ix++) {
+      ImageFileColumn in1 = v1[ix];
+      ImageFileColumn in2 = v2[ix];
+      ImageFileColumn out = vout[ix];
+      for (int iy = 0; iy < im_in1.ny(); iy++)
+       *out++ = *in1++ + *in2++;
+    }
+  } else if (opt_sub) {
+    strOperation = "Subtract Images";
+    for (int ix = 0; ix < im_in1.nx(); ix++) {
+      ImageFileColumn in1 = v1[ix];
+      ImageFileColumn in2 = v2[ix];
+      ImageFileColumn out = vout[ix];
+      for (int iy = 0; iy < im_in1.ny(); iy++)
+         *out++ = *in1++ - *in2++;
+    }
+  } else if (opt_mul) {
+    strOperation = "Multiply Images";
+    for (int ix = 0; ix < im_in1.nx(); ix++) {
+      ImageFileColumn in1 = v1[ix];
+      ImageFileColumn in2 = v2[ix];
+      ImageFileColumn out = vout[ix];
+      for (int iy = 0; iy < im_in1.ny(); iy++)
+       *out++ = *in1++ * *in2++;
+    }
+  } else if (opt_comp) {
+    double abs_error = 0.;
+    strOperation = "Subtract Images";
+    for (int ix = 0; ix < im_in1.nx(); ix++) {
+      ImageFileColumn in1 = v1[ix];
+      ImageFileColumn in2 = v2[ix];
+      ImageFileColumn out = vout[ix];
+      for (int iy = 0; iy < im_in1.ny(); iy++) {
+       double diff = *in1++ - *in2++;
+       *out++ = diff;
+       abs_error += fabs(diff);
+      }
+    }
+    abs_error /= (im_in1.nx() * im_in1.ny());
+    fprintf(stdout, "Average Error = %f\n", abs_error);
+  }
+
+  im_out.adf.arrayDataWrite();
+  im_out.adf.labelsCopy (im_in1.adf, "if-2 file 1: ");
+  im_out.adf.labelsCopy (im_in2.adf, "if-2 file 2: ");
+  im_out.adf.labelAdd (Array2dFileLabel::L_HISTORY, strOperation.c_str());
+
+  im_out.adf.fileClose();
+
+  return (0);
+}
+
+#ifndef NO_MAIN
+int 
+main (int argc, char *const argv[])
+{
+  return (sdf2_main(argc, argv));
+}
+#endif
+
index 000b255e29a6aa7f3ec04ab7223528c05402072e..136792db28bd586604bec92db0dc3bacdc1f064a 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ifinfo.cpp,v 1.2 2000/06/07 03:50:27 kevin Exp $
+**  $Id: ifinfo.cpp,v 1.3 2000/06/07 07:43:19 kevin Exp $
 **  $Log: ifinfo.cpp,v $
+**  Revision 1.3  2000/06/07 07:43:19  kevin
+**  Converted to IF data files and C++
+**
 **  Revision 1.2  2000/06/07 03:50:27  kevin
 **  *** empty log message ***
 **
@@ -137,7 +140,10 @@ ifinfo_main (int argc, char *const argv[])
   in_file = argv[optind];
 
   im = new ImageFile (in_file);
-  im->adf.fileRead ();
+  if (! im->adf.fileRead ()) {
+    sys_error (ERR_WARNING, "Unable to read file %s", in_file);
+    return (1);
+  }
 
   if (opt_labels) 
     {
@@ -147,9 +153,9 @@ ifinfo_main (int argc, char *const argv[])
       for (i = 0; i < nlabels; i++)
        {
            Array2dFileLabel label;
-           string str;
-
            im->adf.labelRead (label, i);
+
+           string str;
            label.getDateString (str);
 
            if (label.getLabelType() == Array2dFileLabel::L_HISTORY) {
@@ -175,9 +181,9 @@ ifinfo_main (int argc, char *const argv[])
       int ix, iy;
 
       maxbin = nbin - 1;
-      ImageFileArray v = im->adf.getArray();
-      int nx = im->adf.nx();
-      int ny = im->adf.ny();
+      ImageFileArray v = im->getArray();
+      int nx = im->nx();
+      int ny = im->ny();
 
       for (ix = 0; ix < nx; ix++)
        {
index cb5fca02e6e021fabd735cf59168e53c57f49e59..2afac40c8030132cec197c927aa62f3610d05087 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.2 2000/06/07 03:50:27 kevin Exp $
+**  $Id: phm2if.cpp,v 1.3 2000/06/07 07:43:19 kevin Exp $
 **  $Log: phm2if.cpp,v $
+**  Revision 1.3  2000/06/07 07:43:19  kevin
+**  Converted to IF data files and C++
+**
 **  Revision 1.2  2000/06/07 03:50:27  kevin
 **  *** empty log message ***
 **
@@ -135,13 +138,13 @@ phm2sdf_usage (const char *program)
 }
 
 #ifdef MPI_CT
-void mpi_gather_image (ImageFile *im_global, ImageFile *im_local, const int opt_debug);
+void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug);
 #endif
 
 int 
 phm2sdf_main (const int argc, char *const argv[])
 {
-  ImageFile *im_global = NULL;
+  ImageFileim_global = NULL;
   PHANTOM *phm = NULL;
   int opt_nx = 0, opt_ny = 0;
   int opt_nsample = 1;
@@ -159,7 +162,7 @@ phm2sdf_main (const int argc, char *const argv[])
   int opt_verbose = 0;
   double time_start=0, time_end=0;
 #ifdef MPI_CT
-  ImageFile *im_local = NULL;
+  ImageFileim_local = NULL;
   int mpi_argc = argc;
   char **mpi_argv = (char **) argv;
   double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
@@ -380,7 +383,7 @@ phm2sdf_main (const int argc, char *const argv[])
   }
 #endif
 
-  ImageFileArray v = im_global->adf.getArray ();
+  ImageFileArray v = im_global->getArray ();
   double calctime = 0;
 
 #ifdef MPI_CT
@@ -391,14 +394,13 @@ phm2sdf_main (const int argc, char *const argv[])
     }
   } else if (opt_filter != -1) {
     if (mpi_ct.my_rank == 0) {
-      image_filter_response (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
+      image_filter_response (*im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
       calctime = 0;
     }
   } else {
     if (opt_verbose)
       mpi_t1 = MPI_Wtime();
-    phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank],
-                 mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace);
+    phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank],  mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace);
     if (opt_verbose) {
       mpi_t2 = MPI_Wtime();
       mpi_t = mpi_t2 - mpi_t1;
@@ -406,14 +408,14 @@ phm2sdf_main (const int argc, char *const argv[])
       if (mpi_ct.my_rank == 0)
        printf("Time to compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
     }
-    mpi_gather_image(im_global, im_local, opt_debug);
+    mpi_gather_image(*im_global, *im_local, opt_debug);
   }
 #else
   if (phm->type == P_UNIT_PULSE) {
     v[opt_nx/2][opt_ny/2] = 1.;
     calctime = 0;
   } else if (opt_filter != -1) {
-    // image_filter_response (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
+    image_filter_response (*im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
     calctime = 0;
   } else {
 #if HAVE_SGP
@@ -442,17 +444,16 @@ phm2sdf_main (const int argc, char *const argv[])
       fprintf (stdout, "Time to compile image = %.2f sec\n\n", calctime);
   }
 
-  if (opt_trace >= TRACE_PHM)
-    {
-      double dmin, dmax;
-      int nscale;
+  if (opt_trace >= TRACE_PHM) {
+    double dmin, dmax;
+    int nscale;
 
-      printf ("Enter display size scale (nominal = 1): ");
-      scanf ("%d", &nscale);
-      printf ("Enter minimum and maximum densities (min, max): ");
-      scanf ("%lf %lf", &dmin, &dmax);
-      // image_display_scale (im_global, nscale, dmin, dmax);
-    }
+    printf ("Enter display size scale (nominal = 1): ");
+    scanf ("%d", &nscale);
+    printf ("Enter minimum and maximum densities (min, max): ");
+    scanf ("%lf %lf", &dmin, &dmax);
+    image_display_scale (*im_global, nscale, dmin, dmax);
+  }
 
   phm_free (phm);
 
@@ -462,34 +463,30 @@ phm2sdf_main (const int argc, char *const argv[])
 
 
 #ifdef MPI_CT
-void mpi_gather_image (ImageFile *im_global, ImageFile *im_local, const int opt_debug)
+void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug)
 {
-  int iproc;
-  int end_work_unit;
-  int iw;
-
-  end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
-  for (iw = 0; iw <= end_work_unit; iw++) {
-    MPI_Send(im_local->v[iw], im_local->ny, im_local->getMPIDataType(), 0, 0, mpi_ct.comm);
+  ImageFileArray vLocal = im_local.getArray();
+  ImageFileArray vGlobal = im_global.getArray();
+  int nyLocal = im_local.ny();
+  int nyGlobal = im_global.ny();
+  
+  int end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
+  for (int iw = 0; iw <= end_work_unit; iw++) {
+    MPI_Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0, mpi_ct.comm);
   }
 
   if (mpi_ct.my_rank == 0) {
-    for (iproc = 0; iproc < mpi_ct.nproc; iproc++) {
-      end_work_unit = mpi_ct.start_work_unit[iproc] 
-       + mpi_ct.local_work_units[iproc] 
-       - 1;
+    for (int iproc = 0; iproc < mpi_ct.nproc; iproc++) {
+      end_work_unit = mpi_ct.start_work_unit[iproc] + mpi_ct.local_work_units[iproc] - 1;
 
       if (opt_debug) {
-       fprintf(stdout, "Recv rs data from process %d (%d-%d)\n", iproc,
-               mpi_ct.start_work_unit[iproc], end_work_unit);
+       fprintf(stdout, "Recv rs data from process %d (%d-%d)\n", iproc, mpi_ct.start_work_unit[iproc], end_work_unit);
        fflush(stdout);
       }
 
-
-      for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
+      for (int iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
        MPI_Status status;
-
-       MPI_Recv(im_global->v[iw], im_global->ny, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status);
+       MPI_Recv(vGlobal[iw], nyGlobal, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status);
       }
     }
   }
index becedaeee69928a97d53d2f75cc17fb3ea5bcaa8..7985355993e18ab911ad9748f0ea519425e6d37b 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: rs2if.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
+**  $Id: rs2if.cpp,v 1.2 2000/06/07 07:43:19 kevin Exp $
 **  $Log: rs2if.cpp,v $
+**  Revision 1.2  2000/06/07 07:43:19  kevin
+**  Converted to IF data files and C++
+**
 **  Revision 1.1  2000/06/07 02:29:05  kevin
 **  Initial C++ versions
 **
@@ -130,7 +133,7 @@ rs2if_main (const int argc, char *const argv[])
   im = new ImageFile (im_name, rs->ndet, rs->nview);
   
   detarray = detarray_alloc (rs->ndet);
-  ImageFileArray v = im->adf.getArray();
+  ImageFileArray v = im->getArray();
 
   for (iy = 0; iy < rs->nview; iy++)
     {