r460: no message
[ctsim.git] / include / projections.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          projections.h
5 **   Purpose:       Header file for Projections class
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 1, 1984
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id: projections.h,v 1.21 2001/01/28 19:10:18 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 PROJECTIONS_H
30 #define PROJECTIONS_H
31
32 class Scanner;
33 class DetectorArray;
34 class Array2dFileLabel;
35 class fnetorderstream;
36
37 #include "array2dfile.h"
38 #include "imagefile.h"
39 #include <complex>
40
41 // Projections
42 class Projections
43 {
44  public:
45
46   static const int POLAR_INTERP_INVALID;
47   static const int POLAR_INTERP_NEAREST;
48   static const int POLAR_INTERP_BILINEAR;
49   static const int POLAR_INTERP_BICUBIC;
50
51   Projections (const int nView, const int nDet);
52   Projections (const Scanner& scanner);
53   Projections ();
54   ~Projections ();
55
56   static const int getInterpCount() {return s_iInterpCount;}
57   static const char** getInterpNameArray() {return s_aszInterpName;}
58   static const char** getInterpTitleArray() {return s_aszInterpTitle;}
59   static int convertInterpNameToID (const char* const interpName);
60   static const char* convertInterpIDToName (const int interpID);
61   static const char* convertInterpIDToTitle (const int interpID);
62
63   void initFromScanner (const Scanner& scanner);
64
65   void printProjectionData (int startView, int endView);
66   void printProjectionData ();
67   void printScanInfo (std::ostringstream& os) const;
68
69   bool read (const std::string& fname);
70   bool read (const char* fname);
71   bool write (const char* fname);
72   bool write (const std::string& fname);
73   bool detarrayRead (fnetorderstream& fs, DetectorArray& darray, const int view_num);
74   bool detarrayWrite (fnetorderstream& fs, const DetectorArray& darray, const int view_num);
75
76   bool convertPolar (ImageFile& rIF, int iInterpolation);
77   bool convertFFTPolar (ImageFile& rIF, int iInterpolation, int iZeropad);
78   void calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double** ppdView, double** ppdDet);
79   void interpolatePolar (ImageFileArray& v, ImageFileArray& vImag, unsigned int nx, unsigned int ny, std::complex<double>** ppcDetValue,
80     double** ppdDet, double** ppdView, unsigned int nView, unsigned int nDet, int iInterpolate);
81
82   bool reconstruct (ImageFile& im, const char* const filterName, double filt_param, const char* const filterMethodName, const int zeropad, const char* frequencyFilterName, const char* const interpName, int interp_param, const char* const backprojName, const int trace) const;
83
84   void setNView (int nView);  // used in MPI to restrict # of views
85   void setRotInc (double rotInc) { m_rotInc = rotInc;}
86   void setDetInc (double detInc) { m_detInc = detInc;}
87   void setPhmLen (double phmLen) { m_phmLen = phmLen;}
88   void setCalcTime (double calcTime) {m_calcTime = calcTime;}
89   void setRemark (const char* remark) {m_remark = remark; m_label.setLabelString(remark);}
90   void setRemark (const std::string& remark) {setRemark(remark.c_str());}
91
92   double detStart() const {return m_detStart;}
93   double rotStart() const {return m_rotStart;}
94   double calcTime() const {return m_calcTime;}
95   double phmLen() const {return m_phmLen;}
96   const char*  remark() const {return m_remark.c_str();}
97   double detInc() const {return m_detInc;}
98   double rotInc() const {return m_rotInc;}
99   int nDet() const {return m_nDet;}
100   int nView() const {return m_nView;}
101   int geometry() const {return m_geometry;}
102   double focalLength() const {return m_focalLength;}
103   double fieldOfView() const {return m_fieldOfView;}
104
105   const std::string& getFilename() const {return m_filename;}
106   Array2dFileLabel& getLabel() {return m_label;}
107   const Array2dFileLabel& getLabel() const {return m_label;}
108
109   DetectorArray& getDetectorArray (const int iview)
110       { return (*m_projData[iview]); }
111   
112   const DetectorArray& getDetectorArray (const int iview) const
113       { return (*m_projData[iview]); }
114
115   static bool copyHeader (const char* const filename, std::ostream& os);
116   static bool copyHeader (const std::string& filename, std::ostream& os);
117
118   static bool copyViewData (const char* const filename, std::ostream& os, int startView, int endView);
119   static bool copyViewData (const std::string& filename, std::ostream& os, int startView, int endView);
120   
121  private:
122   int m_headerSize;             // Size of disk file header 
123   int m_geometry;               // Geometry of scanner 
124   class DetectorArray **m_projData;     // Pointer to array of detarray_st pointers 
125   std::string m_remark;         // description of raysum data 
126   int m_nDet;                   // number of detectors in array 
127   int m_nView;                  // number of rotated views 
128   double m_calcTime;            // time required to calculate raysums 
129   double m_rotStart;            // starting view rotation
130   double m_rotInc;              // angle between rotations 
131   double m_detStart;            // distance of beginning detector to center phantom
132   double m_detInc;              // increment between detectors 
133   double m_phmLen;              // Length of phantom edge (phm is square) 
134   double m_focalLength;
135   double m_fieldOfView;
136   kuint32 m_year;                   // Creation date & time
137   kuint32 m_month;
138   kuint32 m_day;
139   kuint32 m_hour;
140   kuint32 m_minute;
141   kuint32 m_second;
142   std::string m_filename;
143   Array2dFileLabel m_label;
144
145   const static kuint16 m_signature;
146
147   static const char* s_aszInterpName[];
148   static const char* s_aszInterpTitle[];
149   static const int s_iInterpCount;
150
151   bool headerWrite (fnetorderstream& fs);
152   bool headerRead (fnetorderstream& fs);
153   void newProjData ();
154   void deleteProjData ();
155
156   void init (const int nView, const int nDet);
157
158   // prevent default methods
159   Projections& operator= (const Projections& rhs);   // assignment
160   Projections(const Projections& rhs);               // copy
161 };
162
163
164 #endif