r184: *** 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.12 2000/08/25 15:59:13 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 #include "trace.h"
33
34 class Projections;
35 class Phantom;
36 class PhantomElement;
37 class SGP;
38
39 // Projections are collected along an array of ndet detectors.  The data
40 // for these detectors is stored in the class DetectorArray
41
42 typedef float DetectorValue;
43
44 class DetectorArray
45 {
46  public:
47   DetectorArray (const int ndet);
48   ~DetectorArray (void);
49
50   const int nDet(void) const {return m_nDet;}
51   const double viewAngle(void) const {return m_viewAngle;}
52   DetectorValue* detValues(void) {return m_detValues;}
53   const DetectorValue* detValues(void) const {return m_detValues;}
54
55   void setViewAngle (double viewAngle)
56       { m_viewAngle = viewAngle; }
57
58  private:
59   DetectorValue* m_detValues;   // Pointer to array of values recorded by detector 
60   int m_nDet;                   // Number of detectors in array */
61   double m_viewAngle;           // View angle in radians 
62
63   DetectorArray& operator=(const DetectorArray& rhs);   // assignment
64   DetectorArray (const DetectorArray& rhs);             // copy constructor
65 };
66
67
68 class Scanner
69 {
70  public:
71   static const int Scanner::GEOMETRY_INVALID;
72   static const int Scanner::GEOMETRY_PARALLEL;
73   static const int Scanner::GEOMETRY_EQUILINEAR;
74   static const int Scanner::GEOMETRY_EQUIANGULAR;
75
76   
77   Scanner (const Phantom& phm, const char* const geometryName, int nDet, int nView, int nSample, const double rot_anglen, double dFieldOfView, double dFocalLength);
78   ~Scanner();
79   
80   void collectProjections (Projections& proj, const Phantom& phm, const int trace = TRACE_NONE, SGP* pSGP = NULL);
81
82   void collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews, bool bStoreAtViewPosition, const int trace = TRACE_NONE, SGP* pSGP = NULL);
83
84   void setNView (int nView);
85
86   const bool fail(void) const {return m_fail;}
87   const string& failMessage(void) const {return m_failMessage;}
88   const unsigned int nDet(void) const {return m_nDet;}
89   const unsigned int nView(void) const {return m_nView;}
90   const double phmLen(void) const {return m_phmLen;}
91   const double rotInc(void) const {return m_rotInc;}
92   const double detInc(void) const {return m_detInc;}
93   const double detLen(void) const {return m_detLen;}
94
95   static const int getGeometryCount() {return s_iGeometryCount;}
96   static const char** getGeometryNameArray() {return s_aszGeometryName;}
97   static const char** getGeometryTitleArray() {return s_aszGeometryTitle;}
98   static int convertGeometryNameToID (const char* const geometryName);
99   static const char* convertGeometryIDToName (const int idGeometry);
100   static const char* convertGeometryIDToTitle (const int idGeometry);
101   
102  private:
103   bool m_fail;
104   string m_failMessage;
105   int m_idGeometry;
106   unsigned int m_nDet;          /* Number of detectors in array */
107   unsigned int m_nView;         /* Number of rotated views */
108   unsigned int m_nSample;       /* Number of rays per detector */
109   double m_dFieldOfView;        // Field of View
110   double m_dFocalLength;         // Focal Length
111   double m_detLen;              // Total length of detector array 
112   double m_rotLen;              // Rotation angle length in radians (norm 2PI)
113   double m_detInc;              // Increment between centers of detectors 
114   double m_rotInc;              // Increment in rotation angle between views 
115   double m_phmLen;              // Maximum Length of phantom or area of interest
116   int m_trace;
117   struct {
118     double xd1,yd1,xd2,yd2;     /* Coordinates of detector endpoints */
119     double xs1,ys1,xs2,ys2;     /* Coordinates of source endpoints */
120     double angle;               /* Starting angle */
121   } m_initPos;
122
123   static const char* s_aszGeometryName[];
124   static const char* s_aszGeometryTitle[];
125   static const int s_iGeometryCount;
126
127   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, SGP* pSGP);
128
129   double projectSingleLine (const Phantom& phm, const double x1, const double y1, const double x2, const double y2, SGP* pSGP);
130
131   double projectLineAgainstPElem (const PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2, SGP* pSGP);
132
133   void traceShowParam (SGP* pSGP, const char *label, const char *fmt, int row, int color, ...);
134
135
136 };
137
138 const static int RAYSUM_TRACE_ROW_TITLE=1;
139 const static int RAYSUM_TRACE_ROW_TITLE2=2;
140 const static int RAYSUM_TRACE_ROW_PHANT_ID=4;
141 const static int RAYSUM_TRACE_ROW_CHROMATIC=7;
142 const static int RAYSUM_TRACE_ROW_SCATTER=8;
143 const static int RAYSUM_TRACE_ROW_PHOT_STAT=9;
144 const static int RAYSUM_TRACE_ROW_NDET=12;
145 const static int RAYSUM_TRACE_ROW_NVIEW=13;
146 const static int RAYSUM_TRACE_ROW_SAMPLES=14;
147 const static int RAYSUM_TRACE_ROW_CURR_VIEW=17;
148 const static int RAYSUM_TRACE_ROW_ATTEN=18;
149
150
151
152 #endif