| 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-2009 Kevin Rosenberg |
| 11 |
** |
| 12 |
** This program is free software; you can redistribute it and/or modify |
| 13 |
** it under the terms of the GNU General Public License (version 2) as |
| 14 |
** published by the Free Software Foundation. |
| 15 |
** |
| 16 |
** This program is distributed in the hope that it will be useful, |
| 17 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
** GNU General Public License for more details. |
| 20 |
** |
| 21 |
** You should have received a copy of the GNU General Public License |
| 22 |
** along with this program; if not, write to the Free Software |
| 23 |
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 |
******************************************************************************/ |
| 25 |
|
| 26 |
#ifndef SCANNER_H |
| 27 |
#define SCANNER_H |
| 28 |
|
| 29 |
#include "trace.h" |
| 30 |
|
| 31 |
class Projections; |
| 32 |
class Phantom; |
| 33 |
class PhantomElement; |
| 34 |
class SGP; |
| 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 (); |
| 46 |
|
| 47 |
const int nDet() const {return m_nDet;} |
| 48 |
const double viewAngle() const {return m_viewAngle;} |
| 49 |
DetectorValue* detValues() {return m_detValues;} |
| 50 |
const DetectorValue* detValues() 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 |
|
| 65 |
class Scanner |
| 66 |
{ |
| 67 |
public: |
| 68 |
static const int GEOMETRY_INVALID; |
| 69 |
static const int GEOMETRY_PARALLEL; |
| 70 |
static const int GEOMETRY_EQUILINEAR; |
| 71 |
static const int GEOMETRY_EQUIANGULAR; |
| 72 |
static const int GEOMETRY_LINOGRAM; |
| 73 |
|
| 74 |
|
| 75 |
Scanner (const Phantom& phm, const char* const geometryName, int nDet, |
| 76 |
int nView, int iOffsetView, int nSample, const double rot_anglen, |
| 77 |
double dFocalLengthRatio, double dCenterDetectorRatio, double dViewRatio, double dScanRatio); |
| 78 |
~Scanner(); |
| 79 |
|
| 80 |
void collectProjections (Projections& proj, const Phantom& phm, const int trace = Trace::TRACE_NONE, |
| 81 |
SGP* pSGP = NULL); |
| 82 |
|
| 83 |
void collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews, const int iOffsetView, bool bStoreAtViewPosition, const int trace = Trace::TRACE_NONE, SGP* pSGP = NULL); |
| 84 |
|
| 85 |
void collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews, const int iOffsetView, int iStorageOffset, const int trace = Trace::TRACE_NONE, SGP* pSGP = NULL); |
| 86 |
|
| 87 |
void setNView (int nView); |
| 88 |
void setOffsetView (int iOffsetView); |
| 89 |
|
| 90 |
bool fail() const {return m_fail;} |
| 91 |
const std::string& failMessage() const {return m_failMessage;} |
| 92 |
unsigned int nDet() const {return m_nDet;} |
| 93 |
unsigned int nView() const {return m_nView;} |
| 94 |
unsigned int offsetView() const {return m_iOffsetView;} |
| 95 |
unsigned int startView() const {return m_startView;} |
| 96 |
double rotInc() const {return m_rotInc;} |
| 97 |
double detInc() const {return m_detInc;} |
| 98 |
double detLen() const {return m_detLen;} |
| 99 |
double detStart() const {return m_detStart;} |
| 100 |
double focalLength() const {return m_dFocalLength;} |
| 101 |
double sourceDetectorLength() const {return m_dSourceDetectorLength;} |
| 102 |
double centerDetectorLength() const {return m_dCenterDetectorLength;} |
| 103 |
|
| 104 |
double viewDiameter() const {return m_dViewDiameter;} |
| 105 |
double scanDiameter() const {return m_dScanDiameter;} |
| 106 |
double fanBeamAngle() const {return m_dFanBeamAngle;} |
| 107 |
|
| 108 |
int geometry() const {return m_idGeometry;} |
| 109 |
|
| 110 |
static int getGeometryCount() {return s_iGeometryCount;} |
| 111 |
static const char* const* getGeometryNameArray() {return s_aszGeometryName;} |
| 112 |
static const char* const* getGeometryTitleArray() {return s_aszGeometryTitle;} |
| 113 |
static int convertGeometryNameToID (const char* const geometryName); |
| 114 |
static const char* convertGeometryIDToName (const int idGeometry); |
| 115 |
static const char* convertGeometryIDToTitle (const int idGeometry); |
| 116 |
|
| 117 |
private: |
| 118 |
bool m_fail; |
| 119 |
std::string m_failMessage; |
| 120 |
int m_idGeometry; |
| 121 |
unsigned int m_nDet; /* Number of detectors in array */ |
| 122 |
unsigned int m_nView; /* Number of rotated views */ |
| 123 |
unsigned int m_iOffsetView; |
| 124 |
unsigned int m_startView; |
| 125 |
unsigned int m_nSample; /* Number of rays per detector */ |
| 126 |
double m_dFocalLength; // Focal Length, distance from source to center |
| 127 |
double m_dSourceDetectorLength; // Distance from source to detectors |
| 128 |
double m_dCenterDetectorLength; // Distance from center to detectors |
| 129 |
double m_dViewDiameter; // Diameter of area being processed |
| 130 |
double m_dScanDiameter; // Diamer of area being scanned |
| 131 |
double m_dViewRatio; // View Ratio to diameter phantom |
| 132 |
double m_dFocalLengthRatio; // Source to Center Length as ratio to viewDiameter radius |
| 133 |
double m_dCenterDetectorRatio; // Center to Detector Length as ratio of viewDiameter radius |
| 134 |
double m_dScanRatio; // Scan length to view length ratio |
| 135 |
double m_dFanBeamAngle; |
| 136 |
double m_detLen; // Total length of detector array |
| 137 |
double m_rotLen; // Rotation angle length in radians (norm 2PI) |
| 138 |
double m_detInc; // Increment between centers of detectors |
| 139 |
double m_rotInc; // Increment in rotation angle between views |
| 140 |
double m_detStart; |
| 141 |
double m_dXCenter; // Center of Phantom |
| 142 |
double m_dYCenter; |
| 143 |
double m_dAngularDetIncrement; |
| 144 |
double m_dAngularDetLen; |
| 145 |
|
| 146 |
int m_trace; |
| 147 |
struct { |
| 148 |
double xd1,yd1,xd2,yd2; /* Coordinates of detector endpoints */ |
| 149 |
double xs1,ys1,xs2,ys2; /* Coordinates of source endpoints */ |
| 150 |
double angle; /* Starting angle */ |
| 151 |
double dAngularDet; |
| 152 |
} m_initPos; |
| 153 |
|
| 154 |
GRFMTX_2D m_rotmtxIncrement; |
| 155 |
|
| 156 |
#ifdef HAVE_SGP |
| 157 |
SGP* m_pSGP; // Pointer to graphics device |
| 158 |
double m_dXMinWin; // Extent of graphics window |
| 159 |
double m_dXMaxWin; |
| 160 |
double m_dYMinWin; |
| 161 |
double m_dYMaxWin; |
| 162 |
double m_dTextHeight; |
| 163 |
#endif |
| 164 |
|
| 165 |
static const char* const s_aszGeometryName[]; |
| 166 |
static const char* const s_aszGeometryTitle[]; |
| 167 |
static const int s_iGeometryCount; |
| 168 |
|
| 169 |
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); |
| 170 |
|
| 171 |
double projectSingleLine (const Phantom& phm, const double x1, const double y1, const double x2, const double y2); |
| 172 |
|
| 173 |
double projectLineAgainstPElem (const PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2); |
| 174 |
|
| 175 |
void traceShowParam (const char* szLabel, const char *fmt, int row, int color, ...); |
| 176 |
void traceShowParamXOR (const char* szLabel, const char *fmt, int row, int color, ...); |
| 177 |
void traceShowParamRasterOp (int iRasterOp, const char* szLabel, const char* fmt, int row, int color, va_list va); |
| 178 |
|
| 179 |
|
| 180 |
}; |
| 181 |
|
| 182 |
const static int PROJECTION_TRACE_ROW_PHANT_ID=0; |
| 183 |
const static int PROJECTION_TRACE_ROW_GEOMETRY=1; |
| 184 |
const static int PROJECTION_TRACE_ROW_FOCAL_LENGTH=2; |
| 185 |
const static int PROJECTION_TRACE_ROW_FIELD_OF_VIEW=3; |
| 186 |
const static int PROJECTION_TRACE_ROW_NDET=4; |
| 187 |
const static int PROJECTION_TRACE_ROW_NVIEW=5; |
| 188 |
const static int PROJECTION_TRACE_ROW_SAMPLES=6; |
| 189 |
const static int PROJECTION_TRACE_ROW_CURR_VIEW=7; |
| 190 |
const static int PROJECTION_TRACE_ROW_ATTEN=8; |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
#endif |