r96: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 15 Jun 2000 19:07:10 +0000 (19:07 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 15 Jun 2000 19:07:10 +0000 (19:07 +0000)
14 files changed:
ChangeLog
configure.in
include/Makefile.am
include/byteorder.h [new file with mode: 0644]
include/ct.h
include/ir.h
include/kmath.h
include/kstddef.h
include/sgp.h
include/sstream [new file with mode: 0644]
src/ctrec.cpp
src/phm2if.cpp
src/phm2rs.cpp
src/rs2if.cpp

index 06691391e8a309a1afc95288dd0e8f34173cd676..784dfb003735831d99ab3c2642120dff0a6d79cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+0.6.1 - 6/12/2000
+   Converted Phantom and PhantomElements to Object-Oriented
+   Converted Detector to Object-Oriented
+       
 0.6.0-b3 - 6/10/2000
    Improved Integer backprojection method
        Fixed nearest neighbor to be truly nearest neighbor
index 8693d57d74997b2d1d132c0bc0a97526408fc6d0..9cc9819ba9d4c7184caee99521f48ab324e2625d 100644 (file)
@@ -4,7 +4,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout
 dnl CDPATH=
 
 AC_INIT(src/ctrec.cpp)
-AM_INIT_AUTOMAKE(ctsim,0.6.0-b3)
+AM_INIT_AUTOMAKE(ctsim,0.6.1)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
index 90bd58c49c1ace63961f270d176cad1524a63e91..74f7f8103ec4aa5dd39398d4225df91d068c43ae 100644 (file)
@@ -1,4 +1,7 @@
-noinst_HEADERS=ascii.h cio.h ct.h ezplot.h ir.h keyboard.h kmath.h kstddef.h pol.h sgp.h array2d.h imagefile.h backprojectors.h mpiworld.h
+noinst_HEADERS=ascii.h cio.h ct.h ezplot.h ir.h keyboard.h kmath.h kstddef.h pol.h sgp.h array2d.h imagefile.h backprojectors.h mpiworld.h byteorder.h phantom.h timer.h sstream
+
+
+
 
 
 
diff --git a/include/byteorder.h b/include/byteorder.h
new file mode 100644 (file)
index 0000000..a3c51e8
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef NETORDER_H
+#define NETORDER_H
+
+/* netorder.cpp */
+
+void *strreverse (void *dest, const void *src, size_t n);
+int read_nint16 (kuint16 *n, int fd);
+int write_nint16 (kuint16 const *n, int fd);
+int read_nint32 (kuint32 *n, int fd);
+int write_nint32 (kuint32 const *n, int fd);
+int read_nfloat32 (float *f, int fd);
+int write_nfloat32 (float const *f, int fd);
+int read_nfloat64 (double *d, int fd);
+int write_nfloat64 (double const *d, int fd);
+void ConvertNetworkOrder (void* buffer, size_t bytes);
+void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+
+#endif
index 72a01f2844221e78b68b9cdb98c99709adf27b7f..02896535b315d90c2ef7876a4c1abb8b2b69c54a 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ct.h,v 1.13 2000/06/10 23:00:17 kevin Exp $
+**  $Id: ct.h,v 1.14 2000/06/15 19:07:10 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
   #include "png.h"
 #endif
 #ifdef HAVE_G2_H
-  #ifdef __cplusplus
-  extern "C" { 
-    #include "g2.h" 
-  }
-  #else
-  #include "g2.h"
-  #endif
-  #ifdef HAVE_X11
-    #ifdef __cplusplus
-      extern "C" {
-        #include "g2_X11.h"
-      }
-    #else
-        #include "g2_X11.h"
-    #endif
-  #endif
+extern "C" { 
+#include "g2.h" 
+}
+#ifdef HAVE_X11
+extern "C" {
+#include "g2_X11.h"
+}
+#endif
 #endif
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #include "kmath.h"
 #include "keyboard.h"
 #include "cio.h"
+#include "byteorder.h"
 
 #ifdef HAVE_SGP
   #include "ezplot.h"
 #endif
 
 #include <iostream>
+#include <sstream>
 #include <string>
+#include <iterator>
+#include <algorithm>
 
 using namespace std;
 
 #include "array2d.h"
 #include "imagefile.h"
 #include "ir.h"
+#include "phantom.h"
 #include "backprojectors.h"
 
 
index ffa83fb63d156cb3891d212ae8091f860a31b578..c7b2f7bd7150235ae607e7ecbb4da8bfadd488a1 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ir.h,v 1.26 2000/06/13 16:20:31 kevin Exp $
+**  $Id: ir.h,v 1.27 2000/06/15 19:07:10 kevin Exp $
 **
 **
 **  This program is free software; you can redistribute it and/or modify
 #define IR_H
 
 
-static const int POINTS_PER_CIRCLE=90;
-#define MAXREMARK  99
-
-typedef enum {
-  RECTANGLE,
-  TRIANGLE,
-  ELLIPSE,
-  SECTOR,
-  SEGMENT
-} PElmType;
-
-
-class PhmElement
-{
- public:
-    PElmType type;          /* pelm type (box, ellipse, etc) */
-    double atten;           /* X-ray attenuation coefficient */
-    double cx,cy;           /* center of pelm */
-    double u,v;                     /* size of pelm */
-    double rot;                     /* pelm rotation angle (in radians) */
-    double *x, *y;          /* ptr to array of points in obj world coord */
-    int pts;                /* number of points in outline arrays */
-    double xmin, xmax, ymin, ymax; /* pelm limits */
-    double radius;          /*   "   */
-    GRFMTX_2D p_to_o;        /* map from phantom to standard pelm coords */
-    GRFMTX_2D o_to_p;        /* map from std pelm coords to phantom coords */
-    class PhmElement *next;    /* pointer to next pelm in phantom */
-};
-typedef class PhmElement PELM;
-
-typedef enum {
-  P_PELMS,        /* Phantom made of Pelms */
-  P_UNIT_PULSE,   /* Special phantom, not made of pelms */
-  P_FILTER       /* defined only by this type */
-} PhmType;
-
-
-/* Phantom class */
-class Phantom
-{
-public:
-    PELM *pelm_list;               /* pelm linked-list */
-    PhmType type;
-    int n_pelm;                           /* number of pelms in phantom */
-    double xmin, xmax, ymin, ymax; /* extent of pelms in pelm coordinates */
-    double radius;                 /*      " "    */
-};
-typedef class Phantom    PHANTOM;
+#include "phantom.h"
 
 
 /*----------------------------------------------------------------------*/
@@ -125,8 +78,11 @@ class Detector
     double xs1,ys1,xs2,ys2;    /* Coordinates of source endpoints */
     double angle;              /* Starting angle */
   } init;
+
+  Detector (const Phantom& phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
+  ~Detector();
+  
 };
-typedef class Detector DETECTOR;
 
 
 class Projections
@@ -138,7 +94,7 @@ class Projections
   int geometry;                        /* Geometry of scanner */
   struct DetectorArray **view; /* Pointer to array of detarray_st pointers */
 
-  char remark[MAXREMARK+1];    /* description of raysum data */
+  string remark;               /* description of raysum data */
   double calctime;             /* time required to calculate raysums */
 
   int ndet;                    /* number of detectors in array */
@@ -150,21 +106,12 @@ class Projections
   double det_inc;              /* increment between detectors */
   double phmlen;               /* Length of PHANTOM edge (phm is square) */
 };
-typedef class Projections  RAYSUM;
-
+typedef class Projections RAYSUM;
 
 /*----------------------------------------------------------------------*/
 /*                             USER SYMBOLS                            */
 /*----------------------------------------------------------------------*/
 
-/* Codes for Coordinate Types      */
-/* Defines coords for pelm_is_point_inside() */
-
-typedef enum {
-  PELM_COORD,         /* Normalized Pelm Coordinates */
-  PHM_COORD           /* User's phantom Coordinates */
-} CoordType;
-
 /* Codes for Filter types */
 
 typedef enum {         /* filter types for filter_generate() */
@@ -209,9 +156,6 @@ typedef enum {     /* Interpolation methods */
   I_LINEAR        /* Linear interpolation */
 } InterpolationType;
 
-/* Constants for sizing PHANTOM */
-
-static const double PERCENT_PHM_SIZE_INCR=0.0;  /* Fractional increase in phantom limits compared to pelm size */
 static const int N_EXTRA_DETECTORS=4;           /* Number of extra detectors widths when calculating detlen */
 
 static const char O_TRACE_NONE_STR[]=     "none";
@@ -293,8 +237,8 @@ const static int RAYSUM_TRACE_ROW_ATTEN=18;
 double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
 
 /* dialogs.cpp */
-int phm_add_pelm_kb (PHANTOM *phm);
-PHANTOM *phm_select (void);
+bool phm_add_pelem_kb (Phantom& phm);
+const Phantom& phm_select (Phantom& phm);
 int interpolation_select (void);
 int filter_select (double *filter_param);
 
@@ -319,47 +263,16 @@ const char *name_of_filter_domain(const DomainType domain);
 BackprojType opt_set_backproj(const char *optarg);
 const char *name_of_backproj(const BackprojType backproj);
 
-/* phm.cpp */
-PHANTOM *phm_create(const int phmid);
-PHANTOM *phm_create_from_file(const char *fname);
-PHANTOM *phm_init(void);
-void phm_free (PHANTOM *phm);
-int phm_add_pelm_file(PHANTOM *phm, const char *fname);
-void phm_add_pelm (PHANTOM *phm, const char *type, const double cx, const double cy, 
-              const double u, const double v, const double rot, const double atten);
-int pelm_make_points(PELM *obj);
-void pelm_make_xform (PELM *obj);
-PELM *pelm_alloc(void);
-void calc_arc(double x[], double y[], const int pts, const double xcent, const double ycent, 
-             const double r, const double start, const double stop);
-void calc_ellipse(double x[], double y[], const int pts, const double u, const double v);
-int circle_pts(double theta);
-void phm_print(PHANTOM *phm);
-#if HAVE_SGP
-void phm_show(const PHANTOM *phm);
-void phm_draw(const PHANTOM *phm);
-#endif
-
-/* phmstd.cpp */
-void phm_std_herman (PHANTOM *phm);
-void phm_std_rowland (PHANTOM *phm);
-void phm_std_rowland_bordered (PHANTOM *phm);
-
 /* raycollect.cpp */
-int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PHANTOM *phm, const int start_view, const int trace, const int unit_pulse);
-void rayview(const PHANTOM *phm, DETARRAY *darray, const DETECTOR *det, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
-double phm_ray_attenuation (const PHANTOM *phm, const double x1, const double y1, const double x2, const double y2);
-double pelm_ray_attenuation (PELM *pelm, const double x1, const double y1, const double x2, const double y2);
-int pelm_clip_line (const PELM *pelm, double& x1, double& y1, double& x2, double& y2);
+int raysum_collect (RAYSUM *rs, const Detector& det, const Phantom& phm, const int start_view, const int trace, const int unit_pulse);
+void rayview (const Phantom& phm, DETARRAY *darray, const Detector& det, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
+double phm_ray_attenuation (const Phantom& phm, const double x1, const double y1, const double x2, const double y2);
+double pelem_ray_attenuation (PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2);
 void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...);
 
-/* scanner.cpp */
-DETECTOR *detector_create(const PHANTOM *phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
-void detector_free(DETECTOR *det);
-
 /* rayio.cpp */
 RAYSUM *raysum_create(const char *fname, const int nview, const int ndet);
-RAYSUM *raysum_create_from_det(const char *fname, const DETECTOR *det);
+RAYSUM *raysum_create_from_det(const char *fname, const Detector& det);
 RAYSUM *raysum_open(const char *filename);
 void raysum_alloc_views(RAYSUM *rs);
 void raysum_free(RAYSUM *rs);
@@ -377,8 +290,7 @@ int detarray_read(RAYSUM *rs, DETARRAY *darray, const int view_num);
 int detarray_write(RAYSUM *rs, const DETARRAY *darray, const int view_num);
 
 /* From phm2image.cpp */
-void phm_to_imagefile (const PHANTOM *phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
-int pelm_is_point_inside(PELM *obj, const double x, const double y, const CoordType coord_type);
+void phm_to_imagefile (const Phantom& phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
 
 /* image.cpp */
 void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);
index 5599327d2c285de22af7b1745f3965edf8b86fbd..48370267f1f9d92740bded47f363b83e3a4dde78 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: kmath.h,v 1.12 2000/06/13 16:20:31 kevin Exp $
+**  $Id: kmath.h,v 1.13 2000/06/15 19:07:10 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
@@ -30,7 +30,6 @@
 
 #include <stdio.h>
 #include <math.h>
-#include <algo.h>
 
 #define PI      3.14159265358979323846
 #define HALFPI  1.57079632679489661923 /* PI divided by 2 */
 #define F_EPSILON      1.0E-6
 #define D_EPSILON      1.0E-10
 
-#define DEG_TO_RAD(x)  (x*(PI/180.))
-#define RAD_TO_DEG(x)  (x*(180./PI))
-
 #define ASSUMEDZERO  1E-10
 
 typedef double GRFMTX_2D[3][3];
 typedef double GRFMTX_3D[4][4];
 
+inline double 
+convertDegreesToRadians (double x)
+{ return (x * (PI/180.)); }
+
+inline double
+convertRadiansToDegrees (double x)
+{ return (x*(180./PI)); }
 
 template<class T>
 inline T nearest (double x)
 { return (x > 0 ? static_cast<T>(x+0.5) : static_cast<T>(x-0.5)); }
 
 template<class T>
-inline T clamp (T value, T upperBounds, T lowerBounds)
+inline T clamp (T value, T lowerBounds, T upperBounds)
 { return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); }
 
 
index dfb35431e281c53a15218d0c0bc9fdc5165ece67..34e0b02dfb29526973559d835ee60f7eb87857e3 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: kstddef.h,v 1.16 2000/06/13 16:20:31 kevin Exp $
+**  $Id: kstddef.h,v 1.17 2000/06/15 19:07:10 kevin Exp $
 **
 **
 **  This program is free software; you can redistribute it and/or modify
@@ -45,8 +45,6 @@
 #include <string.h>
 #include <stdarg.h>
 
-#undef SHELL
-
 #define TRUE   1
 #define FALSE  0
 #define OK     TRUE
@@ -56,7 +54,7 @@
 
 /*----------------------------------------------------------------------*/
 
-#define SHOW(var, fmt)  fprintf (stderr, "var = fmt\n", var)
+#define SHOW(var, fmt)  { cerr << "var = " << var << endl; }
 
 /*----------------------------------------------------------------------*/
 
 #define        TAB     '\t'
 #define EOS    '\0'
 #define BLANK  ' '
-#define ETX    26      /* end of text signal for PC-DOS */
-
-/*----------------------------------------------------------------------*/
-
-#define MAXPATHNAME  65                /* max length of pathname + 1 */
-#define MAXFILENAME  13                /* rootname(8) + '.'(1) + extension(3) + EOS */
-#define MAXROOTNAME   8
-#define MAXEXTNAME    3
-#define MAXFULLNAME  MAXPATHNAME + MAXFILENAME
-
-/*----------------------------------------------------------------------*/
-
-#define ABS(x)    ((x) < 0 ? -(x) : (x))
-#define SQR(x)    ((x) * (x))
-
-#define ISWAP(a,b) {int i; i = a; a = b; b = i;}
-
-#define CLIP(n,lb,ub)  if (n < lb) n = lb; else if (n > ub) n = ub
-#define STR_EQUAL(s1,s2) (strcmp (s1, s2) == 0)
 
 /*----------------------------------------------------------------------*/
 
@@ -125,15 +104,6 @@ typedef struct timedate_st TIMEDATE;
 
 /*----------------------------------------------------------------------*/
 
-/* codes for input (inp_*) routines */
-
-#define INP_ERROR   -1
-#define INP_NO      FALSE
-#define INP_YES     TRUE
-#define INP_NEITHER 'b'
-#define INP_RETURN  'r'
-#define INP_BREAK   0x8000
-
 #ifndef O_BINARY
 #define O_BINARY (0)
 #endif
@@ -178,6 +148,7 @@ typedef unsigned char kuint8;
     typedef double kfloat64;
 #endif
 
+
 /* filefuncs.cpp */
 bool file_exists(const char* fname);
 const char* fileBasename(const char* filename);
@@ -214,17 +185,4 @@ char *td_str_cdate(DATE *d);
 char *td_month_name(int n);
 char *td_day_name(int n);
 
-/* netorder.cpp */
-void *strreverse (void *dest, const void *src, size_t n);
-int read_nint16 (kuint16 *n, int fd);
-int write_nint16 (kuint16 const *n, int fd);
-int read_nint32 (kuint32 *n, int fd);
-int write_nint32 (kuint32 const *n, int fd);
-int read_nfloat32 (float *f, int fd);
-int write_nfloat32 (float const *f, int fd);
-int read_nfloat64 (double *d, int fd);
-int write_nfloat64 (double const *d, int fd);
-void ConvertNetworkOrder (void* buffer, size_t bytes);
-void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
-
 #endif
index 7189c96d84c70a963e18e940f3507a25dd2048a2..ee95681a6a2ede5f5835ddf4a270d24f5eb1a8ca 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sgp.h,v 1.8 2000/06/13 16:20:31 kevin Exp $
+**  $Id: sgp.h,v 1.9 2000/06/15 19:07:10 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
 #endif
 
 #if HAVE_G2_H
+extern "C" {
 #include "g2.h"
 #include "g2_X11.h"
+}
 #endif
 
 /* device names */
diff --git a/include/sstream b/include/sstream
new file mode 100644 (file)
index 0000000..69d4ee2
--- /dev/null
@@ -0,0 +1,110 @@
+#ifndef __CM_SSTREAM__
+#define __CM_SSTREAM__
+
+#include <string>
+#include <cstdio>
+#include <strstream>
+#include <algorithm>
+
+namespace std {
+
+class ostringstream
+{
+public:
+    ostringstream (const string & str = "")
+        : buffer(str) {}
+
+    const string & str() const
+    {
+        return buffer;
+    }
+
+    void str (const string & new_string)
+    {
+        buffer = new_string;
+    }
+
+    ostringstream & operator<< (const string & item)
+    {
+        buffer += item;
+
+        return *this;
+    }
+
+    ostringstream & operator<< (int item)
+    {
+        char temp[100];
+
+        sprintf (temp, "%d", item);
+        buffer += temp;
+
+        return *this;
+    }
+
+    ostringstream & operator<< (unsigned int item)
+    {
+        char temp[100];
+
+        sprintf (temp, "%u", item);
+        buffer += temp;
+
+        return *this;
+    }
+
+    ostringstream & operator<< (char item)
+    {
+        buffer += item;
+        return *this;
+    }
+
+    ostringstream & operator<< (double item)
+    {
+        char temp[1000];
+
+        sprintf (temp, "%g", item);
+        buffer += temp;
+
+        return *this;
+    }
+
+private:
+    string buffer;
+};
+
+
+
+class istringstream
+{
+    friend istringstream & getline (istringstream &, string &, char = '\n');
+
+public:
+    istringstream (const string & str = "")
+        : buffer (str.c_str(), str.length()) {}
+
+    template <class T>
+    istringstream & operator>> (T & item)
+    {
+        buffer >> item;
+        return *this;
+    }
+
+    operator void * () const
+    {
+        return (void *) buffer;
+    }
+
+private:
+    istrstream buffer;
+};
+
+
+inline istringstream & getline (istringstream & src_stream, string & str, char separator)
+{
+    getline (src_stream.buffer, str, separator);
+    return src_stream;
+}
+
+}   // End of namespace std
+
+#endif
+
index c9c3ead1f20c3ec1df854945278d9d27b9fd888c..586f2b65744dbf41863ca77667c2a6bfd01fa6c2 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctrec.cpp,v 1.8 2000/06/13 16:20:31 kevin Exp $
+**  $Id: ctrec.cpp,v 1.9 2000/06/15 19:07:10 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
@@ -106,7 +106,7 @@ ctrec_main (int argc, char * argv[])
   ImageFile *imGlobal = NULL;
   RAYSUM *rsGlobal = NULL;
   char *rs_name, *im_filename = NULL;
-  char remark[MAXREMARK];
+  string remark;
   char filt_name[80];
   char *endptr;
   int opt_verbose = 0;
@@ -211,8 +211,9 @@ ctrec_main (int argc, char * argv[])
     else
       snprintf (filt_name, sizeof(filt_name), "%s", name_of_filter (opt_filter));
   
-    snprintf (remark, sizeof(remark), "Reconstruct: %dx%d, %s, %s, %s",
-            nx, ny, filt_name, name_of_interpolation (opt_interp), name_of_backproj(opt_backproj));
+    ostringstream label;
+    label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
+    remark = label.str();
   
     if (opt_verbose)
       cout << "Remark: " << remark << endl;
@@ -304,8 +305,8 @@ ctrec_main (int argc, char * argv[])
       raysum_close (rsGlobal);
       double calctime = timerProgram.timerEnd();
       imGlobal->arrayDataWrite ();
-      imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, rsGlobal->remark, rsGlobal->calctime);
-      imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark, calctime);
+      imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, rsGlobal->remark.c_str(), rsGlobal->calctime);
+      imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark.c_str(), calctime);
       imGlobal->fileClose ();
       if (opt_verbose)
        cout << "Run time: " << calctime << " seconds" << endl;
index 208de9acd7dd6cb5710984b5602da27530f38f92..3e82eefaadebc2802b5a430352af2f4ef191e13a 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.8 2000/06/13 16:20:31 kevin Exp $
+**  $Id: phm2if.cpp,v 1.9 2000/06/15 19:07:10 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
@@ -104,7 +104,7 @@ int
 phm2if_main (int argc, char* argv[])
 {
   ImageFile* imGlobal = NULL;
-  PHANTOM *phm = NULL;
+  Phantom phm;
   int opt_nx = 0, opt_ny = 0;
   int opt_nsample = 1;
   int opt_phmnum = -1;
@@ -148,7 +148,7 @@ phm2if_main (int argc, char* argv[])
        break;
       case O_PHMFILE:
        strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
-       phm = phm_create_from_file(opt_phmfilename);
+       phm.createFromFile(opt_phmfilename);
 #ifdef HAVE_MPI
        if (mpiWorld.getRank() == 0) 
          cerr << "Can't use phantom from file in MPI mode" << endl;
@@ -225,7 +225,7 @@ phm2if_main (int argc, char* argv[])
       }
     }
     
-    if (phm == NULL && opt_phmnum == -1 && opt_filter == -1) {
+    if (phm.nPElem() == 0 && opt_phmnum == -1 && opt_filter == -1) {
       cerr << "No phantom defined" << endl;
       phm2if_usage(argv[0]);
       return (1);
@@ -308,7 +308,7 @@ phm2if_main (int argc, char* argv[])
 #endif
 
   if (opt_phmnum >= 0)
-      phm = phm_create (opt_phmnum);
+      phm.create (opt_phmnum);
 
 #ifdef HAVE_MPI
   else {
@@ -323,7 +323,7 @@ phm2if_main (int argc, char* argv[])
   if (mpiWorld.getRank() == 0)
     v = imGlobal->getArray ();
 
-  if (phm->type == P_UNIT_PULSE) {
+  if (phm.getComposition() == P_UNIT_PULSE) {
     if (mpiWorld.getRank() == 0) {
       v[opt_nx/2][opt_ny/2] = 1.;
     }
@@ -344,14 +344,14 @@ phm2if_main (int argc, char* argv[])
   }
 #else
   v = imGlobal->getArray ();
-  if (phm->type == P_UNIT_PULSE) {
+  if (phm.getComposition() == P_UNIT_PULSE) {
     v[opt_nx/2][opt_ny/2] = 1.;
   } else if (opt_filter != -1) {
     image_filter_response (*imGlobal, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
   } else {
 #if HAVE_SGP
       if (opt_trace >= TRACE_PHM)
-       phm_show(phm);
+       phm.show();
 #endif
       phm_to_imagefile (phm, *imGlobal, 0, opt_nx, opt_nsample, opt_trace);
   }
@@ -380,8 +380,6 @@ phm2if_main (int argc, char* argv[])
     }
   }
 
-  phm_free (phm);
-
   return (0);
 }
 
index f87f3016b2e5a0f108d5bf60de43839924ac8c68..04593493f8d7ab8f9d477dc405922037f2b703f5 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2rs.cpp,v 1.5 2000/06/13 16:20:31 kevin Exp $
+**  $Id: phm2rs.cpp,v 1.6 2000/06/15 19:07:10 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
@@ -87,12 +87,12 @@ void GatherProjectionsMPI (MPIWorld& mpiWorld, RAYSUM *rsGlobal, RAYSUM *rsLocal
 int 
 phm2rs_main (int argc, char* argv[])
 {
-  DETECTOR *det;
-  PHANTOM *phm = NULL;
+  Detector *det;
+  Phantom phm;
   RAYSUM *rsGlobal = NULL;
   char *opt_outfile = NULL;
-  char opt_desc[MAXREMARK+1];
-  char opt_phmfilename[256];
+  string opt_desc;
+  string opt_phmfilename;
   char *endptr, *endstr;
   int opt_ndet, opt_nview;
   int opt_nray = 1;
@@ -112,8 +112,6 @@ phm2rs_main (int argc, char* argv[])
 #ifdef HAVE_MPI
   if (mpiWorld.getRank() == 0) {
 #endif
-    strcpy(opt_desc, "");
-    strcpy(opt_phmfilename, "");
     while (1) {
       int c = getopt_long(argc, argv, "", phm2rs_options, NULL);
       char *endptr = NULL;
@@ -128,7 +126,7 @@ phm2rs_main (int argc, char* argv[])
          phm2rs_usage(argv[0]);
          return (1);
        }
-       phm = phm_create (opt_phmnum);
+       phm.create (opt_phmnum);
        break;
       case O_PHMFILE:
 #ifdef HAVE_MPI
@@ -136,8 +134,8 @@ phm2rs_main (int argc, char* argv[])
          cerr << "Can not read phantom from file in MPI mode" << endl;
        return (1);
 #endif
-       strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
-       phm = phm_create_from_file(opt_phmfilename);
+       opt_phmfilename = optarg;
+       phm.createFromFile (opt_phmfilename.c_str());
        break;
       case O_VERBOSE:
        opt_verbose = 1;
@@ -153,7 +151,7 @@ phm2rs_main (int argc, char* argv[])
        }
        break;
       case O_DESC:
-       strncpy(opt_desc, optarg, sizeof(opt_desc));
+       opt_desc = optarg;
        break;
       case O_ROTANGLE:
        opt_rotangle = strtod(optarg, &endptr);
@@ -190,7 +188,7 @@ phm2rs_main (int argc, char* argv[])
       }
     }
   
-    if (phm == NULL) {
+    if (phm.nPElem() == 0) {
       cerr << "No phantom defined" << endl;
       phm2rs_usage(argv[0]);
       return (1);
@@ -216,22 +214,17 @@ phm2rs_main (int argc, char* argv[])
       return (1);
     }
 
-    char str[256];
-    snprintf(str, sizeof(str), 
-            "Raysum_Collect: NDet=%d, Nview=%d, NRay=%d, RotAngle=%.2f, ", 
-            opt_ndet, opt_nview, opt_nray, opt_rotangle);
-    if (opt_phmfilename[0]) {
-      strncat(str, "Phantom=", sizeof(str));
-      strncat(str, opt_phmfilename, sizeof(str));
+    ostringstream desc;
+    desc << "Raysum_Collect: NDet=" << opt_ndet << ", Nview=" << opt_nview << ", NRay=" << opt_nray << ", RotAngle=" << opt_rotangle << ", ";
+    if (opt_phmfilename.length()) {
+      desc << "PhantomFile=" << opt_phmfilename;
     } else if (opt_phmnum != -1) {
-      strncat(str, "Phantom=", sizeof(str));
-      strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
+      desc << "Phantom=" << name_of_phantom(opt_phmnum);
     }
-    if (opt_desc[0]) {
-      strncat(str, ": ", sizeof(str));
-      strncat(str, opt_desc, sizeof(str));
+    if (opt_desc.length()) {
+      desc << ": " << opt_desc;
     }
-    strncpy(opt_desc, str, sizeof(opt_desc));
+    opt_desc = desc.str();
 #ifdef HAVE_MPI
   }
 #endif
@@ -247,27 +240,27 @@ phm2rs_main (int argc, char* argv[])
   mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0);
 
   if (mpiWorld.getRank() > 0 && opt_phmnum >= 0)
-    phm = phm_create (opt_phmnum);
+    phm.create (opt_phmnum);
 #endif
 
   opt_rotangle *= PI;
-  det = detector_create (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
+  det = new Detector (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
 
 #ifdef HAVE_MPI
   mpiWorld.setTotalWorkUnits (opt_nview);
 
   if (mpiWorld.getRank() == 0) {
-    rsGlobal = raysum_create_from_det (opt_outfile, det);
+    rsGlobal = raysum_create_from_det (opt_outfile, *det);
     raysum_alloc_views(rsGlobal);
   }
   
-  rsLocal = raysum_create_from_det (NULL, det);
+  rsLocal = raysum_create_from_det (NULL, *det);
   rsLocal->nview = mpiWorld.getMyLocalWorkUnits();
   if (opt_debug)
     cout << "rsLocal->nview = " << rsLocal->nview << " (process " << mpiWorld.getRank() << ")" << endl;;
 
   TimerMPI timerProject (mpiWorld.getComm());
-  raysum_collect (rsLocal, det, phm, mpiWorld.getMyStartWorkUnit(), opt_trace, FALSE);
+  raysum_collect (rsLocal, *det, phm, mpiWorld.getMyStartWorkUnit(), opt_trace, FALSE);
   if (opt_verbose)
     timerProject.timerEndAndReport ("Time to collect projections");
 
@@ -276,8 +269,8 @@ phm2rs_main (int argc, char* argv[])
   if (opt_verbose)
     timerGather.timerEndAndReport ("Time to gather projections");
 #else
-  rsGlobal = raysum_create_from_det (opt_outfile, det);
-  raysum_collect (rsGlobal, det, phm, 0, opt_trace, FALSE);
+  rsGlobal = raysum_create_from_det (opt_outfile, *det);
+  raysum_collect (rsGlobal, *det, phm, 0, opt_trace, FALSE);
 #endif
   
 #ifdef HAVE_MPI
@@ -285,7 +278,7 @@ phm2rs_main (int argc, char* argv[])
 #endif
     {
       rsGlobal->calctime = timerProgram.timerEnd();
-      strncpy (rsGlobal->remark, opt_desc, sizeof(rsGlobal->remark));
+      rsGlobal->remark = opt_desc;
       raysum_write (rsGlobal);
       raysum_close (rsGlobal);
       if (opt_verbose) {
@@ -294,8 +287,7 @@ phm2rs_main (int argc, char* argv[])
       }
     }
 
-  phm_free (phm);
-  detector_free (det);
+  delete det;
 
   return (0);
 }
index 5da8d68e08b85e43938c036659651866d05cc0f2..d82ee0997bd241447a825abea7788f77159fe2ac 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: rs2if.cpp,v 1.5 2000/06/13 16:20:31 kevin Exp $
+**  $Id: rs2if.cpp,v 1.6 2000/06/15 19:07:10 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
@@ -117,7 +117,7 @@ rs2if_main (const int argc, char *const argv[])
     {
       printf ("Number of detectors: %d\n", rs->ndet);
       printf ("    Number of views: %d\n", rs->nview);
-      printf ("             Remark: %s\n", rs->remark);
+      printf ("             Remark: %s\n", rs->remark.c_str());
     }
   
   im = new ImageFile (im_name, rs->ndet, rs->nview);
@@ -138,7 +138,7 @@ rs2if_main (const int argc, char *const argv[])
 
   im->fileCreate ();
   im->arrayDataWrite ();
-  im->labelAdd (Array2dFileLabel::L_HISTORY, rs->remark, rs->calctime);
+  im->labelAdd (Array2dFileLabel::L_HISTORY, rs->remark.c_str(), rs->calctime);
   im->labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .rs to .idf");
   im->fileClose ();