1 /*****************************************************************************
5 ** Purpose: Scanner header file
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 1, 1984
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: scanner.h,v 1.20 2001/03/01 07:30:49 kevin Exp $
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.
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.
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 ******************************************************************************/
39 // Projections are collected along an array of ndet detectors. The data
40 // for these detectors is stored in the class DetectorArray
42 typedef float DetectorValue;
47 DetectorArray (const int ndet);
50 const int nDet() const {return m_nDet;}
51 const double viewAngle() const {return m_viewAngle;}
52 DetectorValue* detValues() {return m_detValues;}
53 const DetectorValue* detValues() const {return m_detValues;}
55 void setViewAngle (double viewAngle)
56 { m_viewAngle = viewAngle; }
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
63 DetectorArray& operator=(const DetectorArray& rhs); // assignment
64 DetectorArray (const DetectorArray& rhs); // copy constructor
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;
77 Scanner (const Phantom& phm, const char* const geometryName, int nDet,
78 int nView, int nSample, const double rot_anglen,
79 double dFocalLengthRatio, double dCenterDetectorRatio, double dViewRatio, double dScanRatio);
82 void collectProjections (Projections& proj, const Phantom& phm, const int trace = Trace::TRACE_NONE,
85 void collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews,
86 bool bStoreAtViewPosition, const int trace = Trace::TRACE_NONE, SGP* pSGP = NULL);
88 void collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews,
89 int iStorageOffset, const int trace = Trace::TRACE_NONE, SGP* pSGP = NULL);
91 void setNView (int nView);
93 bool fail() const {return m_fail;}
94 const std::string& failMessage() const {return m_failMessage;}
95 unsigned int nDet() const {return m_nDet;}
96 unsigned int nView() const {return m_nView;}
98 double rotInc() const {return m_rotInc;}
99 double detInc() const {return m_detInc;}
100 double detLen() const {return m_detLen;}
101 double focalLength() const {return m_dFocalLength;}
102 double sourceDetectorLength() const {return m_dSourceDetectorLength;}
103 double centerDetectorLength() const {return m_dCenterDetectorLength;}
105 double viewDiameter() const {return m_dViewDiameter;}
106 double scanDiameter() const {return m_dScanDiameter;}
107 double fanBeamAngle() const {return m_dFanBeamAngle;}
109 int geometry() const {return m_idGeometry;}
111 static int getGeometryCount() {return s_iGeometryCount;}
112 static const char** getGeometryNameArray() {return s_aszGeometryName;}
113 static const char** getGeometryTitleArray() {return s_aszGeometryTitle;}
114 static int convertGeometryNameToID (const char* const geometryName);
115 static const char* convertGeometryIDToName (const int idGeometry);
116 static const char* convertGeometryIDToTitle (const int idGeometry);
120 std::string m_failMessage;
122 unsigned int m_nDet; /* Number of detectors in array */
123 unsigned int m_nView; /* Number of rotated views */
124 unsigned int m_nSample; /* Number of rays per detector */
125 double m_dFocalLength; // Focal Length, distance from source to center
126 double m_dSourceDetectorLength; // Distance from source to detectors
127 double m_dCenterDetectorLength; // Distance from center to detectors
128 double m_dViewDiameter; // Diameter of area being processed
129 double m_dScanDiameter; // Diamer of area being scanned
130 double m_dViewRatio; // View Ratio to diameter phantom
131 double m_dFocalLengthRatio; // Source to Center Length as ratio to viewDiameter radius
132 double m_dCenterDetectorRatio; // Center to Detector Length as ratio of viewDiameter radius
133 double m_dScanRatio; // Scan length to view length ratio
134 double m_dFanBeamAngle;
135 double m_detLen; // Total length of detector array
136 double m_rotLen; // Rotation angle length in radians (norm 2PI)
137 double m_detInc; // Increment between centers of detectors
138 double m_rotInc; // Increment in rotation angle between views
139 double m_dXCenter; // Center of Phantom
141 double m_dAngularDetIncrement;
142 double m_dAngularDetLen;
146 double xd1,yd1,xd2,yd2; /* Coordinates of detector endpoints */
147 double xs1,ys1,xs2,ys2; /* Coordinates of source endpoints */
148 double angle; /* Starting angle */
152 GRFMTX_2D m_rotmtxIncrement;
155 SGP* m_pSGP; // Pointer to graphics device
156 double m_dXMinWin; // Extent of graphics window
160 double m_dTextHeight;
163 static const char* s_aszGeometryName[];
164 static const char* s_aszGeometryTitle[];
165 static const int s_iGeometryCount;
167 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, const double dDetAngle);
169 double projectSingleLine (const Phantom& phm, const double x1, const double y1, const double x2, const double y2);
171 double projectLineAgainstPElem (const PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2);
173 void traceShowParam (const char* szLabel, const char *fmt, int row, int color, ...);
174 void traceShowParamXOR (const char* szLabel, const char *fmt, int row, int color, ...);
175 void traceShowParamRasterOp (int iRasterOp, const char* szLabel, const char* fmt, int row, int color, va_list va);
180 const static int PROJECTION_TRACE_ROW_PHANT_ID=0;
181 const static int PROJECTION_TRACE_ROW_GEOMETRY=1;
182 const static int PROJECTION_TRACE_ROW_FOCAL_LENGTH=2;
183 const static int PROJECTION_TRACE_ROW_FIELD_OF_VIEW=3;
184 const static int PROJECTION_TRACE_ROW_NDET=4;
185 const static int PROJECTION_TRACE_ROW_NVIEW=5;
186 const static int PROJECTION_TRACE_ROW_SAMPLES=6;
187 const static int PROJECTION_TRACE_ROW_CURR_VIEW=7;
188 const static int PROJECTION_TRACE_ROW_ATTEN=8;