r70: added imagefiles
[ctsim.git] / include / ir.h
index cae88b6f645ec42aa40ed0e5f53aef31b82e4d3c..0a04c795d74bb149107c832af9b31cbf329711a5 100644 (file)
@@ -2,8 +2,35 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ir.h,v 1.10 2000/05/04 18:16:34 kevin Exp $
+**  $Id: ir.h,v 1.19 2000/06/07 00:59:38 kevin Exp $
 **  $Log: ir.h,v $
+**  Revision 1.19  2000/06/07 00:59:38  kevin
+**  added imagefiles
+**
+**  Revision 1.18  2000/06/05 01:32:45  kevin
+**  Added C++ compatibility
+**
+**  Revision 1.17  2000/06/03 06:29:08  kevin
+**  *** empty log message ***
+**
+**  Revision 1.16  2000/05/24 22:48:17  kevin
+**  First functional version of SDF library for X-window
+**
+**  Revision 1.15  2000/05/16 04:33:17  kevin
+**  Updated documentation
+**
+**  Revision 1.14  2000/05/11 14:07:00  kevin
+**  Added support for Windows NT
+**
+**  Revision 1.13  2000/05/08 20:00:48  kevin
+**  ANSI C changes
+**
+**  Revision 1.12  2000/05/07 12:46:19  kevin
+**  made c++ compatible
+**
+**  Revision 1.11  2000/05/05 02:37:31  kevin
+**  renamed phmelm to pelm
+**
 **  Revision 1.10  2000/05/04 18:16:34  kevin
 **  renamed filter definitions
 **
 **  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
+
+/*     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
+#define MPI_MAX_PROCESS 128 
 struct mpi_ct_st
 {
   int my_rank;
@@ -88,56 +113,61 @@ typedef struct histo_st HISTOGRAM;
 
 /*---------------------------------------------------------------------------*/
 
-#define POINTS_PER_CIRCLE  36
+static const int POINTS_PER_CIRCLE=90;
+#define MAXREMARK  99
 
-#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 */
+typedef FMTX_2D         IMAGE_ARRAY;    /* use 2d floating point matrix */
+typedef float           IMAGE_ELEM_VAL;        /* use floats for image storing */
 
 struct image_st {
-    IMAGE_VAL v;                       /* values of voxels in matrix form */
+    IMAGE_ARRAY 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 phm coord */
-    char remark[LENREMARK];            /* description of voxel data */
+    char remark[MAXREMARK+1];          /* description of voxel data */
     float calctime;                    /* time to calculate voxels in seconds */
 };
+typedef struct image_st  IMAGE;
+
+typedef enum {
+  RECTANGLE,
+  TRIANGLE,
+  ELLIPSE,
+  SECTOR,
+  SEGMENT
+} PElmType;
 
-struct phmelm_st {
-    int type;               /* phmelm type (box, ellipse, etc) */
+struct pelm_st {
+    PElmType type;          /* pelm type (box, ellipse, etc) */
     double atten;           /* X-ray attenuation coefficient */
-    double cx,cy;           /* center of phmelm */
-    double u,v;                     /* size of phmelm */
-    double rot;                     /* phmelm rotation angle (in radians) */
+    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; /* phmelm limits */
+    double xmin, xmax, ymin, ymax; /* pelm limits */
     double radius;          /*   "   */
-    struct {                /* transform matrices      */
-       GRFMTX_2D p_to_o;    /* map from phantom to standard phmelm coords */
-       GRFMTX_2D o_to_p;    /* map from std phmelm coords to phantom coords */
-    } xform;
-    struct phmelm_st *next;  /* pointer to next phmelm in phantom */
+    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 */
+    struct pelm_st *next;    /* pointer to next pelm in phantom */
 };
-
-typedef struct phmelm_st PHMELM;
-
-struct phm_st {                     /* Phantom structure */
-    PHMELM *phmelm_list;     /* phmelm linked-list */
-    int type;
-    int n_pelm;                     /* number of phmelms in phantom */
-    double xmin, xmax, ymin, ymax; /* extent of phmelms in phmelm coordinates */
-    double radius;           /*     " "    */
+typedef struct pelm_st 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;
+
+struct phm_st {                           /* Phantom structure */
+    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 struct image_st  IMAGE;
 typedef struct phm_st    PHANTOM;
 
-#define P_PHMELMS      0       /* Phantom made of phmelms */
-#define P_UNIT_PULSE   1       /* Special PHANTOM, not made of phmelms */
-#define P_FILTER       9       /* defined only by a type */
 
 /*----------------------------------------------------------------------*/
 /*                             RAYSUM SYMBOLS                          */
@@ -147,20 +177,24 @@ typedef struct phm_st    PHANTOM;
  * for these detectors is stored in the structure DETECTARRAY
  */
 
-#define DETECT_TYPE float
+typedef float DETECT_TYPE;
 
 struct detarray_st {
   DETECT_TYPE *detval; /* Pointer to array of values recorded by detector */
   int ndet;            /* Number of detectors in array */
   double view_angle;    /* View angle in radians */
 };
+typedef struct detarray_st DETARRAY;
 
-#define DETECTOR_PARALLEL   1
-#define DETECTOR_EQUIANGLE  2
-#define DETECTOR_EQUILINEAR 3
 
+typedef enum {
+    DETECTOR_PARALLEL,
+    DETECTOR_EQUIANGLE,
+    DETECTOR_EQUILINEAR
+} ScannerGeometry;
+  
 struct detector_st {
-  int geometry;                 /* Geometry of detectory */
+  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 */
@@ -170,22 +204,23 @@ struct detector_st {
   double rot_inc;              /* Increment in rotation angle between views */
   double radius;               /* Radius of rotation.  Distance from */
                                /*   center of phm to center of det */
-  double phmlen;                /* Maximum Length of PHANTOM or area of interest */
+  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 struct detector_st DETECTOR;
 
 struct raysum_st {
-  int fd;
-  int file_mode;
-  int header_size;
-  int geometry;
+  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 detarray_st **view;   /* Pointer to array of detarray_st pointers */
 
-  char remark[LENREMARK];      /* description of raysum data */
+  char remark[MAXREMARK+1];    /* description of raysum data */
   double calctime;             /* time required to calculate raysums */
 
   int ndet;                    /* number of detectors in array */
@@ -197,171 +232,154 @@ struct raysum_st {
   double det_inc;              /* increment between detectors */
   double phmlen;               /* Length of PHANTOM edge (phm is square) */
 };
-
-typedef struct detarray_st DETARRAY;
-typedef struct detector_st DETECTOR;
 typedef struct raysum_st   RAYSUM;
 
 /*----------------------------------------------------------------------*/
 /*                             USER SYMBOLS                            */
 /*----------------------------------------------------------------------*/
 
-/* codes for phmelm 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 pelm_is_point_inside() */
 
-#define PELM_COORD -1          /* Normalized Phmelm Coordinates */
-#define PHM_COORD -2           /* User's PHANTOM Coordinates */
+typedef enum {
+  PELM_COORD,         /* Normalized Pelm Coordinates */
+  PHM_COORD           /* User's phantom Coordinates */
+} CoordType;
 
 /* Codes for Filter types */
 
-#define FILTER_BANDLIMIT       1       /* filter types for genfilter() */
-#define FILTER_SINC            2
-#define FILTER_G_HAMMING       3
-#define FILTER_COSINE          4
-#define FILTER_TRIANGLE                5
-#define FILTER_ABS_BANDLIMIT   11      /* filters times abs() of function */
-#define FILTER_ABS_SINC                12
-#define FILTER_ABS_G_HAMMING   13
-#define FILTER_ABS_COSINE      14
-#define FILTER_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
+#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 */
 
-#define PERCENT_PHM_SIZE_INCR   0.0    /* Fractional increase in PHANTOM */
-                                       /* limits compared to phmelm size */
-#define N_EXTRA_DETECTORS         4    /* Number of extra detectors */
-                                       /* widths when calculating detlen */
-
-#define O_TRACE_NONE_STR     "none"
-#define O_TRACE_TEXT_STR     "text"
-#define O_TRACE_PHM_STR      "phm"
-#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_PHM      2               /* Show PHANTOM */
-#define TRACE_RAYS     3               /* Show all rays */
-#define TRACE_PLOT     4               /* Plot raysums */
-#define TRACE_CLIPPING 5               /* Plot clipping */
-
-#define O_PHM_HERMAN    1               /* Herman head phantom */
-#define O_PHM_ROWLAND   2               /* Rowland head phantom */
-#define O_PHM_BROWLAND  3               /* Bordered Rowland head phantom */
-#define O_PHM_UNITPULSE 4               /* Unit pulse phantom */
-
-#define O_PHM_HERMAN_STR    "herman"
-#define O_PHM_ROWLAND_STR   "rowland"
-#define O_PHM_BROWLAND_STR  "browland"
-#define O_PHM_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 RAYSUM_TRACE_ROW_TITLE 1
-#define RAYSUM_TRACE_ROW_TITLE2        2
-#define RAYSUM_TRACE_ROW_PHANT_ID      4
-#define RAYSUM_TRACE_ROW_CHROMATIC     7
-#define RAYSUM_TRACE_ROW_SCATTER       8
-#define RAYSUM_TRACE_ROW_PHOT_STAT     9
-#define RAYSUM_TRACE_ROW_NDET  12
-#define RAYSUM_TRACE_ROW_NVIEW 13
-#define RAYSUM_TRACE_ROW_SAMPLES       14
-#define RAYSUM_TRACE_ROW_CURR_VIEW     17
-#define RAYSUM_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 */
+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;
+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
+ ************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
 
+void usage (const char *program);
 
 /* 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);
+IMAGE *image_reconst (IMAGE *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.c */
-void backproj_init (const RAYSUM *rs, IMAGE *im, const int bproj_method);
+void backproj_init (const RAYSUM *rs, IMAGE *im, const BackprojType 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);
@@ -391,16 +409,11 @@ 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[]);
 
 /* 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(const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
 double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np);
 
 /* dialogs.c */
@@ -410,7 +423,7 @@ int interpolation_select(void);
 int filter_select(double *filter_param);
 
 /* filter.c */
-double *filter_generate(int filt_type, double bw, double xmin, double xmax, int n, double param, int domain, int numint);
+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);
@@ -422,37 +435,40 @@ 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);
-void image_filter_response(IMAGE *im, int domain, double bw, int filt_type, double filt_param, int opt_trace);
+void image_filter_response(IMAGE *im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);
+int image_display (const IMAGE *im);
+int image_display_scale (const IMAGE *im, const int scale, const double pmin, const double pmax);
 
 /* options.c */
-int opt_set_trace(const char *optarg, const char *program);
+int opt_set_trace(const char *optarg);
 const char *name_of_phantom(const int phmid);
-int opt_set_phantom(const char *optarg, const char *program);
-int opt_set_interpolation(const char *optarg, const char *program);
+int opt_set_phantom(const char *optarg);
+int opt_set_interpolation(const char *optarg);
 const char *name_of_interpolation(int interp_type);
-int opt_set_filter(const char *optarg, const char *program);
+int 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);
+DomainType opt_set_filter_domain(const char *optarg);
+const char *name_of_filter_domain(const DomainType domain);
+int opt_set_backproj(const char *optarg);
+const char *name_of_backproj(const BackprojType backproj);
 
 /* phm.c */
 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 int type, const double cx, const double cy, 
+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(PHMELM *obj);
-void pelm_make_xform (PHMELM *obj);
-PHMELM *pelm_alloc(void);
+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_INTERACTIVE_GRAPHICS
+#if HAVE_SGP
 void phm_show(const PHANTOM *phm);
 void phm_draw(const PHANTOM *phm);
 #endif
@@ -460,7 +476,7 @@ void phm_draw(const PHANTOM *phm);
 /* phm2image.c */
 void phm_to_image(const PHANTOM *phm, IMAGE *im, const int col_start, const int col_count,
                  const int nsample, const int trace);
-int pelm_is_point_inside(const PHMELM *obj, double x, double y, const int coord_type);
+int pelm_is_point_inside(PELM *obj, const double x, const double y, const CoordType coord_type);
 
 /* phmstd.c */
 void phm_std_herman (PHANTOM *phm);
@@ -471,8 +487,8 @@ void phm_std_rowland_bordered (PHANTOM *phm);
 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 (const PHMELM *obj, const double x1, const double y1, const double x2, const double y2);
-int pelm_clip_line (const PHMELM *obj, double *x1, double *y1, double *x2, 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.c */
@@ -497,4 +513,8 @@ 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);
 
+#ifdef __cplusplus
+} 
+#endif /* __cplusplus */
+
 #endif