b1ee7fe9469fb3ab62d1416eca025fb9b6190088
[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.9 2000/07/13 07:03:21 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 (void);
44   ~Projections (void);
45
46   void initFromScanner (const Scanner& scanner);
47
48   void printProjectionData (void);
49   void printScanInfo (void) const;
50
51   bool read (const char* fname);
52   bool write (const char* fname);
53   bool detarrayRead (fnetorderstream& fs, DetectorArray& darray, const int view_num);
54   bool detarrayWrite (fnetorderstream& fs, const DetectorArray& darray, const int view_num);
55
56   bool reconstruct (ImageFile& im, const char* const filterName, double filt_param, const char* const filterMethodName, const int zeropad, const char* const interpName, int interp_param, const char* const backprojName, const int trace);
57
58   void setNView (int nView);  // used in MPI to restrict # of views
59   void setRotInc (double rotInc) { m_rotInc = rotInc;}
60   void setDetInc (double detInc) { m_detInc = detInc;}
61   void setPhmLen (double phmLen) { m_phmLen = phmLen;}
62   void setCalcTime (double calcTime) {m_calcTime = calcTime;}
63   void setRemark (const char* remark) {m_remark = remark;}
64   void setRemark (const string remark) {m_remark = remark;}
65
66   const double detStart(void) const {return m_detStart;}
67   const double rotStart(void) const {return m_rotStart;}
68   const double calcTime(void) const {return m_calcTime;}
69   const double phmLen(void) const {return m_phmLen;}
70   const char*  remark(void) const {return m_remark.c_str();}
71   const double detInc(void) const {return m_detInc;}
72   const double rotInc(void) const {return m_rotInc;}
73   const int nDet(void) const {return m_nDet;}
74   const int nView(void) const {return m_nView;}
75   const string& getFilename(void) const {return m_filename;}
76   Array2dFileLabel& getLabel(void) {return m_label;}
77   const Array2dFileLabel& getLabel(void) const {return m_label;}
78
79   DetectorArray& getDetectorArray (const int iview)
80       { return (*m_projData[iview]); }
81   
82   const DetectorArray& getDetectorArray (const int iview) const
83       { return (*m_projData[iview]); }
84   
85  private:
86   int m_headerSize;             // Size of disk file header 
87   int m_geometry;               // Geometry of scanner 
88   struct DetectorArray **m_projData;    // Pointer to array of detarray_st pointers 
89   string m_remark;              // description of raysum data 
90   int m_nDet;                   // number of detectors in array 
91   int m_nView;                  // number of rotated views 
92   double m_calcTime;            // time required to calculate raysums 
93   double m_rotStart;            // starting view rotation
94   double m_rotInc;              // angle between rotations 
95   double m_detStart;            // distance of beginning detector to center phantom
96   double m_detInc;              // increment between detectors 
97   double m_phmLen;              // Length of phantom edge (phm is square) 
98   kuint32 m_year;                   // Creation date & time
99   kuint32 m_month;
100   kuint32 m_day;
101   kuint32 m_hour;
102   kuint32 m_minute;
103   kuint32 m_second;
104   string m_filename;
105   Array2dFileLabel m_label;
106
107   const static kuint16 m_signature = ('P'*256 + 'J');
108
109   bool headerRead (void);
110   bool headerWrite (void);
111   bool headerRead (fnetorderstream& fs);
112   bool headerWrite (fnetorderstream& fs);
113   void newProjData (void);
114   void deleteProjData (void);
115
116   void init (const int nView, const int nDet);
117
118   // prevent default methods
119   Projections& operator= (const Projections& rhs);   // assignment
120   Projections(const Projections& rhs);               // copy
121 };
122
123
124 #endif