r156: *** empty log message ***
[ctsim.git] / include / scanner.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          scanner.h
5 **   Purpose:       Scanner header file
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 1, 1984
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: scanner.h,v 1.7 2000/07/20 11:17:31 kevin Exp $
13 **
14 **
15 **  This program is free software; you can redistribute it and/or modify
16 **  it under the terms of the GNU General Public License (version 2) as
17 **  published by the Free Software Foundation.
18 **
19 **  This program is distributed in the hope that it will be useful,
20 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
21 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 **  GNU General Public License for more details.
23 **
24 **  You should have received a copy of the GNU General Public License
25 **  along with this program; if not, write to the Free Software
26 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 ******************************************************************************/
28
29 #ifndef SCANNER_H
30 #define SCANNER_H
31
32 class Projections;
33 class Phantom;
34 class PhantomElement;
35
36 // Projections are collected along an array of ndet detectors.  The data
37 // for these detectors is stored in the class DetectorArray
38
39 typedef float DetectorValue;
40
41 class DetectorArray
42 {
43  public:
44   DetectorArray (const int ndet);
45   ~DetectorArray (void);
46
47   const int nDet(void) const {return m_nDet;}
48   const double viewAngle(void) const {return m_viewAngle;}
49   DetectorValue* detValues(void) {return m_detValues;}
50   const DetectorValue* detValues(void) const {return m_detValues;}
51
52   void setViewAngle (double viewAngle)
53       { m_viewAngle = viewAngle; }
54
55  private:
56   DetectorValue* m_detValues;   // Pointer to array of values recorded by detector 
57   int m_nDet;                   // Number of detectors in array */
58   double m_viewAngle;           // View angle in radians 
59
60   DetectorArray& operator=(const DetectorArray& rhs);   // assignment
61   DetectorArray (const DetectorArray& rhs);             // copy constructor
62 };
63
64 class Scanner
65 {
66  public:
67     typedef enum {
68         GEOMETRY_INVALID,
69         GEOMETRY_PARALLEL,
70         GEOMETRY_EQUILINEAR,
71         GEOMETRY_EQUIANGULAR,
72     } GeometryID;
73   
74     static const char GEOMETRY_PARALLEL_STR[];
75     static const char GEOMETRY_EQUILINEAR_STR[];
76     static const char GEOMETRY_EQUIANGULAR_STR[];
77
78     static const char GEOMETRY_PARALLEL_TITLE_STR[];
79     static const char GEOMETRY_EQUILINEAR_TITLE_STR[];
80     static const char GEOMETRY_EQUIANGULAR_TITLE_STR[];
81
82   Scanner (const Phantom& phm, const char* const geometryName, int nDet, int nView, int nSample, const double rot_anglen);
83   ~Scanner();
84   
85   void collectProjections (Projections& proj, const Phantom& phm, const int start_view, const int trace);
86
87   void setNView (int nView);
88
89   const bool fail(void) const {return m_fail;}
90   const string& failMessage(void) const {return m_failMessage;}
91   const unsigned int nDet(void) const {return m_nDet;}
92   const unsigned int nView(void) const {return m_nView;}
93   const double phmLen(void) const {return m_phmLen;}
94   const double rotInc(void) const {return m_rotInc;}
95   const double detInc(void) const {return m_detInc;}
96   const double radius(void) const {return m_radius;}
97
98
99  private:
100   bool m_fail;
101   string m_failMessage;
102   GeometryID m_idGeometry;
103   unsigned int m_nDet;          /* Number of detectors in array */
104   unsigned int m_nView;         /* Number of rotated views */
105   unsigned int m_nSample;       /* Number of rays per detector */
106   double m_detLen;              /* Total length of detector array */
107   double m_rotLen;              /* Rotation angle length in radians (norm 2PI) */
108   double m_detInc;              /* Increment between centers of detectors */
109   double m_rotInc;              /* Increment in rotation angle between views */
110   double m_radius;              /* Radius of rotation.  Distance from center of phm to center of det */
111   double m_phmLen;              /* Maximum Length of phantom or area of interest */
112   int m_trace;
113   struct {
114     double xd1,yd1,xd2,yd2;     /* Coordinates of detector endpoints */
115     double xs1,ys1,xs2,ys2;     /* Coordinates of source endpoints */
116     double angle;               /* Starting angle */
117   } m_initPos;
118
119   static const int N_EXTRA_DETECTORS=4;           /* Number of extra detectors widths when calculating detlen */
120
121   static GeometryID convertGeometryNameToID (const char* const geometryName);
122   
123   void projectSingleView (const Phantom& phm, DetectorArray& darray, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2);
124
125   double projectSingleLine (const Phantom& phm, const double x1, const double y1, const double x2, const double y2);
126
127   double projectLineAgainstPElem (const PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2);
128
129   void traceShowParam (const char *label, const char *fmt, int row, int color, ...);
130
131
132 };
133
134 const static int RAYSUM_TRACE_ROW_TITLE=1;
135 const static int RAYSUM_TRACE_ROW_TITLE2=2;
136 const static int RAYSUM_TRACE_ROW_PHANT_ID=4;
137 const static int RAYSUM_TRACE_ROW_CHROMATIC=7;
138 const static int RAYSUM_TRACE_ROW_SCATTER=8;
139 const static int RAYSUM_TRACE_ROW_PHOT_STAT=9;
140 const static int RAYSUM_TRACE_ROW_NDET=12;
141 const static int RAYSUM_TRACE_ROW_NVIEW=13;
142 const static int RAYSUM_TRACE_ROW_SAMPLES=14;
143 const static int RAYSUM_TRACE_ROW_CURR_VIEW=17;
144 const static int RAYSUM_TRACE_ROW_ATTEN=18;
145
146
147
148 #endif