Initial snark14m import
[snark14.git] / src / snark / getden.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/getden.cpp $
5  $LastChangedRevision: 80 $
6  $Date: 2014-07-01 21:01:54 -0400 (Tue, 01 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9
10  ---  getden.f
11
12  ---  Subroutine to get thresholding density values t1 (lower limit) and t2
13  (upper limit) if valid density selection is specified in input,
14  otherwise set t1 = minus infinit    ; t2 = plus infinity
15  */
16
17 //      parameter (MXNREG = 40)
18
19 #include <cstdio>
20 #include <cstdlib>
21
22 #include "blkdta.h"
23 #include "consts.h"
24 #include "uiod.h"
25 #include "infile.h"
26
27 #include "eval.h"
28
29 void Eval_class::getden(BOOLEAN* flagdw, INTEGER ObjJ)
30 {
31         BOOLEAN eol;
32
33         REAL v1 = InFile.getnum(FALSE, &eol);
34         REAL v2 = InFile.getnum(FALSE, &eol);
35
36         // Set density range ifspecification is valid, otherwise set default
37         // density range from minus infinity to plus infinity
38
39         if (eol || (v1 > v2))
40         {
41
42                 Obj[ObjJ].t1 = -Consts.infin;
43                 Obj[ObjJ].t2 = Consts.infin;
44                 *flagdw = FALSE;
45
46                 if (v1 > v2)
47                 {
48                         // ERROR - lower threshold is greater than upper threshold
49                         fprintf(output,
50                                         "\n **** lower density value is greater than the higher");
51                         fprintf(output, "\n **** program aborted\n");
52                         exit(-1);
53                 }
54         }
55         else
56         {
57                 Obj[ObjJ].t1 = v1;
58                 Obj[ObjJ].t2 = v2;
59                 *flagdw = TRUE;
60         }
61 }
62
63 void Eval_class::getdens(BOOLEAN* flagdw, eval_Object_Node *o_node)
64 {
65         BOOLEAN eol;
66
67         // Set density range ifspecification is valid, otherwise set default
68         // density range from minus infinity to plus infinity
69
70         REAL v1 = InFile.getnum(FALSE, &eol);
71         if (eol)
72         {
73                 o_node->data.t1 = -Consts.infin;
74                 o_node->data.t2 = Consts.infin;
75                 *flagdw = FALSE;
76                 return;
77         };
78
79         REAL v2 = InFile.getnum(FALSE, &eol);
80         if (eol)
81         {
82                 o_node->data.t1 = -Consts.infin;
83                 o_node->data.t2 = Consts.infin;
84                 *flagdw = FALSE;
85                 return;
86         };
87
88         if (v1 > v2)
89         {
90                 // ERROR - lower threshold is greater than upper threshold
91                 fprintf(output,
92                                 "\n **** lower density value is greater than the higher");
93                 fprintf(output, "\n **** program aborted\n");
94                 exit(-1);
95         }
96         else
97         {
98                 o_node->data.t1 = v1;
99                 o_node->data.t2 = v2;
100                 *flagdw = TRUE;
101         }
102 }