r96: *** empty log message ***
[ctsim.git] / include / ir.h
index ffa83fb63d156cb3891d212ae8091f860a31b578..c7b2f7bd7150235ae607e7ecbb4da8bfadd488a1 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ir.h,v 1.26 2000/06/13 16:20:31 kevin Exp $
+**  $Id: ir.h,v 1.27 2000/06/15 19:07:10 kevin Exp $
 **
 **
 **  This program is free software; you can redistribute it and/or modify
 #define IR_H
 
 
-static const int POINTS_PER_CIRCLE=90;
-#define MAXREMARK  99
-
-typedef enum {
-  RECTANGLE,
-  TRIANGLE,
-  ELLIPSE,
-  SECTOR,
-  SEGMENT
-} PElmType;
-
-
-class PhmElement
-{
- public:
-    PElmType type;          /* pelm type (box, ellipse, etc) */
-    double atten;           /* X-ray attenuation coefficient */
-    double cx,cy;           /* center of pelm */
-    double u,v;                     /* size of pelm */
-    double rot;                     /* pelm rotation angle (in radians) */
-    double *x, *y;          /* ptr to array of points in obj world coord */
-    int pts;                /* number of points in outline arrays */
-    double xmin, xmax, ymin, ymax; /* pelm limits */
-    double radius;          /*   "   */
-    GRFMTX_2D p_to_o;        /* map from phantom to standard pelm coords */
-    GRFMTX_2D o_to_p;        /* map from std pelm coords to phantom coords */
-    class PhmElement *next;    /* pointer to next pelm in phantom */
-};
-typedef class PhmElement PELM;
-
-typedef enum {
-  P_PELMS,        /* Phantom made of Pelms */
-  P_UNIT_PULSE,   /* Special phantom, not made of pelms */
-  P_FILTER       /* defined only by this type */
-} PhmType;
-
-
-/* Phantom class */
-class Phantom
-{
-public:
-    PELM *pelm_list;               /* pelm linked-list */
-    PhmType type;
-    int n_pelm;                           /* number of pelms in phantom */
-    double xmin, xmax, ymin, ymax; /* extent of pelms in pelm coordinates */
-    double radius;                 /*      " "    */
-};
-typedef class Phantom    PHANTOM;
+#include "phantom.h"
 
 
 /*----------------------------------------------------------------------*/
@@ -125,8 +78,11 @@ class Detector
     double xs1,ys1,xs2,ys2;    /* Coordinates of source endpoints */
     double angle;              /* Starting angle */
   } init;
+
+  Detector (const Phantom& phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
+  ~Detector();
+  
 };
-typedef class Detector DETECTOR;
 
 
 class Projections
@@ -138,7 +94,7 @@ class Projections
   int geometry;                        /* Geometry of scanner */
   struct DetectorArray **view; /* Pointer to array of detarray_st pointers */
 
-  char remark[MAXREMARK+1];    /* description of raysum data */
+  string remark;               /* description of raysum data */
   double calctime;             /* time required to calculate raysums */
 
   int ndet;                    /* number of detectors in array */
@@ -150,21 +106,12 @@ class Projections
   double det_inc;              /* increment between detectors */
   double phmlen;               /* Length of PHANTOM edge (phm is square) */
 };
-typedef class Projections  RAYSUM;
-
+typedef class Projections RAYSUM;
 
 /*----------------------------------------------------------------------*/
 /*                             USER SYMBOLS                            */
 /*----------------------------------------------------------------------*/
 
-/* Codes for Coordinate Types      */
-/* Defines coords for pelm_is_point_inside() */
-
-typedef enum {
-  PELM_COORD,         /* Normalized Pelm Coordinates */
-  PHM_COORD           /* User's phantom Coordinates */
-} CoordType;
-
 /* Codes for Filter types */
 
 typedef enum {         /* filter types for filter_generate() */
@@ -209,9 +156,6 @@ typedef enum {     /* Interpolation methods */
   I_LINEAR        /* Linear interpolation */
 } InterpolationType;
 
-/* Constants for sizing PHANTOM */
-
-static const double PERCENT_PHM_SIZE_INCR=0.0;  /* Fractional increase in phantom limits compared to pelm size */
 static const int N_EXTRA_DETECTORS=4;           /* Number of extra detectors widths when calculating detlen */
 
 static const char O_TRACE_NONE_STR[]=     "none";
@@ -293,8 +237,8 @@ const static int RAYSUM_TRACE_ROW_ATTEN=18;
 double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
 
 /* dialogs.cpp */
-int phm_add_pelm_kb (PHANTOM *phm);
-PHANTOM *phm_select (void);
+bool phm_add_pelem_kb (Phantom& phm);
+const Phantom& phm_select (Phantom& phm);
 int interpolation_select (void);
 int filter_select (double *filter_param);
 
@@ -319,47 +263,16 @@ const char *name_of_filter_domain(const DomainType domain);
 BackprojType opt_set_backproj(const char *optarg);
 const char *name_of_backproj(const BackprojType backproj);
 
-/* phm.cpp */
-PHANTOM *phm_create(const int phmid);
-PHANTOM *phm_create_from_file(const char *fname);
-PHANTOM *phm_init(void);
-void phm_free (PHANTOM *phm);
-int phm_add_pelm_file(PHANTOM *phm, const char *fname);
-void phm_add_pelm (PHANTOM *phm, const char *type, const double cx, const double cy, 
-              const double u, const double v, const double rot, const double atten);
-int pelm_make_points(PELM *obj);
-void pelm_make_xform (PELM *obj);
-PELM *pelm_alloc(void);
-void calc_arc(double x[], double y[], const int pts, const double xcent, const double ycent, 
-             const double r, const double start, const double stop);
-void calc_ellipse(double x[], double y[], const int pts, const double u, const double v);
-int circle_pts(double theta);
-void phm_print(PHANTOM *phm);
-#if HAVE_SGP
-void phm_show(const PHANTOM *phm);
-void phm_draw(const PHANTOM *phm);
-#endif
-
-/* phmstd.cpp */
-void phm_std_herman (PHANTOM *phm);
-void phm_std_rowland (PHANTOM *phm);
-void phm_std_rowland_bordered (PHANTOM *phm);
-
 /* raycollect.cpp */
-int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PHANTOM *phm, const int start_view, const int trace, const int unit_pulse);
-void rayview(const PHANTOM *phm, DETARRAY *darray, const DETECTOR *det, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
-double phm_ray_attenuation (const PHANTOM *phm, const double x1, const double y1, const double x2, const double y2);
-double pelm_ray_attenuation (PELM *pelm, const double x1, const double y1, const double x2, const double y2);
-int pelm_clip_line (const PELM *pelm, double& x1, double& y1, double& x2, double& y2);
+int raysum_collect (RAYSUM *rs, const Detector& det, const Phantom& phm, const int start_view, const int trace, const int unit_pulse);
+void rayview (const Phantom& phm, DETARRAY *darray, const Detector& det, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
+double phm_ray_attenuation (const Phantom& phm, const double x1, const double y1, const double x2, const double y2);
+double pelem_ray_attenuation (PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2);
 void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...);
 
-/* scanner.cpp */
-DETECTOR *detector_create(const PHANTOM *phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
-void detector_free(DETECTOR *det);
-
 /* rayio.cpp */
 RAYSUM *raysum_create(const char *fname, const int nview, const int ndet);
-RAYSUM *raysum_create_from_det(const char *fname, const DETECTOR *det);
+RAYSUM *raysum_create_from_det(const char *fname, const Detector& det);
 RAYSUM *raysum_open(const char *filename);
 void raysum_alloc_views(RAYSUM *rs);
 void raysum_free(RAYSUM *rs);
@@ -377,8 +290,7 @@ int detarray_read(RAYSUM *rs, DETARRAY *darray, const int view_num);
 int detarray_write(RAYSUM *rs, const DETARRAY *darray, const int view_num);
 
 /* From phm2image.cpp */
-void phm_to_imagefile (const PHANTOM *phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
-int pelm_is_point_inside(PELM *obj, const double x, const double y, const CoordType coord_type);
+void phm_to_imagefile (const Phantom& phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
 
 /* image.cpp */
 void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);