r94: finished c++ conversions
[ctsim.git] / include / ir.h
index e510c75b8ddc332da4a47b2fe7cc6331bfe38965..ffa83fb63d156cb3891d212ae8091f860a31b578 100644 (file)
@@ -1,18 +1,15 @@
 /*****************************************************************************
-**  This is part of the CTSim program
-**  Copyright (C) 1983-2000 Kevin Rosenberg
+** FILE IDENTIFICATION
 **
-**  $Id: ir.h,v 1.3 2000/04/29 23:24:29 kevin Exp $
-**  $Log: ir.h,v $
-**  Revision 1.3  2000/04/29 23:24:29  kevin
-**  *** empty log message ***
+**   Name:          ir.h
+**   Purpose:       Master Image Reconstruction Header
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  July 1, 1984
 **
-**  Revision 1.2  2000/04/28 14:14:16  kevin
-**  *** empty log message ***
-**
-**  Revision 1.1.1.1  2000/04/28 13:02:43  kevin
-**  Initial CVS import for first public release
+**  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 $
 **
 **
 **  This program is free software; you can redistribute it and/or modify
 **  along with this program; if not, write to the Free Software
 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ******************************************************************************/
-/* FILE IDENTIFICATION
- *
- *     Name:         ir.h          Header File for Image Reconstruction System
- *     Programmer:   Kevin Rosenberg
- *     Date Started: 7-1-84
- *     Last Change:  1-20-85
- */
 
 #ifndef IR_H
 #define IR_H
 
-#ifdef MPI_CT
-#define MPI_MAX_PROCESS 128
-struct mpi_ct_st
-{
-  int my_rank;
-  int nproc;
-  int base_local_work_units;
-  int remainder_work_units;
-  int local_work_units[MPI_MAX_PROCESS];
-  int start_work_unit[MPI_MAX_PROCESS];
-  MPI_Comm comm;
-};
-
-extern struct mpi_ct_st mpi_ct;
-void mpi_ct_calc_work_units(const unsigned int global_work_units);
-#endif
-
-
-struct histo_st {
-    int *b;                    /* Histogram array (# of elements in each bin) */
-    int nbin;                  /* Number of histogram bins */
-    double xmin, xmax, xinc;   /* Limits of histogram boundaries */
-};
-
-typedef struct histo_st HISTOGRAM;
 
-/*---------------------------------------------------------------------------*/
+static const int POINTS_PER_CIRCLE=90;
+#define MAXREMARK  99
 
-#define POINTS_PER_CIRCLE  36
+typedef enum {
+  RECTANGLE,
+  TRIANGLE,
+  ELLIPSE,
+  SECTOR,
+  SEGMENT
+} PElmType;
 
-#define MAXREMARK      99
-#define LENREMARK       (MAXREMARK+1)
-#define IMAGE_VAL      FMTX_2D         /* use 2d floating point matrix */
-#define IMAGE_ELEM_TYPE DT_FLOAT       /* use floats for images */
-typedef float IMAGE_ELEM_VAL;          /* use floats for image storing */
 
-struct image_st {
-    IMAGE_VAL v;                       /* values of voxels in matrix form */
-    SDF_2D *dfp_2d;                    /* Pointer to disk image file */
-    int nx, ny;                                /* size of voxel matrix */
-    double xmin, xmax, ymin, ymax;     /* extent of voxel matrix in pic coord */
-    char remark[LENREMARK];            /* description of voxel data */
-    float calctime;                    /* time to calculate voxels in seconds */
+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;
 
-struct object_st {
-    int type;                     /* object type (box, ellipse, etc) */
-    double atten;                 /* X-ray attenuation coefficient */
-    double cx,cy;                 /* center of object */
-    double u,v;                           /* size of object */
-    double rot;                           /* object 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; /* object limits */
-    double radius;                /*   "   */
-    struct {                      /* transform matrices        */
-       GRFMTX_2D p_to_o;          /* map from pic to standard obj coords */
-       GRFMTX_2D o_to_p;          /* map from std object coords to pic coords */
-    } xform;
-    struct object_st *next;      /* pointer to next object in picture */
-};
+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;
 
-typedef struct object_st OBJECT;
 
-struct pic_st {                           /* Picture structure */
-    OBJECT *objlist;              /* object list */
-    int type;
-    int numobj;                           /* number of objects in picture */
-    double xmin, xmax, ymin, ymax; /* extent of objects in object coordinates */
-    double radius;                /*     " "    */
+/* 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;
 
-typedef struct image_st  IMAGE;
-typedef struct pic_st    PICTURE;
-
-#define P_OBJECTS      0       /* Picture made of objects */
-#define P_UNIT_PULSE   1       /* Special picture, not made of objects */
-#define P_FILTER       9       /* defined only by a type */
 
 /*----------------------------------------------------------------------*/
 /*                             RAYSUM SYMBOLS                          */
@@ -126,15 +88,28 @@ typedef struct pic_st    PICTURE;
  * for these detectors is stored in the structure DETECTARRAY
  */
 
-#define DETECT_TYPE float
+typedef float DETECT_TYPE;
 
-struct detarray_st {
+struct DetectorArray
+{
   DETECT_TYPE *detval; /* Pointer to array of values recorded by detector */
-  int ndet;                    /* Number of detectors in array */
+  int ndet;            /* Number of detectors in array */
   double view_angle;    /* View angle in radians */
 };
+typedef struct DetectorArray DETARRAY;
 
-struct detect_st {
+
+typedef enum {
+    DETECTOR_PARALLEL,
+    DETECTOR_EQUIANGLE,
+    DETECTOR_EQUILINEAR
+} ScannerGeometry;
+  
+
+class Detector
+{
+ public:
+  ScannerGeometry geometry;     /* Geometry of detectory */
   int ndet;                    /* Number of detectors in array */
   int nview;                   /* Number of rotated views */
   int nsample;                 /* Number of rays per detector */
@@ -143,22 +118,27 @@ struct detect_st {
   double det_inc;              /* Increment between centers of detectors */
   double rot_inc;              /* Increment in rotation angle between views */
   double radius;               /* Radius of rotation.  Distance from */
-                               /*   center of pic to center of det */
-  double piclen;                /* Maximum Length of picture or area of interest */
+                               /*   center of phm to center of det */
+  double phmlen;                /* Maximum Length of phantom or area of interest */
   struct {
     double xd1,yd1,xd2,yd2;    /* Coordinates of detector endpoints */
     double xs1,ys1,xs2,ys2;    /* Coordinates of source endpoints */
     double angle;              /* Starting angle */
   } init;
 };
+typedef class Detector DETECTOR;
 
-struct raysum_st {
-  int fd;
-  int file_mode;
-  int header_size;
-  struct detarray_st **view;   /* Pointer to array of detarray_st pointers */
 
-  char remark[LENREMARK];      /* description of raysum data */
+class Projections
+{
+ public:
+  int fd;                      /* Disk file descriptor */
+  int file_mode;               /* Current file mode (read or write) */
+  int header_size;             /* Size of disk file header */
+  int geometry;                        /* Geometry of scanner */
+  struct DetectorArray **view; /* Pointer to array of detarray_st pointers */
+
+  char remark[MAXREMARK+1];    /* description of raysum data */
   double calctime;             /* time required to calculate raysums */
 
   int ndet;                    /* number of detectors in array */
@@ -166,304 +146,218 @@ struct raysum_st {
   double rot_start;            /* starting view rotation */
   double rot_inc;              /* angle between rotations */
   double det_start;            /* distance of beginning detector to center */
-                               /*    of picture */
+                               /*    of PHANTOM */
   double det_inc;              /* increment between detectors */
-  double piclen;               /* Length of picture edge (pic is square) */
+  double phmlen;               /* Length of PHANTOM edge (phm is square) */
 };
+typedef class Projections  RAYSUM;
 
-typedef struct detarray_st DETARRAY;
-typedef struct detect_st   DETECTOR;
-typedef struct raysum_st   RAYSUM;
 
 /*----------------------------------------------------------------------*/
 /*                             USER SYMBOLS                            */
 /*----------------------------------------------------------------------*/
 
-/* codes for object types, passed to add_obj() */
-
-#define O_RECTANGLE  1
-#define O_TRIANGLE   2
-#define O_ELLIPSE    3
-#define O_SECTOR     4
-#define O_SEGMENT    5
-
 /* Codes for Coordinate Types      */
-/* Defines coords for inside_obj() */
+/* Defines coords for pelm_is_point_inside() */
 
-#define OBJ_COORD -1           /* Normalized Object Coordinates */
-#define PIC_COORD -2           /* User's Picture Coordinates */
+typedef enum {
+  PELM_COORD,         /* Normalized Pelm Coordinates */
+  PHM_COORD           /* User's phantom Coordinates */
+} CoordType;
 
 /* Codes for Filter types */
 
-#define W_BANDLIMIT    1       /* filter types for genfilter() */
-#define W_SINC         2
-#define W_G_HAMMING    3
-#define W_COSINE       4
-#define W_TRIANGLE     5
-
-#define W_A_BANDLIMIT  11      /* filters times abs() of function */
-#define W_A_SINC       12
-#define W_AG_HAMMING   13
-#define W_A_COSINE     14
-
-#define W_SHEPP         21
+typedef enum {         /* filter types for filter_generate() */
+  FILTER_BANDLIMIT, 
+  FILTER_SINC,
+  FILTER_G_HAMMING,
+  FILTER_COSINE,
+  FILTER_TRIANGLE,
+  FILTER_ABS_BANDLIMIT,        /* filter times |x| */
+  FILTER_ABS_SINC, 
+  FILTER_ABS_G_HAMMING,
+  FILTER_ABS_COSINE,
+  FILTER_SHEPP
+} FilterType;
 
 /* function domains */
 
-#define O_FREQ_STR      "freq"
-#define O_SPATIAL_STR   "spatial"
+static const char D_FREQ_STR[]=    "freq";
+static const char D_SPATIAL_STR[]= "spatial";
  
-#define D_FREQ         1       /* Domain names */
-#define D_SPATIAL      2
+typedef enum {
+  D_FREQ = 1,
+  D_SPATIAL 
+} DomainType;
 
-/* function symmetry */
-
-#define FUNC_EVEN      1       /* function types, f[-n] = f[n] */
-#define FUNC_ODD       2       /* f[-n] = -f[n] */
-#define FUNC_BOTH      3       /* function has both odd & even components */
+typedef enum {
+    FUNC_EVEN = 1,    /* function types, f[-n] = f[n] */
+    FUNC_ODD,     /* f[-n] = -f[n] */
+    FUNC_BOTH    /* function has both odd & even components */
+} FunctionSymmetry;
 
 /* interpolation methods */
-
-#define I_NEAREST      1       /* Interpolation methods */
-#define I_LINEAR       2       /* Linear interpolation */
-#define I_BSPLINE       3
-#define I_1BSPLINE      3      /* 1st order B-Spline */
-#define I_2BSPLINE      4
-#define I_3BSPLINE      5
-
-/* Constants for sizing picture */
-
-#define PERCENT_PIC_SIZE_INCR   0.0    /* Fractional increase in picture */
-                                       /* limits compared to object size */
-#define N_EXTRA_DETECTORS         4    /* Number of extra detectors */
-                                       /* widths when calculating detlen */
-
-#define DET_PARALLEL 1
-#define DET_FAN      2
-
-#define O_TRACE_NONE_STR     "none"
-#define O_TRACE_TEXT_STR     "text"
-#define O_TRACE_PIC_STR      "pic"
-#define O_TRACE_RAYS_STR     "rays"
-#define O_TRACE_PLOT_STR     "plot"
-#define O_TRACE_CLIPPING_STR "clipping"
-
-
-#define TRACE_NONE     0               /* No tracing */
-#define TRACE_TEXT     1               /* Minimal status */
-#define TRACE_PIC      2               /* Show picture */
-#define TRACE_RAYS     3               /* Show all rays */
-#define TRACE_PLOT     4               /* Plot raysums */
-#define TRACE_CLIPPING 5               /* Plot clipping */
-
-#define O_PIC_HERMAN    1               /* Herman head phantom */
-#define O_PIC_ROWLAND   2               /* Rowland head phantom */
-#define O_PIC_BROWLAND  3               /* Bordered Rowland head phantom */
-#define O_PIC_UNITPULSE 4               /* Unit pulse phantom */
-
-#define O_PIC_HERMAN_STR    "herman"
-#define O_PIC_ROWLAND_STR   "rowland"
-#define O_PIC_BROWLAND_STR  "browland"
-#define O_PIC_UNITPULSE_STR "unitpulse"
-
-#define O_INTERP_NEAREST_STR  "nearest"
-#define O_INTERP_LINEAR_STR   "linear"
-#define O_INTERP_BSPLINE_STR  "bspline"
-
-#define O_FILTER_ABS_BANDLIMIT_STR "abs_bandlimit"
-#define O_FILTER_ABS_SINC_STR      "abs_sinc"
-#define O_FILTER_ABS_COS_STR       "abs_cos"
-#define O_FILTER_ABS_HAMMING_STR   "abs_hamming"
-#define O_FILTER_SHEPP_STR         "shepp"
-#define O_FILTER_BANDLIMIT_STR     "bandlimit"
-#define O_FILTER_SINC_STR          "sinc"
-#define O_FILTER_COS_STR           "cos"
-#define O_FILTER_HAMMING_STR       "hamming"
-#define O_FILTER_TRIANGLE_STR      "triangle"
-
-#define O_BPROJ_TRIG   1 
-#define O_BPROJ_TABLE  2
-#define O_BPROJ_DIFF   3
-#define O_BPROJ_DIFF2  4
-#define O_BPROJ_IDIFF2 5
-
-#define O_BPROJ_TRIG_STR     "trig"
-#define O_BPROJ_TABLE_STR    "table"
-#define O_BPROJ_DIFF_STR     "diff"
-#define O_BPROJ_DIFF2_STR    "diff2"
-#define O_BPROJ_IDIFF2_STR   "idiff2"
-
-#define RS_TRACE_ROW_TITLE     1
-#define RS_TRACE_ROW_TITLE2    2
-#define RS_TRACE_ROW_PHANT_ID  4
-#define RS_TRACE_ROW_CHROMATIC 7
-#define RS_TRACE_ROW_SCATTER   8
-#define RS_TRACE_ROW_PHOT_STAT 9
-#define RS_TRACE_ROW_NDET      12
-#define RS_TRACE_ROW_NVIEW     13
-#define RS_TRACE_ROW_SAMPLES   14
-#define RS_TRACE_ROW_CURR_VIEW 17
-#define RS_TRACE_ROW_ATTEN     18
-
-
-/*----------------------------------------------------------------------*/
-/*                     GRAY SCALE STRUCTURES                           */
-/*----------------------------------------------------------------------*/
-
-#define GS_MAX_CELL_SIZE   4
-
-typedef int GS_BITMASK[4][4];
-
-struct greyscale_st {
-    int dev;                           /* Device to output to */
-    int (*dotfunc)(int x, int y, int color);                   /* Pointer to dot function for device */
-    int cur_x, cur_y;                  /* Current cell location */
-    int nxcell, nycell;                        /* size of cell in pixels */
-    int xmin, ymin;                    /* starting position of grey scale */
-    int num_color;                     /* Number of primary colors available */
-    int num_intens;                    /* Number of intensities available */
-    int max_level;                     /* gs levels range from 0 to max_level */
-    char *fg_color_tbl;                        /* Hold foreground color for each level */
-    char *bg_color_tbl;                        /* Holds background color */
-    char *level_sub_tbl;               /* Holds value to subtract for level */
-                                       /* before accessing bit mask */
-    GS_BITMASK *bm;                    /* Holds grey-scale bit mask */
-    struct greyscale_st *next_dev;     /* Pointer to next open device */
-                                       /* == NULL when no more devices */
+#undef HAVE_BSPLINE_INTERP
+typedef enum {     /* Interpolation methods */
+  I_NEAREST = 1,       /* Nearest neighbor */
+#if HAVE_BSPLINE_INTERP
+  I_BSPLINE,
+  I_1BSPLINE,      /* 1st order B-Spline */
+  I_2BSPLINE,
+  I_3BSPLINE,
+#endif
+  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";
+static const char O_TRACE_TEXT_STR[]=     "text";
+static const char O_TRACE_PHM_STR[]=      "phm";
+static const char O_TRACE_RAYS_STR[]=     "rays";
+static const char O_TRACE_PLOT_STR[]=     "plot";
+static const char O_TRACE_CLIPPING_STR[]= "clipping";
+
+enum {
+  TRACE_NONE,          /* No tracing */
+  TRACE_TEXT,          /* Minimal status */
+  TRACE_PHM,           /* Show phantom */
+  TRACE_RAYS,          /* Show all rays */
+  TRACE_PLOT,          /* Plot raysums */
+  TRACE_CLIPPING       /* Plot clipping */
 };
 
-typedef struct greyscale_st GREYSCALE;
-
-
-/* From reconstr.c */
-IMAGE *image_reconst (IMAGE *im, RAYSUM *rs, int filt_type, double filt_param, int interp_type, int interp_param, const int backproj_type, int ir_trace);
-
-/* From bproj.c */
-void backproj_init (const RAYSUM *rs, IMAGE *im, const int bproj_method);
-int  backproj_calc (const RAYSUM *rs, IMAGE *im, const double *t, const double view_angle, 
-                   const int interp_type, const int bproj_method);
-void backproj_term (const RAYSUM *rs, IMAGE *im, const int bproj_method);
-
-void backproj_init_trig (const RAYSUM *rs, IMAGE *im);
-int  backproj_calc_trig (const RAYSUM *rs, IMAGE *im, const double *t, 
-                        const double view_angle, const int interp_type);
-void backproj_term_trig (const RAYSUM *rs, IMAGE *im);
-void backproj_init_table (const RAYSUM *rs, IMAGE *im);
-int  backproj_calc_table (const RAYSUM *rs, IMAGE *im, const double *t, 
-                         const double view_angle, const int interp_type);
-void backproj_term_table (const RAYSUM *rs, IMAGE *im);
-void backproj_init_d (const RAYSUM *rs, IMAGE *im);
-int  backproj_calc_d (const RAYSUM *rs, IMAGE *im, const double *t, 
-                     const double view_angle, const int interp_type);
-void backproj_term_d (const RAYSUM *rs, IMAGE *im);
-void backproj_init_d2 (const RAYSUM *rs, IMAGE *im);
-int  backproj_calc_d2 (const RAYSUM *rs, IMAGE *im, const double *t, 
-                      const double view_angle, const int interp_type);
-void backproj_term_d2 (const RAYSUM *rs, IMAGE *im);
-void backproj_init_id (const RAYSUM *rs, IMAGE *im);
-int  backproj_calc_id (const RAYSUM *rs, IMAGE *im, const double *t, 
-                      const double view_angle, const int interp_type);
-void backproj_term_id (const RAYSUM *rs, IMAGE *im);
-void backproj_init_id2 (const RAYSUM *rs, IMAGE *im);
-int  backproj_calc_id2 (const RAYSUM *rs, IMAGE *im, const double *t, 
-                       const double view_angle, const int interp_type);
-void backproj_term_id2 (const RAYSUM *rs, IMAGE *im);
-
-void usage (const char *program);
-int main(const int argc, char * const argv[]);
-
-
-
-/* bspline.c */
-int bspline(int samples, int zoom_factor, int spline_order, double input[], double output[]);
-/* clip.c */
-int inside_obj(const OBJECT *obj, double x, double y, const int coord_type);
-int clipsegment(double *x1, double *y1, double *x2, double *y2, const double u, const double v);
-int clipsector(double *x1, double *y1, double *x2, double *y2, const double u, const double v);
-int clipcircle(double *x1, double *y1, double *x2, double *y2, const double cx, const double cy, const double radius, double t1, double t2);
-int cliptriangle(double *x1, double *y1, double *x2, double *y2, const double u, const double v, const int clip_xaxis);
-/* convolve.c */
-double convolve(const double f1[], const double f2[], const double dx, const int n, const int np, const int func_type);
-double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np);
-/* ctsub.c */
-OBJECT *alloc_obj(int n);
-void dminmax(const double array[], const int pts, double *xmin, double *xmax);
-void rotate2d(double x[], double y[], int pts, double angle);
-void xlat2d(double x[], double y[], int pts, double xoffset, double yoffset);
-void scale2d(double x[], double y[], int pts, double xfact, double yfact);
-int circle_pts(double theta);
-/* filt.c */
-const char *interp_name_of(int interp_type);
-const char *filter_name_of(int filt_type);
-int interp_select(void);
-int filter_select(double *filt_param);
-double d_filtfunc(int filt_type, double x, double bw, double param, int n);
-double filter_freq(int filt_type, double u, double bw, double param);
-double a_filtfunc(int filt_type, double x, double bw, double param);
-double sinc(double x, double mult);
-double abscos_int(double u, double w);
-double *filter_generate(int filt_type, double bw, double xmin, double xmax, int n, double param, int domain, int numint);
-void image_filter_init(IMAGE *im, int domain, double bw, int filt_type, double filt_param, int opt_trace);
-/* im_draw.c */
-void image_show(IMAGE *im, int nxcell, int nycell, double densmin, double densmax, bool disp_scale);
-int image_paint(int dev, IMAGE *im, int xmin, int ymin, int nxcell, int nycell, double densmin, double densmax, bool disp_scale);
-int gs_image(GREYSCALE *gs, IMAGE *im, double densmin, double densmax, bool disp_scale);
-void paint_cscale(GREYSCALE *gs, int nx, int ny);
-GREYSCALE *gs_init(int dev, int xmin, int ymin, int nxcell, int nycell);
-void gs_pixel(GREYSCALE *gs, int x, int y, int gs_level);
-void gs_set_pos(GREYSCALE *gs, int x, int y);
-void gs_set_at_addr(GREYSCALE *gs, int gs_level);
-void gs_set_color_scale(void);
-/* image.c */
-IMAGE *image_create(const char *fname, const int nx, const int ny);
-int image_clear(IMAGE *im);
-int image_save(IMAGE *im);
-IMAGE *image_load(const char *fname);
-/* ir_vars.c */
-/* options.c */
-int opt_set_trace(const char *optarg, const char *program);
-const char *name_of_picture(const int picnum);
-int opt_set_picture(const char *optarg, const char *program);
-int opt_set_interpolation(const char *optarg, const char *program);
-int opt_set_filter(const char *optarg, const char *program);
+typedef enum {
+  O_PHM_HERMAN,               /* Herman head phantom */
+  O_PHM_ROWLAND,              /* Rowland head phantom */
+  O_PHM_BROWLAND,             /* Bordered Rowland head phantom */
+  O_PHM_UNITPULSE             /* Unit pulse phantom */
+} PhantomType;
+
+static const char O_PHM_HERMAN_STR[]=    "herman";
+static const char O_PHM_ROWLAND_STR[]=   "rowland";
+static const char O_PHM_BROWLAND_STR[]=  "browland";
+static const char O_PHM_UNITPULSE_STR[]= "unitpulse";
+
+static const char O_INTERP_NEAREST_STR[]=  "nearest";
+static const char O_INTERP_LINEAR_STR[]=   "linear";
+static const char O_INTERP_BSPLINE_STR[]=  "bspline";
+
+static const char O_FILTER_ABS_BANDLIMIT_STR[]= "abs_bandlimit";
+static const char O_FILTER_ABS_SINC_STR[]=      "abs_sinc";
+static const char O_FILTER_ABS_COS_STR[]=       "abs_cos";
+static const char O_FILTER_ABS_HAMMING_STR[]=   "abs_hamming";
+static const char O_FILTER_SHEPP_STR[]=         "shepp";
+static const char O_FILTER_BANDLIMIT_STR[]=     "bandlimit";
+static const char O_FILTER_SINC_STR[]=          "sinc";
+static const char O_FILTER_COS_STR[]=           "cos";
+static const char O_FILTER_HAMMING_STR[]=       "hamming";
+static const char O_FILTER_TRIANGLE_STR[]=      "triangle";
+
+typedef  enum {
+  O_BPROJ_TRIG,
+  O_BPROJ_TABLE,
+  O_BPROJ_DIFF,
+  O_BPROJ_DIFF2,
+  O_BPROJ_IDIFF2
+} BackprojType;
+
+static const char O_BPROJ_TRIG_STR[]=     "trig";
+static const char O_BPROJ_TABLE_STR[]=    "table";
+static const char O_BPROJ_DIFF_STR[]=     "diff";
+static const char O_BPROJ_DIFF2_STR[]=    "diff2";
+static const char O_BPROJ_IDIFF2_STR[]=   "idiff2";
+
+const static int RAYSUM_TRACE_ROW_TITLE=1;
+const static int RAYSUM_TRACE_ROW_TITLE2=2;
+const static int RAYSUM_TRACE_ROW_PHANT_ID=4;
+const static int RAYSUM_TRACE_ROW_CHROMATIC=7;
+const static int RAYSUM_TRACE_ROW_SCATTER=8;
+const static int RAYSUM_TRACE_ROW_PHOT_STAT=9;
+const static int RAYSUM_TRACE_ROW_NDET=12;
+const static int RAYSUM_TRACE_ROW_NVIEW=13;
+const static int RAYSUM_TRACE_ROW_SAMPLES=14;
+const static int RAYSUM_TRACE_ROW_CURR_VIEW=17;
+const static int RAYSUM_TRACE_ROW_ATTEN=18;
+
+
+
+/*************************************************************************
+ *  FUNCTION DECLARATIONS
+ ************************************************************************/
+
+/* convolve.cpp */
+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);
+int interpolation_select (void);
+int filter_select (double *filter_param);
+
+/* filter.cpp */
+double *filter_generate (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
+double filter_spatial_response_calc (int filt_type, double x, double bw, double param, int n);
+double filter_spatial_response_analytic (int filt_type, double x, double bw, double param);
+double filter_frequency_response (int filt_type, double u, double bw, double param);
+double sinc (double x, double mult);
+double integral_abscos(double u, double w);
+
+/* options.cpp */
+int opt_set_trace(const char *optarg);
+const char *name_of_phantom(const int phmid);
+int opt_set_phantom(const char *optarg);
+InterpolationType opt_set_interpolation(const char *optarg);
+const char *name_of_interpolation(int interp_type);
+FilterType opt_set_filter(const char *optarg);
 const char *name_of_filter(const int filter);
-int opt_set_filter_domain(const char *optarg, const char *program);
-const char *name_of_filter_domain(const int domain);
-int opt_set_backproj(const char *optarg, const char *program);
-const char *name_of_backproj(const int backproj);
-/* pic.c */
-PICTURE *select_pic(void);
-PICTURE *create_pic_from_file(const char *fname);
-PICTURE *create_pic(const int picnum);
-PICTURE *init_pic(void);
-int add_objs_kb(PICTURE *pic);
-int add_objs_file(PICTURE *pic, const char *fname);
-void addobject(PICTURE *pic, const int type, const double cx, const double cy, 
+DomainType opt_set_filter_domain(const char *optarg);
+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 makeobjpts(OBJECT *obj);
-void makeobjxform(OBJECT *obj);
+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);
-void prt_pic(PICTURE *pic);
-void show_pic(const PICTURE *pic);
-void draw_pic(const PICTURE *pic);
-/* pic2image.c */
-void pic_to_image(const PICTURE *pic, IMAGE *im, const int col_start, const int col_count,
-                 const int nsample, const int trace);
-/* ray.c */
-void rs_trace_showprm (const char *label, const char *fmt, int row, int color, ...);
-DETECTOR *detect_create(const PICTURE *pic, int ndet, int nview, int nsample, const double rot_anglen);
-void detect_free(DETECTOR *det);
-int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PICTURE *pic, const int start_view, 
-                  const int trace, const int unit_pulse);
-void rayview(const PICTURE *pic, 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 calc_rsum(const PICTURE *pic, const double x1, const double y1, const double x2, const double y2);
-double calc_objsum(const OBJECT *obj, const double x1, const double y1, const double x2, const double y2);
-int clipobj(const OBJECT *obj, double *x1, double *y1, double *x2, double *y2);
-/* rayio.c */
+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);
+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_open(const char *filename);
@@ -475,21 +369,53 @@ int raysum_read_header(RAYSUM *rs);
 int raysum_write_header(RAYSUM *rs);
 int raysum_read(RAYSUM *rs);
 int raysum_write(RAYSUM *rs);
+void raysum_print(const RAYSUM *rs);
+void raysum_print_info(const RAYSUM *rs);
 DETARRAY *detarray_alloc(const int n);
 void detarray_free(DETARRAY *darray);
 int detarray_read(RAYSUM *rs, DETARRAY *darray, const int view_num);
 int detarray_write(RAYSUM *rs, const DETARRAY *darray, const int view_num);
-int raysum_print(const RAYSUM *rs);
-/* phantom.c */
-void herm_head(PICTURE *pic);
-void row_head(PICTURE *pic);
-void row_bord_head(PICTURE *pic);
-/* xform.c */
-void indent_mtx2(GRFMTX_2D m);
-void xlat_mtx2(GRFMTX_2D m, const double x, const double y);
-void scale_mtx2(GRFMTX_2D m, const double sx, const double sy);
-void rot_mtx2(GRFMTX_2D m, const double theta);
-void mult_mtx2(GRFMTX_2D m1, GRFMTX_2D m2, GRFMTX_2D result);
-void xform_mtx2(GRFMTX_2D m, double *x, double *y);
+
+/* 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);
+
+/* image.cpp */
+void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);
+int image_display (const ImageFile& im);
+int image_display_scale (const ImageFile& im, const int scale, const double pmin, const double pmax);
+
+/* From reconstr.cpp */
+ImageFile& proj_reconst (ImageFile& im, RAYSUM *rs, const FilterType filt_type, double filt_param, InterpolationType interp_type, int interp_param, const BackprojType backproj_type, int const ir_trace);
+
+/* From bproj.cpp */
+void backproj_init (const RAYSUM *rs, ImageFile& im, const BackprojType bproj_method);
+int  backproj_calc (const RAYSUM *rs, ImageFile& im, const double *t, const double view_angle, const int interp_type, const int bproj_method);
+void backproj_term (const RAYSUM *rs, ImageFile& im, const int bproj_method);
+
+void backproj_init_trig (const RAYSUM *rs, ImageFile& im);
+int  backproj_calc_trig (const RAYSUM *rs, ImageFile& im, const double *t, 
+                        const double view_angle, const int interp_type);
+void backproj_term_trig (const RAYSUM *rs, ImageFile& im);
+void backproj_init_table (const RAYSUM *rs, ImageFile& im);
+int  backproj_calc_table (const RAYSUM *rs, ImageFile& im, const double *t, 
+                         const double view_angle, const int interp_type);
+void backproj_term_table (const RAYSUM *rs, ImageFile& im);
+void backproj_init_d (const RAYSUM *rs, ImageFile& im);
+int  backproj_calc_d (const RAYSUM *rs, ImageFile& im, const double *t, 
+                     const double view_angle, const int interp_type);
+void backproj_term_d (const RAYSUM *rs, ImageFile& im);
+void backproj_init_d2 (const RAYSUM *rs, ImageFile& im);
+int  backproj_calc_d2 (const RAYSUM *rs, ImageFile& im, const double *t, 
+                      const double view_angle, const int interp_type);
+void backproj_term_d2 (const RAYSUM *rs, ImageFile& im);
+void backproj_init_id (const RAYSUM *rs, ImageFile& im);
+int  backproj_calc_id (const RAYSUM *rs, ImageFile& im, const double *t, 
+                      const double view_angle, const int interp_type);
+void backproj_term_id (const RAYSUM *rs, ImageFile& im);
+void backproj_init_id2 (const RAYSUM *rs, ImageFile& im);
+int  backproj_calc_id2 (const RAYSUM *rs, ImageFile& im, const double *t, 
+                       const double view_angle, const int interp_type);
+void backproj_term_id2 (const RAYSUM *rs, ImageFile& im);
 
 #endif