-/*****************************************************************************
-** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
-**
-** $Id: rs2sdf.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
-** $Log: rs2sdf.cpp,v $
-** Revision 1.1 2000/06/07 02:29:05 kevin
-** Initial C++ versions
-**
-** Revision 1.3 2000/05/16 04:33:59 kevin
-** Improved option processing
-**
-** Revision 1.2 2000/05/08 20:02:32 kevin
-** ANSI C changes
-**
-** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
-** Initial CVS import for first public release
-**
-**
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License (version 2) as
-** published by the Free Software Foundation.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-******************************************************************************/
-
-/* FILE
- * rs2sdf.c Convert Raysum to image
- *
- * DATE
- * Apr 1999
- */
-
-#include "ct.h"
-
-enum { O_VERBOSE, O_HELP, O_VERSION };
-
-static struct option my_options[] =
-{
- {"verbose", 0, 0, O_VERBOSE},
- {"help", 0, 0, O_HELP},
- {"version", 0, 0, O_VERSION},
- {0, 0, 0, 0}
-};
-
-
-void
-rs2sdf_usage (const char *program)
-{
- fprintf(stdout, "rs2sdf_usage: %s in-rs-file out-sdf-file [OPTIONS]\n", kbasename(program));
- fprintf(stdout, "This program converts a raysum file to a SDF2D file\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " --verbose Verbose mode\n");
- fprintf(stdout, " --version Print version\n");
- fprintf(stdout, " --help Print this help message\n");
-}
-
-
-
-int
-rs2sdf_main (const int argc, char *const argv[])
-{
- IMAGE *im;
- RAYSUM *rs;
- DETARRAY *detarray;
- char *rs_name, *im_name;
- int ix, iy;
- int opt_v = 0;
- extern int optind;
-
- while (1)
- {
- int c = getopt_long (argc, argv, "", my_options, NULL);
- if (c == -1)
- break;
-
- switch (c)
- {
- case O_VERBOSE:
- opt_v = 1;
- break;
- case O_VERSION:
-#ifdef VERSION
- fprintf(stdout, "Version %s\n", VERSION);
-#else
- fprintf(stderr, "Unknown version number");
-#endif
- exit(0);
- case O_HELP:
- case '?':
- rs2sdf_usage(argv[0]);
- return (0);
- default:
- rs2sdf_usage(argv[0]);
- return (1);
- }
- }
-
- if (argc - optind != 2) {
- rs2sdf_usage(argv[0]);
- return (1);
- }
-
- rs_name = argv[optind];
- im_name = argv[optind + 1];
-
- if (file_exists(rs_name) == FALSE) {
- fprintf (stderr, "Raysum file %s does not exist\n", rs_name);
- return (1);
- }
-
- rs = raysum_open (rs_name);
-
- if (opt_v)
- {
- printf ("Number of detectors: %d\n", rs->ndet);
- printf (" Number of views: %d\n", rs->nview);
- printf (" Remark: %s\n", rs->remark);
- }
-
- im = image_create (im_name, rs->ndet, rs->nview);
-
- sdf_add_label (LT_HISTORY, rs->remark, rs->calctime, im->dfp_2d->dfp);
- sdf_add_empty_label (im->dfp_2d->dfp);
-
- detarray = detarray_alloc (rs->ndet);
- for (iy = 0; iy < rs->nview; iy++)
- {
- detarray_read (rs, detarray, iy);
- for (ix = 0; ix < rs->ndet; ix++)
- {
- im->v[ix][iy] = detarray->detval[ix];
- }
- }
- detarray_free (detarray);
-
- raysum_close (rs);
- image_save (im);
-
- return(0);
-}
-
-#ifndef NO_MAIN
-int
-main (const int argc, char *const argv[])
-{
- return (rs2sdf_main(argc, argv));
-}
-#endif