Initial snark14m import
[snark14.git] / src / snark / disply.cpp
1 /*
2  **********************************************************************
3  $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4  $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/disply.cpp $
5  $LastChangedRevision: 79 $
6  $Date: 2014-07-01 15:33:39 -0400 (Tue, 01 Jul 2014) $
7  $Author: agulati $
8  **********************************************************************
9  */
10
11 #include <cstdio>
12
13 #include "blkdta.h"
14 #include "uiod.h"
15
16 #include "int2str.h"
17 #include "disp.h"
18
19 #include "recfile.h"
20 #include "infile.h"
21
22 #include "disply.h"
23
24 void disply()
25 {
26         // was in post but it is realy local
27         CHAR prjnam[81];
28         CHAR phnnam[81];
29         CHAR recnam[81];
30
31         // was in geo but it is realy local
32         INTEGER nelem;
33         INTEGER area;
34
35         INTEGER word, flags[51];
36         unsigned int count, iter;
37         CHAR algn[5];
38         REAL scale;
39         REAL* Recon;
40         BOOLEAN eol, phan;
41
42         phan = FALSE;
43         scale = 1.0;
44
45         static const INTEGER hphan = CHAR2INT('p', 'h', 'a', 'n');
46         static const INTEGER hscal = CHAR2INT('s', 'c', 'a', 'l');
47
48         // modified calls to getwrd() to use the 4-parameter version. Lajos, Dec 13, 2004
49         static const INTEGER disply_codes[2] =
50         { CHAR2INT('p', 'h', 'a', 'n'), CHAR2INT('s', 'c', 'a', 'l') };
51
52         for (;;)
53         {
54                 word = InFile.getwrd(FALSE, &eol, disply_codes, 2);
55                 if (eol)
56                         break;
57
58                 switch (word)
59                 {
60                 case hphan:
61                         phan = TRUE;
62                         break;
63
64                 case hscal:
65                         scale = InFile.getnum(FALSE, &eol);
66                         break;
67
68                 }
69         }
70
71         if (RecFile.Open("recfil") != 0)
72         {
73                 fprintf(output, "\n **** unable to open recfil");
74                 fprintf(output, "\n **** DISPLAY execution aborted\n");
75                 return;
76         }
77
78         if (RecFile.GetNelem(&nelem) != 0)
79         {
80                 ;
81         }
82
83         if (RecFile.GetProjName(prjnam) != 0)
84         {
85                 ;
86         }
87
88         area = nelem * nelem;
89         //GeoPar.midpix = (GeoPar.nelem + 1) / 2;
90
91         InFile.listit(flags);
92
93         Recon = new REAL[area];
94
95         // if phantom selected
96         if (phan)
97         {
98                 if (RecFile.ReadPhan(phnnam, Recon) != 0)
99                 {
100                         fprintf(output, "\n **** phantom not present\n");
101                 }
102                 else
103                 {
104                         fprintf(output, "\n     display of phantom\n");
105
106                         fprintf(output, "\n     phantom name:    %s", phnnam);
107
108                         disp(Recon, nelem, nelem, scale, output);
109                 }
110         }
111
112         while (RecFile.ReadRec(recnam, algn, &count, &iter, Recon) == 0)
113         {
114
115                 // if selected
116                 if (flags[iter - 1] != 0)
117                 {
118
119                         fprintf(output, "\n\n     reconstruction using %s iter %4i\n", algn,
120                                         count);
121
122                         fprintf(output, "\n     projection data: %s", prjnam);
123
124                         if (iter > 0)
125                         {
126                                 fprintf(output, "\n     execution name:  %s", recnam);
127                         }
128
129                         disp(Recon, nelem, nelem, scale, output);
130                 }
131         }
132
133         delete[] Recon;  // bug 92 - Lajos - 03/02/2005
134
135         fprintf(output, "\n");  // end of file reached
136         RecFile.Close();
137         return;
138 }