1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: options.cpp,v 1.1 2000/06/19 02:59:34 kevin Exp $
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License (version 2) as
9 ** published by the Free Software Foundation.
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ******************************************************************************/
23 opt_set_trace (const char *optarg)
27 if (strcmp(optarg, O_TRACE_NONE_STR) == 0)
29 else if (strcmp(optarg, O_TRACE_TEXT_STR) == 0)
31 else if (strcmp(optarg, O_TRACE_PHM_STR) == 0)
33 else if (strcmp(optarg, O_TRACE_PLOT_STR) == 0)
35 else if (strcmp(optarg, O_TRACE_CLIPPING_STR) == 0)
37 else if (strcmp(optarg, O_TRACE_RAYS_STR) == 0)
40 sys_error(ERR_WARNING,"Invalid trace option %s\n", optarg);
48 name_of_phantom (const int phmnum)
50 const char *name = "Unknown phantom";
52 if (phmnum == O_PHM_HERMAN)
53 name = O_PHM_HERMAN_STR;
54 else if (phmnum == O_PHM_ROWLAND)
55 name = O_PHM_ROWLAND_STR;
56 else if (phmnum == O_PHM_BROWLAND)
57 name = O_PHM_BROWLAND_STR;
58 else if (phmnum == O_PHM_UNITPULSE)
59 name = O_PHM_UNITPULSE_STR;
65 opt_set_phantom (const char *optarg)
69 if (strcmp(optarg, O_PHM_HERMAN_STR) == 0)
71 else if (strcmp(optarg, O_PHM_ROWLAND_STR) == 0)
73 else if (strcmp(optarg, O_PHM_BROWLAND_STR) == 0)
75 else if (strcmp(optarg, O_PHM_UNITPULSE_STR) == 0)
76 opt = O_PHM_UNITPULSE;
78 sys_error(ERR_WARNING,"Invalid phantom option %s\n", optarg);
87 opt_set_interpolation (const char *optarg)
89 InterpolationType opt;
91 if (strcmp(optarg, O_INTERP_NEAREST_STR) == 0)
93 else if (strcmp(optarg, O_INTERP_LINEAR_STR) == 0)
95 #if HAVE_BSPLINE_INTERP
96 else if (strcmp(optarg, O_INTERP_BSPLINE_STR) == 0)
100 sys_error(ERR_WARNING, "Invalid interpolation type %s\n", optarg);
101 opt = static_cast<InterpolationType>(-1);
108 opt_set_filter (const char *optarg)
112 if (strcmp(optarg, O_FILTER_BANDLIMIT_STR) == 0)
113 opt = FILTER_BANDLIMIT;
114 else if (strcmp(optarg, O_FILTER_HAMMING_STR) == 0)
115 opt = FILTER_G_HAMMING;
116 else if (strcmp(optarg, O_FILTER_SINC_STR) == 0)
118 else if (strcmp(optarg, O_FILTER_COS_STR) == 0)
120 else if (strcmp(optarg, O_FILTER_TRIANGLE_STR) == 0)
121 opt = FILTER_TRIANGLE;
122 else if (strcmp(optarg, O_FILTER_ABS_BANDLIMIT_STR) == 0)
123 opt = FILTER_ABS_BANDLIMIT;
124 else if (strcmp(optarg, O_FILTER_ABS_HAMMING_STR) == 0)
125 opt = FILTER_ABS_G_HAMMING;
126 else if (strcmp(optarg, O_FILTER_ABS_SINC_STR) == 0)
127 opt = FILTER_ABS_SINC;
128 else if (strcmp(optarg, O_FILTER_ABS_COS_STR) == 0)
129 opt = FILTER_ABS_COSINE;
130 else if (strcmp(optarg, O_FILTER_SHEPP_STR) == 0)
133 sys_error(ERR_WARNING, "Invalid filter type %s\n", optarg);
134 opt = static_cast<FilterType>(-1);
141 name_of_filter (const int filter)
143 const char *name = "Unknown filter";
145 if (filter == FILTER_SHEPP)
146 name = O_FILTER_SHEPP_STR;
147 else if (filter == FILTER_ABS_COSINE)
148 name = O_FILTER_ABS_COS_STR;
149 else if (filter == FILTER_ABS_SINC)
150 name = O_FILTER_ABS_SINC_STR;
151 else if (filter == FILTER_ABS_G_HAMMING)
152 name = O_FILTER_ABS_HAMMING_STR;
153 else if (filter == FILTER_ABS_BANDLIMIT)
154 name = O_FILTER_ABS_BANDLIMIT_STR;
155 else if (filter == FILTER_COSINE)
156 name = O_FILTER_COS_STR;
157 else if (filter == FILTER_SINC)
158 name = O_FILTER_SINC_STR;
159 else if (filter == FILTER_G_HAMMING)
160 name = O_FILTER_HAMMING_STR;
161 else if (filter == FILTER_BANDLIMIT)
162 name = O_FILTER_BANDLIMIT_STR;
163 else if (filter == FILTER_TRIANGLE)
164 name = O_FILTER_TRIANGLE_STR;
170 opt_set_filter_domain (const char *optarg)
174 if (strcmp(optarg, D_SPATIAL_STR) == 0)
176 else if (strcmp(optarg, D_FREQ_STR) == 0)
179 sys_error(ERR_WARNING, "Invalid filter domain %s\n", optarg);
180 opt = static_cast<DomainType>(-1);
187 name_of_filter_domain (const DomainType domain)
189 const char *name = "Unknown domain";
191 if (domain == D_SPATIAL)
192 return(D_SPATIAL_STR);
193 else if (domain == D_FREQ)
201 opt_set_backproj (const char *optarg)
205 if (strcmp(optarg, O_BPROJ_TRIG_STR) == 0)
207 else if (strcmp(optarg, O_BPROJ_TABLE_STR) == 0)
209 else if (strcmp(optarg, O_BPROJ_DIFF_STR) == 0)
211 else if (strcmp(optarg, O_BPROJ_DIFF2_STR) == 0)
213 else if (strcmp(optarg, O_BPROJ_IDIFF2_STR) == 0)
214 opt = O_BPROJ_IDIFF2;
216 sys_error(ERR_WARNING, "Invalid backprojection method %s\n", optarg);
217 opt = static_cast<BackprojType>(-1);
224 name_of_backproj(const BackprojType bproj)
226 const char *name = "Unknown backprojection method";
228 if (bproj == O_BPROJ_TRIG)
229 name = O_BPROJ_TRIG_STR;
230 else if (bproj == O_BPROJ_TABLE)
231 name = O_BPROJ_TABLE_STR;
232 else if (bproj == O_BPROJ_DIFF)
233 name = O_BPROJ_DIFF_STR;
234 else if (bproj == O_BPROJ_DIFF2)
235 name = O_BPROJ_DIFF2_STR;
236 else if (bproj == O_BPROJ_IDIFF2)
237 name = O_BPROJ_IDIFF2_STR;
245 * name_of_interp Return name of interpolation method
248 * name = name_of_interp (interp_type)
249 * char *name Name of interpolation method
250 * int interp_type Method of interpolation
253 * Returns NULL if interp_type is invalid
257 name_of_interpolation (int interp_type)
259 if (interp_type == I_NEAREST)
260 return (O_INTERP_NEAREST_STR);
261 else if (interp_type == I_LINEAR)
262 return (O_INTERP_LINEAR_STR);
263 #if HAVE_BSPLINE_INTERP
264 else if (interp_type == I_BSPLINE)
265 return (O_INTERP_BSPLINE_STR);
268 return ("Unknown interpolation method");