1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: rs2if.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
7 ** Revision 1.1 2000/06/07 02:29:05 kevin
8 ** Initial C++ versions
10 ** Revision 1.3 2000/05/16 04:33:59 kevin
11 ** Improved option processing
13 ** Revision 1.2 2000/05/08 20:02:32 kevin
16 ** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
17 ** Initial CVS import for first public release
21 ** This program is free software; you can redistribute it and/or modify
22 ** it under the terms of the GNU General Public License (version 2) as
23 ** published by the Free Software Foundation.
25 ** This program is distributed in the hope that it will be useful,
26 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
27 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ** GNU General Public License for more details.
30 ** You should have received a copy of the GNU General Public License
31 ** along with this program; if not, write to the Free Software
32 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 ******************************************************************************/
36 * rs2if.c Convert Raysum to image
45 enum { O_VERBOSE, O_HELP, O_VERSION };
47 static struct option my_options[] =
49 {"verbose", 0, 0, O_VERBOSE},
50 {"help", 0, 0, O_HELP},
51 {"version", 0, 0, O_VERSION},
57 rs2if_usage (const char *program)
59 fprintf(stdout, "usage: %s in-rs-file out-if-file [OPTIONS]\n", kbasename(program));
60 fprintf(stdout, "This program converts a raysum file to a IF file\n");
61 fprintf(stdout, "\n");
62 fprintf(stdout, " --verbose Verbose mode\n");
63 fprintf(stdout, " --version Print version\n");
64 fprintf(stdout, " --help Print this help message\n");
70 rs2if_main (const int argc, char *const argv[])
75 char *rs_name, *im_name;
82 int c = getopt_long (argc, argv, "", my_options, NULL);
93 fprintf(stdout, "Version %s\n", VERSION);
95 fprintf(stderr, "Unknown version number");
100 rs2if_usage(argv[0]);
103 rs2if_usage(argv[0]);
108 if (argc - optind != 2) {
109 rs2if_usage(argv[0]);
113 rs_name = argv[optind];
114 im_name = argv[optind + 1];
116 if (file_exists(rs_name) == FALSE) {
117 fprintf (stderr, "Raysum file %s does not exist\n", rs_name);
121 rs = raysum_open (rs_name);
125 printf ("Number of detectors: %d\n", rs->ndet);
126 printf (" Number of views: %d\n", rs->nview);
127 printf (" Remark: %s\n", rs->remark);
130 im = new ImageFile (im_name, rs->ndet, rs->nview);
132 detarray = detarray_alloc (rs->ndet);
133 ImageFileArray v = im->adf.getArray();
135 for (iy = 0; iy < rs->nview; iy++)
137 detarray_read (rs, detarray, iy);
138 for (ix = 0; ix < rs->ndet; ix++)
140 v[ix][iy] = detarray->detval[ix];
143 detarray_free (detarray);
146 im->adf.fileCreate ();
147 im->adf.arrayDataWrite ();
148 im->adf.labelAdd (Array2dFileLabel::L_HISTORY, rs->remark, rs->calctime);
149 im->adf.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .rs to .idf");
150 im->adf.fileClose ();
158 main (const int argc, char *const argv[])
160 return (rs2if_main(argc, argv));