1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: rs2sdf.c,v 1.3 2000/05/16 04:33:59 kevin Exp $
7 ** Revision 1.3 2000/05/16 04:33:59 kevin
8 ** Improved option processing
10 ** Revision 1.2 2000/05/08 20:02:32 kevin
13 ** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
14 ** Initial CVS import for first public release
18 ** This program is free software; you can redistribute it and/or modify
19 ** it under the terms of the GNU General Public License (version 2) as
20 ** published by the Free Software Foundation.
22 ** This program is distributed in the hope that it will be useful,
23 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ** GNU General Public License for more details.
27 ** You should have received a copy of the GNU General Public License
28 ** along with this program; if not, write to the Free Software
29 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 ******************************************************************************/
33 * rs2sdf.c Convert Raysum to image
41 enum { O_VERBOSE, O_HELP, O_VERSION };
43 static struct option my_options[] =
45 {"verbose", 0, 0, O_VERBOSE},
46 {"help", 0, 0, O_HELP},
47 {"version", 0, 0, O_VERSION},
53 rs2sdf_usage (const char *program)
55 fprintf(stdout, "rs2sdf_usage: %s in-rs-file out-sdf-file [OPTIONS]\n", kbasename(program));
56 fprintf(stdout, "This program converts a raysum file to a SDF2D file\n");
57 fprintf(stdout, "\n");
58 fprintf(stdout, " --verbose Verbose mode\n");
59 fprintf(stdout, " --version Print version\n");
60 fprintf(stdout, " --help Print this help message\n");
66 rs2sdf_main (const int argc, char *const argv[])
71 char *rs_name, *im_name;
78 int c = getopt_long (argc, argv, "", my_options, NULL);
89 fprintf(stdout, "Version %s\n", VERSION);
91 fprintf(stderr, "Unknown version number");
96 rs2sdf_usage(argv[0]);
99 rs2sdf_usage(argv[0]);
104 if (argc - optind != 2) {
105 rs2sdf_usage(argv[0]);
109 rs_name = argv[optind];
110 im_name = argv[optind + 1];
112 if (file_exists(rs_name) == FALSE) {
113 fprintf (stderr, "Raysum file %s does not exist\n", rs_name);
117 rs = raysum_open (rs_name);
121 printf ("Number of detectors: %d\n", rs->ndet);
122 printf (" Number of views: %d\n", rs->nview);
123 printf (" Remark: %s\n", rs->remark);
126 im = image_create (im_name, rs->ndet, rs->nview);
128 sdf_add_label (LT_HISTORY, rs->remark, rs->calctime, im->dfp_2d->dfp);
129 sdf_add_empty_label (im->dfp_2d->dfp);
131 detarray = detarray_alloc (rs->ndet);
132 for (iy = 0; iy < rs->nview; iy++)
134 detarray_read (rs, detarray, iy);
135 for (ix = 0; ix < rs->ndet; ix++)
137 im->v[ix][iy] = detarray->detval[ix];
140 detarray_free (detarray);
150 main (const int argc, char *const argv[])
152 return (rs2sdf_main(argc, argv));