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/select.cpp $
5 $LastChangedRevision: 96 $
6 $Date: 2014-07-02 20:06:42 -0400 (Wed, 02 Jul 2014) $
8 ***********************************************************
10 PROCESS THE SELECT COMMAND AND SET THE VARIABLES IN /RAYSEL/ FOR
28 void select(BOOLEAN isdefault) //add isdefault option, by wei
31 // modified calls to getwrd() to use the 4-parameter version. Lajos, Dec 16, 2004
32 static const INTEGER sel_type[] =
34 CHAR2INT('r', 'a', 'y', 's'), CHAR2INT('p', 'r', 'o', 'j'),
35 CHAR2INT('r', 'a', 'n', 'd'), CHAR2INT('e', 'f', 'f', 'i') // adding efficient mode
38 static const INTEGER user = CHAR2INT('u', 's', 'e', 'r');
39 static const INTEGER snark = CHAR2INT('s', 'n', 'a', 'r');
41 // modified calls to getwrd() to use the 4-parameter version. Lajos, Dec 16, 2004
42 static const INTEGER select_codes[3] =
43 { CHAR2INT('u', 's', 'e', 'r'), CHAR2INT('s', 'n', 'a', 'r'), CHAR2INT('s', 't', 'e', 'p') };
45 // static const INTEGER step = 35; // commented out since it is unused. Lajos, Jan 13, 2005
48 int NumRay; //for efficient mode
54 //default select efficient, by wei
56 word = InFile.getwrd(FALSE, &eol, select_codes, 2);
57 if ((word != user) && (word != snark))
59 fprintf(output, "\n **** select must be followed by either USER or SNARK");
60 fprintf(output, "\n **** program aborted\n");
64 RaySel.useray = (word == user);
65 word = InFile.getwrd(FALSE, &eol, sel_type, 4);
66 for (i = 0; i < 3; i++)
68 if (word == sel_type[i])
72 if (word == sel_type[3])
75 word = InFile.getwrd(FALSE, &eol, sel_type, 4);
83 fprintf(output, "\n **** unknown selection type %s", int2str(word));
84 fprintf(output, "\n **** program aborted\n");
92 fprintf(output, "\n **** unknown selection type %s", int2str(word));
93 fprintf(output, "\n **** program aborted\n");
99 goto L40; // efficient mode by default wei 1/2005
101 L20: RaySel.stype = i;
102 word = InFile.getint(FALSE, &eol);
107 fprintf(output, "\n **** illegal selection : %s %s, the number after a selection type must be greater than zero", int2str(sel_type[RaySel.stype]), int2str(word));
108 fprintf(output, "\n **** program aborted\n");
113 word = InFile.getwrd(FALSE, &eol, sel_type, 3);
117 fprintf(output, "\n **** illegal selection : %s, %i", int2str(sel_type[RaySel.stype]), RaySel.rn1);
118 fprintf(output, "\n **** program aborted\n");
122 for (i = 0; i < 3; i++)
124 if (word == sel_type[i])
128 fprintf(output, "\n **** unknown selection type %s", int2str(word));
129 fprintf(output, "\n **** program aborted\n");
132 L25: if ((RaySel.stype == 0) && (i == 2))
134 if ((RaySel.stype == 1) && (i == 2))
136 if ((RaySel.stype == 2) && (i == 0))
138 if ((RaySel.stype == 2) && (i == 1))
141 if (!((RaySel.stype != 0) && (RaySel.stype != 1) && (RaySel.stype != 2)))
145 fprintf(output, "\n **** illegal select combination : %s, %s", int2str(sel_type[RaySel.stype]), int2str(sel_type[i]));
146 fprintf(output, "\n **** program aborted\n");
150 word = InFile.getint(FALSE, &eol);
151 if ((!eol) && (word <= 0))
153 fprintf(output, "\n **** illegal selection : %s %s, the number after a selection type must be greater than zero", int2str(sel_type[RaySel.stype]), int2str(word));
154 fprintf(output, "\n **** program aborted\n");
160 L30: if (RaySel.stype != 2)
163 ///if(getwrd(input, &eol) != keywd[step]) {
164 if (InFile.getwrd(TRUE, &eol, &(select_codes[2]), 1) != CHAR2INT('s','t','e','p'))
166 fprintf(output, "\n **** keyword STEP missing");
167 fprintf(output, "\n **** program aborted\n");
171 RaySel.prjinc = InFile.getint(FALSE, &eol);
172 RaySel.rayinc = InFile.getint(FALSE, &eol);
173 if ((RaySel.prjinc <= 0) || (RaySel.rayinc <= 0))
175 fprintf(output, "\n **** both mod1 and mod2 must be positive.");
176 fprintf(output, "\n mod1 = %5i, mod2 = %5i", RaySel.prjinc, RaySel.rayinc);
177 fprintf(output, "\n **** program aborted\n");
185 if (RaySel.stype == 3 && eol)
187 fprintf(output, "\n a fixed number of %5i rays at random, followed by sequential ray selection", RaySel.rn1);
188 fprintf(output, "\n with ray-step %5i and projection-step %5i", RaySel.rayinc, RaySel.prjinc);
192 if (RaySel.stype == 4 && eol)
194 fprintf(output, "\n a fixed number of %5i rays at random followed by sequential projection selection", RaySel.rn1);
195 fprintf(output, "\n with projection-step %5i and ray-step %5i", RaySel.prjinc, RaySel.rayinc);
199 if (RaySel.stype == 5 && eol)
201 fprintf(output, "\n a fixed number of, %5i sequential rays, with ray-step, %5i and projection-step %5i", RaySel.rn1, RaySel.rayinc, RaySel.prjinc);
202 fprintf(output, "\n followed by random selection of rays and projections");
206 if (RaySel.stype == 6 && eol)
208 fprintf(output, "\n a fixed number of, %5i sequential rays, with ray-step, %5i and projection-step %5i", RaySel.rn1, RaySel.prjinc, RaySel.rayinc);
209 fprintf(output, "\n followed by random selection of rays and projections");
213 L40: switch (RaySel.stype)
216 fprintf(output, "\n sequential ray selection with ray-step %5i and projection-step %5i", RaySel.rayinc, RaySel.prjinc);
220 fprintf(output, "\n sequential projection selection with projection-step %5i and ray-step %5i", RaySel.prjinc, RaySel.rayinc);
224 fprintf(output, "\n random selection of rays and projections");
228 fprintf(output, "\n cycles of %5i rays at random", RaySel.rn1);
229 fprintf(output, "\n followed by a fixed number of %5i sequential rays with ray-step %5i and projection-step %5i", RaySel.rn2, RaySel.rayinc, RaySel.prjinc);
233 fprintf(output, "\n cycles of %5i rays at random", RaySel.rn1);
234 fprintf(output, "\n followed by a fixed number of %5i sequential projection selection with projection-step %5i and ray-step %5i", RaySel.rn2, RaySel.prjinc, RaySel.rayinc);
238 fprintf(output, "\n cycles of %5i sequential rays with ray-step %5i and projection-step %5i", RaySel.rn1, RaySel.rayinc, RaySel.prjinc);
239 fprintf(output, "\n followed by %5i rays at random", RaySel.rn2);
243 fprintf(output, "\n cycles of %5i sequential projection selection with projection-step %5i and ray-step %5i", RaySel.rn1, RaySel.prjinc, RaySel.rayinc);
244 fprintf(output, "\n followed by %5i rays at random", RaySel.rn2);
250 fprintf(output, "\n efficient data access");
253 NumRay = GeoPar.snrays;
255 NumRay = GeoPar.usrays;
257 factorization(GeoPar.prjnum, &RaySel.decompprj, &RaySel.num_digprj);
258 factorization(NumRay, &RaySel.decompray, &RaySel.num_digray);
259 //factorization(30, &RaySel.decompray, &RaySel.num_digray);
261 get_base(RaySel.decompprj, RaySel.num_digprj, &RaySel.baseprj);
262 get_base(RaySel.decompray, RaySel.num_digray, &RaySel.baseray);
264 if (RaySel.old_numray != NULL)
265 delete[] RaySel.old_numray;
266 if (RaySel.old_numprj != NULL)
267 delete[] RaySel.old_numprj;
268 if (RaySel.new_numray != NULL)
269 delete[] RaySel.new_numray;
270 if (RaySel.new_numprj != NULL)
271 delete[] RaySel.new_numprj; //added to avoid memory leak, by wei 1/2005
273 RaySel.old_numray = new INTEGER[RaySel.num_digray];
274 RaySel.old_numprj = new INTEGER[RaySel.num_digprj];
275 RaySel.new_numray = new INTEGER[RaySel.num_digray];
276 RaySel.new_numprj = new INTEGER[RaySel.num_digprj];
278 RaySel.old_numprj[0] = -1;