r41: ANSI C changes
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 8 May 2000 20:02:32 +0000 (20:02 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 8 May 2000 20:02:32 +0000 (20:02 +0000)
12 files changed:
include/cio.h
include/ir.h
include/kmath.h
include/kstddef.h
src/ctrec.c
src/phm2rs.c
src/phm2sdf.c
src/rs2sdf.c
src/sdf-1.c
src/sdf-2.c
src/sdf2img.c
src/sdfinfo.c

index 7057bd43d055064528b2e364f55f2e1d7961728a..562da97e04714390fb773e62e2957302f6f84598 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: cio.h,v 1.5 2000/05/07 12:46:19 kevin Exp $
+**  $Id: cio.h,v 1.6 2000/05/08 20:00:47 kevin Exp $
 **  $Log: cio.h,v $
+**  Revision 1.6  2000/05/08 20:00:47  kevin
+**  ANSI C changes
+**
 **  Revision 1.5  2000/05/07 12:46:19  kevin
 **  made c++ compatible
 **
@@ -88,43 +91,39 @@ struct crtv_st {
 
 #define WAITKEY()      {cio_kb_clr(); while (cio_kb_read() == 0);}
 
-/* c_save.c */
-int crt_save(const char *fname);
 /* center.c */
 void crt_center_line(const char *str);
 /* clreol.c */
-void crt_clreol(void);
+void cio_clreol(void);
 /* clrline.c */
-void crt_clrline(unsigned int line);
+void cio_clrline(unsigned int line);
 /* clrscrn.c */
 void crt_clrscrn(void);
 /* cpos.c */
-void crt_tab(unsigned int n);
-void crt_save_cpos(void);
-void crt_restore_cpos(void);
+void cio_tab(unsigned int n);
+void cio__save_cpos(void);
+void cio__restore_cpos(void);
 /* fill_eol.c */
-void crt_fill_eol(int c, int attr);
+void cio_fill_eol(int c, int attr);
 /* getstate.c */
-void crt_get_state(void);
+void cio_get_state(void);
 /* put_ca.c */
-void crt_set_text_clr(int fclr, int bclr);
-int crt_get_texta(void);
-void crt_set_texta(int a);
-int crt_blank_attr(void);
-void crt_put_ca(int c, int attr);
-void crt_put_c(int c);
-void crt_put_cc(int c, int count);
-void crt_put_cca(int c, int attr, int count);
-void crt_put_str(const char *str);
-void crt_put_stra(const char *str, int attr);
-void crt_inc_col(int count);
-void crt_dec_col(int count);
-void crt_dec_row(int count);
-/* scrollup.c */
-void crt_scrollup(int xmin, int ymin, int xmax, int ymax, int nline, int attr);
+void cio_set_text_clr(int fclr, int bclr);
+int cio_get_texta(void);
+void cio_set_texta(int a);
+int cio_blank_attr(void);
+void cio_put_ca(int c, int attr);
+void cio_put_c(int c);
+void cio_put_cc(int c, int count);
+void cio_put_cca(int c, int attr, int count);
+void cio_put_str(const char *str);
+void cio_put_stra(const char *str, int attr);
+void cio_inc_col(int count);
+void cio_dec_col(int count);
+void cio_dec_row(int count);
 /* setcpos.c */
-void crt_set_cpos(int col, int row);
-void crt_get_cpos(int *col, int *row);
+void cio_set_cpos(int col, int row);
+void cio_get_cpos(int *col, int *row);
 /* beep.c */
 void cio_beep(void);
 /* kb_chk.c */
@@ -146,8 +145,8 @@ void cio_tone(double freq, double length);
 /* check_kb */
 int cio_check_kb_escape(void);
 
-#ifdef __cplusplus
+#ifdef _cplusplus
 }
-#endif /* __cplusplus */
+#endif /* _cplusplus */
 
 #endif
index fbab3fc5d4d7450f52eafb5589166697f33d2fb5..e676b1a97d0d399335e474eeaa19421bda0b02c7 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ir.h,v 1.12 2000/05/07 12:46:19 kevin Exp $
+**  $Id: ir.h,v 1.13 2000/05/08 20:00:48 kevin Exp $
 **  $Log: ir.h,v $
+**  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
 **
 **  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
@@ -71,7 +72,7 @@ extern "C" {
 #endif /* __cplusplus */
 
 #ifdef MPI_CT
-#define MPI_MAX_PROCESS 128
+#define MPI_MAX_PROCESS 128 
 struct mpi_ct_st
 {
   int my_rank;
@@ -98,25 +99,32 @@ 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 pelm_st {
-    int type;               /* pelm type (box, ellipse, etc) */
+    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 */
@@ -125,29 +133,27 @@ struct pelm_st {
     int pts;                /* number of points in outline arrays */
     double xmin, xmax, ymin, ymax; /* pelm limits */
     double radius;          /*   "   */
-    struct {                /* transform matrices      */
-       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 */
-    } xform;
-    struct pelm_st *next;  /* pointer to next pelm 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 pelm_st PELM;
 
-struct phm_st {                     /* Phantom structure */
-    PELM *pelm_list;       /* pelm linked-list */
-    int type;
-    int n_pelm;                     /* number of pelms in phantom */
+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;           /*     " "    */
+    double radius;                 /*      " "    */
 };
-
-typedef struct image_st  IMAGE;
 typedef struct phm_st    PHANTOM;
 
-#define P_PELMS        0       /* Phantom made of pelms */
-#define P_UNIT_PULSE   1       /* Special PHANTOM, not made of pelms */
-#define P_FILTER       9       /* defined only by a type */
 
 /*----------------------------------------------------------------------*/
 /*                             RAYSUM SYMBOLS                          */
@@ -157,20 +163,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 */
@@ -180,13 +190,14 @@ 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;
@@ -195,7 +206,7 @@ struct raysum_st {
   int geometry;
   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 */
@@ -207,171 +218,147 @@ 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 pelm types, passed to phm_add_pelm() */
-
-#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 Pelm 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,
+  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,    /* 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
+typedef enum {     /* Interpolation methods */
+  I_NEAREST,       /* Nearest neighbor */
+  I_LINEAR,        /* Linear interpolation */
+  I_BSPLINE,
+  I_1BSPLINE,      /* 1st order B-Spline */
+  I_2BSPLINE,
+  I_3BSPLINE
+} InterpolationType;
 
 /* Constants for sizing PHANTOM */
 
-#define PERCENT_PHM_SIZE_INCR   0.0    /* Fractional increase in PHANTOM */
-                                       /* limits compared to pelm 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
+ ************************************************************************/
+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);
 
 /* 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);
@@ -401,16 +388,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 */
@@ -420,7 +402,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, 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);
@@ -442,17 +424,17 @@ int opt_set_interpolation(const char *optarg, const char *program);
 const char *name_of_interpolation(int interp_type);
 int opt_set_filter(const char *optarg, const char *program);
 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);
+DomainType opt_set_filter_domain(const char *optarg, const char *program);
+const char *name_of_filter_domain(const DomainType domain);
 int opt_set_backproj(const char *optarg, const char *program);
-const char *name_of_backproj(const int backproj);
+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);
 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(PELM *obj);
 void pelm_make_xform (PELM *obj);
@@ -470,7 +452,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 PELM *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);
@@ -481,8 +463,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 PELM *obj, const double x1, const double y1, const double x2, const double y2);
-int pelm_clip_line (const PELM *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 */
index e250a06d40e9a482a75501a6f3c54743e91383b1..3b4a36ad30435d0fbbef347050177971979da277 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: kmath.h,v 1.8 2000/05/07 12:46:19 kevin Exp $
+**  $Id: kmath.h,v 1.9 2000/05/08 20:00:48 kevin Exp $
 **  $Log: kmath.h,v $
+**  Revision 1.9  2000/05/08 20:00:48  kevin
+**  ANSI C changes
+**
 **  Revision 1.8  2000/05/07 12:46:19  kevin
 **  made c++ compatible
 **
@@ -221,7 +224,7 @@ 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 const m, double *x, double *y);
+void xform_mtx2(GRFMTX_2D m, double *x, double *y);
 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);
index 4a5771c267cf3c180afd8f4062d8facce562941e..deb65fa70b03052ef3b06efef94bd5d4a951bd98 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: kstddef.h,v 1.7 2000/05/07 12:46:19 kevin Exp $
+**  $Id: kstddef.h,v 1.8 2000/05/08 20:00:48 kevin Exp $
 **  $Log: kstddef.h,v $
+**  Revision 1.8  2000/05/08 20:00:48  kevin
+**  ANSI C changes
+**
 **  Revision 1.7  2000/05/07 12:46:19  kevin
 **  made c++ compatible
 **
@@ -76,17 +79,12 @@ typedef signed int bool;            /* Boolean variable type */
 
 typedef unsigned char string[STR_SIZE];
 
-#define UNSIGNLONG unsigned long int
-#define UNSIGNCHAR unsigned char
-
 #define TRUE   1
 #define FALSE  0
 #define OK     TRUE
 #define ERROR  FALSE
 #define YES    TRUE
 #define NO     FALSE
-#define ON     TRUE
-#define OFF    FALSE
 
 /*----------------------------------------------------------------------*/
 
@@ -94,11 +92,6 @@ typedef unsigned char string[STR_SIZE];
 
 /*----------------------------------------------------------------------*/
 
-#define INTERNAL_FUNC  static
-#define INTERNAL_VAR   static
-
-/*----------------------------------------------------------------------*/
-
 #define        NEWLINE '\n'
 #define        TAB     '\t'
 #define EOS    '\0'
@@ -159,11 +152,7 @@ typedef struct timedate_st TIMEDATE;
 
 /* codes for open command */
 
-#ifdef LATTICE
-#define OPEN_RDONLY  0x8000            /* Lattice codes for binary i/o */
-#define OPEN_WRONLY  0x8001
-#define OPEN_RDWR    0x8002
-#elif MICROSOFT
+#if MICROSOFT
 #define OPEN_RDONLY  O_RDONLY                  /* other system use standard codes */
 #define OPEN_WRONLY  O_WRONLY                  /* for binary */
 #define OPEN_RDWR    O_RDWR
index fb23af9f456ea3a7fbf9270d790a2d180edd6985..8015376fff4d3b40507276b68131f560df48181c 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctrec.c,v 1.8 2000/05/04 18:16:34 kevin Exp $
+**  $Id: ctrec.c,v 1.9 2000/05/08 20:02:32 kevin Exp $
 **  $Log: ctrec.c,v $
+**  Revision 1.9  2000/05/08 20:02:32  kevin
+**  ANSI C changes
+**
 **  Revision 1.8  2000/05/04 18:16:34  kevin
 **  renamed filter definitions
 **
 
 #include "ct.h"
 
-#define O_INTERP       1
-#define O_FILTER       2
-#define O_FILTER_PARAM 3
-#define O_BACKPROJ     4
-#define O_VERBOSE      5
-#define O_TRACE        6
-#define O_HELP         7
-#define O_DEBUG        8
-#define O_VERSION      9
+enum {O_INTERP, O_FILTER, O_FILTER_PARAM, O_BACKPROJ, O_VERBOSE, O_TRACE, O_HELP, O_DEBUG, O_VERSION};
 
 static struct option my_options[] =
 {
@@ -150,7 +145,7 @@ main (const int argc, char *const argv[])
   int opt_filter = FILTER_ABS_BANDLIMIT;
   int opt_interp = I_LINEAR;
   int opt_interp_param = 1;
-  int opt_backproj = O_BPROJ_DIFF2;
+  BackprojType opt_backproj = O_BPROJ_DIFF2;
 #ifdef MPI_CT
   IMAGE *im_local;
   RAYSUM *rs_local;
@@ -251,8 +246,7 @@ main (const int argc, char *const argv[])
     else
       sprintf (filt_name, "%s", name_of_filter (opt_filter));
   
-    sprintf (remark,
-            "Reconstruct: %dx%d, %s, %s, %s",
+    sprintf (remark, "Reconstruct: %dx%d, %s, %s, %s",
             nx, ny, filt_name, name_of_interpolation (opt_interp), name_of_backproj(opt_backproj));
   
     if (opt_verbose)
@@ -376,7 +370,7 @@ main (const int argc, char *const argv[])
       printf("Time to reduce image = %f secs, max time = %f\n", mpi_t, mpi_t_g);
   }
   if (mpi_ct.my_rank == 0) {
-    strncpy (im_global->remark, remark, MAXREMARK);
+    strncpy (im_global->remark, remark, sizeof(im_global->remark));
     time_end = MPI_Wtime();
     im_global->calctime = time_end - time_start;
     image_save (im_global);
@@ -385,7 +379,7 @@ main (const int argc, char *const argv[])
     }
 #else  
   raysum_close (rs_global);
-  strncpy (im_global->remark, remark, MAXREMARK);
+  strncpy (im_global->remark, remark, sizeof(im_global->remark));
   time_end = td_current_sec();
   im_global->calctime = time_end - time_start;
   image_save (im_global);
index 6076995212bf7a06863243a0d1be70b93805898e..4dbf09080b4dac963cbce5a9f8f038fdf396bbdb 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2rs.c,v 1.8 2000/05/04 18:16:34 kevin Exp $
+**  $Id: phm2rs.c,v 1.9 2000/05/08 20:02:32 kevin Exp $
 **  $Log: phm2rs.c,v $
+**  Revision 1.9  2000/05/08 20:02:32  kevin
+**  ANSI C changes
+**
 **  Revision 1.8  2000/05/04 18:16:34  kevin
 **  renamed filter definitions
 **
 
 #include "ct.h"
 
-#define O_PHANTOM    1
-#define O_DESC       2
-#define O_NRAY       3
-#define O_ROTANGLE   4
-#define O_TRACE      5
-#define O_VERBOSE    6
-#define O_HELP       7
-#define O_PHMFILE    8
-#define O_DEBUG     10
-#define O_VERSION   11
+enum { O_PHANTOM, O_DESC, O_NRAY, O_ROTANGLE, O_TRACE, O_VERBOSE, O_HELP, O_PHMFILE, O_DEBUG, O_VERSION };
 
 static struct option my_options[] = 
 {
@@ -368,12 +362,6 @@ main (const int argc, char *const argv[])
 
   detector_free (det);
 
-  if (opt_trace >= TRACE_PHM)
-    {
-      crt_set_cpos (1, 1);
-      printf("Finished\n");
-    }
-
   return (0);
 }
 
index ac3481cd18e478794ec46ec1ec9a4565684cc590..7da5c48161aebb643f45abac563096f8efa18232 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2sdf.c,v 1.6 2000/05/03 08:49:50 kevin Exp $
+**  $Id: phm2sdf.c,v 1.7 2000/05/08 20:02:32 kevin Exp $
 **  $Log: phm2sdf.c,v $
+**  Revision 1.7  2000/05/08 20:02:32  kevin
+**  ANSI C changes
+**
 **  Revision 1.6  2000/05/03 08:49:50  kevin
 **  Code cleanup
 **
 
 #include "ct.h"
 
-#define O_PHANTOM       1
-#define O_DESC          2
-#define O_NSAMPLE       3
-#define O_FILTER        4
-#define O_TRACE         5
-#define O_VERBOSE       6
-#define O_HELP          7
-#define O_PHMFILE       8
-#define O_FILTER_DOMAIN 9
-#define O_FILTER_BW     10
-#define O_FILTER_PARAM  11
-#define O_DEBUG         12
-#define O_VERSION       13
+enum { O_PHANTOM, O_DESC, O_NSAMPLE, O_FILTER, O_TRACE, O_VERBOSE, O_HELP, 
+       O_PHMFILE, O_FILTER_DOMAIN, O_FILTER_BW, O_FILTER_PARAM, O_DEBUG, O_VERSION };
 
 static struct option my_options[] = 
 {
@@ -271,7 +263,7 @@ main (const int argc, char *const argv[])
 
 #if HAVE_INTERACTIVE_GRAPHICS
     if (opt_trace >= TRACE_PHM)
-      show_phm(phm);
+      phm_show(phm);
 #endif
 
     if (optind + 3 != argc) {
@@ -418,11 +410,6 @@ main (const int argc, char *const argv[])
   strncpy (im_global->remark, opt_desc, sizeof(im_global->remark));
   image_save (im_global);
 
-  if (opt_trace >= TRACE_PHM)
-    {
-      crt_set_cpos (1, 1);
-    }
-  
   if (opt_verbose)
     fprintf (stdout, "Time to compile image = %.2f sec\n\n", im_global->calctime);
 #endif
@@ -437,10 +424,7 @@ main (const int argc, char *const argv[])
       printf ("Enter minimum and maximum densities (min, max): ");
       scanf ("%lf %lf", &dmin, &dmax);
       //      image_paint (CRTDEV, im_global, 0, 0, nx, ny, dmin, dmax, 0);
-      WAITKEY();
 
-      crt_put_stra ("Finished", 8 + C_WHITE);
-      crt_set_cpos (1, 2);
     }
 
   return (0);
index 9ea63c658c444c0413a5a8180539d218207ae017..edfd411d92dcda144ffe2f5443679b76ee6e085e 100644 (file)
@@ -2,10 +2,14 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: rs2sdf.c,v 1.1 2000/04/28 13:02:44 kevin Exp $
+**  $Id: rs2sdf.c,v 1.2 2000/05/08 20:02:32 kevin Exp $
 **  $Log: rs2sdf.c,v $
-**  Revision 1.1  2000/04/28 13:02:44  kevin
-**  Initial revision
+**  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
@@ -30,9 +34,7 @@
 
 #include "ct.h"
 
-#define O_VERBOSE  7
-#define O_HELP     8
-#define O_VERSION  9
+enum { O_VERBOSE, O_HELP, O_VERSION };
 
 static struct option my_options[] =
 {
index 1acb2d0d3c5d03de871992daa8c7b7612243b951..d21052d66a032ce6e0d68e1665f6a33b0647a225 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sdf-1.c,v 1.2 2000/05/03 08:49:50 kevin Exp $
+**  $Id: sdf-1.c,v 1.3 2000/05/08 20:02:32 kevin Exp $
 **  $Log: sdf-1.c,v $
+**  Revision 1.3  2000/05/08 20:02:32  kevin
+**  ANSI C changes
+**
 **  Revision 1.2  2000/05/03 08:49:50  kevin
 **  Code cleanup
 **
 
 #include "ct.h"
 
-#define O_LOG      4
-#define O_EXP      5
-#define O_INVERT   6
-#define O_VERBOSE  7
-#define O_HELP     8
-#define O_VERSION  9
+enum {O_LOG, O_EXP, O_INVERT, O_VERBOSE, O_HELP, O_VERSION};
 
 static struct option my_options[] =
 {
index 3a1843848bae049e4cb199570fcbf4393163ef52..4dc323fc169a347071c1a4f335abbb005de7f390 100644 (file)
@@ -2,10 +2,14 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sdf-2.c,v 1.1 2000/04/28 13:02:44 kevin Exp $
+**  $Id: sdf-2.c,v 1.2 2000/05/08 20:02:32 kevin Exp $
 **  $Log: sdf-2.c,v $
-**  Revision 1.1  2000/04/28 13:02:44  kevin
-**  Initial revision
+**  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
 
 #include "ct.h"
 
-#define O_ADD      1
-#define O_SUB      2
-#define O_MUL      3
-#define O_COMP     4
-#define O_VERBOSE  7
-#define O_HELP     8
-#define O_VERSION  9
+enum {O_ADD, O_SUB, O_MUL, O_COMP, O_VERBOSE, O_HELP, O_VERSION};
 
 static struct option my_options[] =
 {
index 4972ac63b615f541eeaf400c086ff4420133463a..b19013b796cac96bc5344322a7811fb064149507 100644 (file)
@@ -2,10 +2,14 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sdf2img.c,v 1.1 2000/04/28 13:02:44 kevin Exp $
+**  $Id: sdf2img.c,v 1.2 2000/05/08 20:02:32 kevin Exp $
 **  $Log: sdf2img.c,v $
-**  Revision 1.1  2000/04/28 13:02:44  kevin
-**  Initial revision
+**  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
@@ -36,18 +40,8 @@ void sdf2d_to_gif (IMAGE *im, char *outfile, int nxcell, int nycell, double dens
 void sdf2d_to_pgm (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax);
 void sdf2d_to_pgmasc (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax);
 
-#define O_SCALE    1
-#define O_MIN      2
-#define O_MAX      3
-#define O_AUTO     4
-#define O_CENTER   5
-#define O_STATS    6
-#define O_VERBOSE  7
-#define O_HELP     8
-#define O_FORMAT   9
-#define O_LABELS   10
-#define O_VERSION  11
-#define O_DEBUG    12
+enum { O_SCALE, O_MIN, O_MAX, O_AUTO, O_CENTER, O_STATS, O_FORMAT, O_LABELS, 
+       O_HELP, O_VERBOSE, O_VERSION, O_DEBUG };
 
 static struct option my_options[] =
 {
index 9f406ded3815ce7153064a796ab73b984b55e3b8..49cfd9f7d3c4e04f1d69c518c56cc328eb8e0d87 100644 (file)
@@ -2,10 +2,14 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sdfinfo.c,v 1.1 2000/04/28 13:02:44 kevin Exp $
+**  $Id: sdfinfo.c,v 1.2 2000/05/08 20:02:32 kevin Exp $
 **  $Log: sdfinfo.c,v $
-**  Revision 1.1  2000/04/28 13:02:44  kevin
-**  Initial revision
+**  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
 
 #include "ct.h"
 
-#define O_LABELS   5
-#define O_STATS    6
-#define O_VERBOSE  7
-#define O_HELP     8
-#define O_VERSION  9
-#define O_DEBUG    10
-#define O_NO_STATS 11
-#define O_NO_LABELS 12
+enum { O_LABELS, O_STATS, O_NO_STATS, O_NO_LABELS, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG };
 
 static struct option my_options[] =
 {