03cb2da92db5ba71d586b9bcb793eaae3bf04caa
[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-2000 Kevin Rosenberg
11 **
12 **  $Id: projections.h,v 1.16 2000/12/16 02:31:00 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
36
37 // Projections
38 class Projections
39 {
40  public:
41   Projections (const int nView, const int nDet);
42   Projections (const Scanner& scanner);
43   Projections ();
44   ~Projections ();
45
46   void initFromScanner (const Scanner& scanner);
47
48   void printProjectionData (int startView, int endView);
49   void printProjectionData ();
50   void printScanInfo (ostringstream& os) const;
51
52   bool read (const string& fname);
53   bool read (const char* fname);
54   bool write (const char* fname);
55   bool write (const string& fname);
56   bool detarrayRead (fnetorderstream& fs, DetectorArray& darray, const int view_num);
57   bool detarrayWrite (fnetorderstream& fs, const DetectorArray& darray, const int view_num);
58
59   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;
60
61   void setNView (int nView);  // used in MPI to restrict # of views
62   void setRotInc (double rotInc) { m_rotInc = rotInc;}
63   void setDetInc (double detInc) { m_detInc = detInc;}
64   void setPhmLen (double phmLen) { m_phmLen = phmLen;}
65   void setCalcTime (double calcTime) {m_calcTime = calcTime;}
66   void setRemark (const char* remark) {m_remark = remark; m_label.setLabelString(remark);}
67   void setRemark (const string& remark) {setRemark(remark.c_str());}
68
69   double detStart() const {return m_detStart;}
70   double rotStart() const {return m_rotStart;}
71   double calcTime() const {return m_calcTime;}
72   double phmLen() const {return m_phmLen;}
73   const char*  remark() const {return m_remark.c_str();}
74   double detInc() const {return m_detInc;}
75   double rotInc() const {return m_rotInc;}
76   int nDet() const {return m_nDet;}
77   int nView() const {return m_nView;}
78   int geometry() const {return m_geometry;}
79   double focalLength() const {return m_focalLength;}
80   double fieldOfView() const {return m_fieldOfView;}
81
82   const string& getFilename() const {return m_filename;}
83   Array2dFileLabel& getLabel() {return m_label;}
84   const Array2dFileLabel& getLabel() const {return m_label;}
85
86   DetectorArray& getDetectorArray (const int iview)
87       { return (*m_projData[iview]); }
88   
89   const DetectorArray& getDetectorArray (const int iview) const
90       { return (*m_projData[iview]); }
91
92   static bool copyHeader (const char* const filename, ostream& os);
93   static bool copyHeader (const string& filename, ostream& os);
94
95   static bool copyViewData (const char* const filename, ostream& os, int startView, int endView);
96   static bool copyViewData (const string& filename, ostream& os, int startView, int endView);
97   
98  private:
99   int m_headerSize;             // Size of disk file header 
100   int m_geometry;               // Geometry of scanner 
101   class DetectorArray **m_projData;     // Pointer to array of detarray_st pointers 
102   string m_remark;              // description of raysum data 
103   int m_nDet;                   // number of detectors in array 
104   int m_nView;                  // number of rotated views 
105   double m_calcTime;            // time required to calculate raysums 
106   double m_rotStart;            // starting view rotation
107   double m_rotInc;              // angle between rotations 
108   double m_detStart;            // distance of beginning detector to center phantom
109   double m_detInc;              // increment between detectors 
110   double m_phmLen;              // Length of phantom edge (phm is square) 
111   double m_focalLength;
112   double m_fieldOfView;
113   kuint32 m_year;                   // Creation date & time
114   kuint32 m_month;
115   kuint32 m_day;
116   kuint32 m_hour;
117   kuint32 m_minute;
118   kuint32 m_second;
119   string m_filename;
120   Array2dFileLabel m_label;
121
122   const static kuint16 m_signature;
123
124   bool headerWrite (fnetorderstream& fs);
125   bool headerRead (fnetorderstream& fs);
126   void newProjData ();
127   void deleteProjData ();
128
129   void init (const int nView, const int nDet);
130
131   // prevent default methods
132   Projections& operator= (const Projections& rhs);   // assignment
133   Projections(const Projections& rhs);               // copy
134 };
135
136
137 #endif