1 /*****************************************************************************
5 ** Purpose: Display linogram sampling
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: April 2003
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2009 Kevin Rosenberg
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License (version 2) as
14 ** published by the Free Software Foundation.
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ** GNU General Public License for more details.
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ******************************************************************************/
28 enum { O_XY, O_POLAR_RT, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG };
30 static struct option my_options[] =
33 {"polar-rt", 0, 0, O_POLAR_RT},
34 {"debug", 0, 0, O_DEBUG},
35 {"verbose", 0, 0, O_VERBOSE},
36 {"help", 0, 0, O_HELP},
37 {"version", 0, 0, O_VERSION},
41 static const char* g_szIdStr = "$Id$";
45 linogram_usage (const char *program)
47 std::cout << "usage: " << fileBasename(program) << " n d [OPTIONS]\n";
48 std::cout << "Imagefile information\n";
49 std::cout << std::endl;
50 std::cout << " n Linogram N\n";
51 std::cout << " d Max detector spacing\n";
52 std::cout << " --xy Output x,y pairs\n";
53 std::cout << " --polar-rt Output r,t pairs\n";
54 std::cout << " --debug Debug mode\n";
55 std::cout << " --verbose Verbose mode\n";
56 std::cout << " --version Print version\n";
57 std::cout << " --help Print this help message\n";
61 linogram_main (int argc, char *const argv[])
72 int c = getopt_long (argc, argv, "", my_options, NULL);
93 std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
95 std::cout << "Unknown version number\n";
100 linogram_usage(argv[0]);
103 linogram_usage(argv[0]);
108 if (optind + 2 != argc) {
109 linogram_usage (argv[0]);
113 const char* in_n = argv[optind];
114 const char* in_d = argv[optind+1];
117 double d = atof (in_d);
118 int size = 4 * n + 3;
121 double theta_base = PI/4;
124 double theta_vec [size];
125 for (int i = 0; i < size; i++) {
126 int m = i - (2 * n + 1);
127 theta_vec[i] = atan (static_cast<double>(2 * m) / size);
132 for (m = 0; m < size; m++) {
133 double step = d * cos(theta_vec[m]);
134 for (int id = min; id <= max; id++) {
135 double r = id * step;
136 double x = r * cos(theta_vec[m] + theta_base);
137 double y = r * sin(theta_vec[m] + theta_base);
138 printf ("%lf,%lf ", x, y);
143 for (m = 0; m < size; m++) {
144 double step = d * cos(theta_vec[m]);
145 for (int id = min; id <= max; id++) {
146 double r = id * step;
147 double x = r * cos(theta_vec[m] + PI/2 + theta_base);
148 double y = r * sin(theta_vec[m] + PI/2 + theta_base);
149 printf ("%lf,%lf ", x, y);
155 for (m = 0; m < size; m++) {
157 printf ("%lf: ", theta_vec[m] + theta_base);
158 double step = d * cos(theta_vec[m]);
159 for (int id = min; id <= max; id++) {
161 printf ("%lf,", theta_vec[m] + theta_base);
162 printf ("%lf ", id * step);
167 for (m = 0; m < size; m++) {
169 printf ("%lf: ", theta_vec[m] + PI/2 + theta_base);
170 double step = d * cos(theta_vec[m]);
171 for (int id = min; id <= max; id++) {
173 printf ("%lf,", theta_vec[m] + PI/2 + theta_base);
174 printf ("%lf ", id * step);
185 main (int argc, char *const argv[])
190 retval = linogram_main(argc, argv);
191 } catch (exception e) {
192 std::cerr << "Exception: " << e.what() << std::endl;
194 std::cerr << "Unknown exception\n";