1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: rs2if.cpp,v 1.2 2000/06/07 07:43:19 kevin Exp $
7 ** Revision 1.2 2000/06/07 07:43:19 kevin
8 ** Converted to IF data files and C++
10 ** Revision 1.1 2000/06/07 02:29:05 kevin
11 ** Initial C++ versions
13 ** Revision 1.3 2000/05/16 04:33:59 kevin
14 ** Improved option processing
16 ** Revision 1.2 2000/05/08 20:02:32 kevin
19 ** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
20 ** Initial CVS import for first public release
24 ** This program is free software; you can redistribute it and/or modify
25 ** it under the terms of the GNU General Public License (version 2) as
26 ** published by the Free Software Foundation.
28 ** This program is distributed in the hope that it will be useful,
29 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ** GNU General Public License for more details.
33 ** You should have received a copy of the GNU General Public License
34 ** along with this program; if not, write to the Free Software
35 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 ******************************************************************************/
39 * rs2if.c Convert Raysum to image
48 enum { O_VERBOSE, O_HELP, O_VERSION };
50 static struct option my_options[] =
52 {"verbose", 0, 0, O_VERBOSE},
53 {"help", 0, 0, O_HELP},
54 {"version", 0, 0, O_VERSION},
60 rs2if_usage (const char *program)
62 fprintf(stdout, "usage: %s in-rs-file out-if-file [OPTIONS]\n", kbasename(program));
63 fprintf(stdout, "This program converts a raysum file to a IF file\n");
64 fprintf(stdout, "\n");
65 fprintf(stdout, " --verbose Verbose mode\n");
66 fprintf(stdout, " --version Print version\n");
67 fprintf(stdout, " --help Print this help message\n");
73 rs2if_main (const int argc, char *const argv[])
78 char *rs_name, *im_name;
85 int c = getopt_long (argc, argv, "", my_options, NULL);
96 fprintf(stdout, "Version %s\n", VERSION);
98 fprintf(stderr, "Unknown version number");
103 rs2if_usage(argv[0]);
106 rs2if_usage(argv[0]);
111 if (argc - optind != 2) {
112 rs2if_usage(argv[0]);
116 rs_name = argv[optind];
117 im_name = argv[optind + 1];
119 if (file_exists(rs_name) == FALSE) {
120 fprintf (stderr, "Raysum file %s does not exist\n", rs_name);
124 rs = raysum_open (rs_name);
128 printf ("Number of detectors: %d\n", rs->ndet);
129 printf (" Number of views: %d\n", rs->nview);
130 printf (" Remark: %s\n", rs->remark);
133 im = new ImageFile (im_name, rs->ndet, rs->nview);
135 detarray = detarray_alloc (rs->ndet);
136 ImageFileArray v = im->getArray();
138 for (iy = 0; iy < rs->nview; iy++)
140 detarray_read (rs, detarray, iy);
141 for (ix = 0; ix < rs->ndet; ix++)
143 v[ix][iy] = detarray->detval[ix];
146 detarray_free (detarray);
149 im->adf.fileCreate ();
150 im->adf.arrayDataWrite ();
151 im->adf.labelAdd (Array2dFileLabel::L_HISTORY, rs->remark, rs->calctime);
152 im->adf.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .rs to .idf");
153 im->adf.fileClose ();
161 main (const int argc, char *const argv[])
163 return (rs2if_main(argc, argv));