1 /*****************************************************************************
5 ** Purpose: Convert an projection data file to an image file
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: April 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: pjinfo.cpp,v 1.2 2000/12/16 02:31:00 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 * pjinfo.c Convert Raysum to image
39 enum { O_BINARYHEADER, O_BINARYVIEWS, O_STARTVIEW, O_ENDVIEW, O_DUMP, O_HELP, O_VERSION };
41 static struct option my_options[] =
43 {"binaryheader", 0, 0, O_BINARYHEADER},
44 {"binaryviews", 0, 0, O_BINARYVIEWS},
45 {"startview", 1, 0, O_STARTVIEW},
46 {"endview", 1, 0, O_ENDVIEW},
47 {"dump", 0, 0, O_DUMP},
48 {"help", 0, 0, O_HELP},
49 {"version", 0, 0, O_VERSION},
53 static const char* g_szIdStr = "$Id: pjinfo.cpp,v 1.2 2000/12/16 02:31:00 kevin Exp $";
56 pjinfo_usage (const char *program)
58 cout << "usage: " << fileBasename(program) << " proj-file [OPTIONS]" << endl;
59 cout << "Display projection file information" << endl;
61 cout << " --binaryheader Dump binary header data\n";
62 cout << " --binaryviews Dump binary view data\n";
63 cout << " --startview n Beginning view number to display (default=0)\n";
64 cout << " --endview n Ending view number to display (default=last view)\n";
65 cout << " --dump Print all scan data ASCII format\n";
66 cout << " --version Print version" << endl;
67 cout << " --help Print this help message" << endl;
73 pjinfo_main (const int argc, char *const argv[])
77 bool optBinaryHeader = false;
78 bool optBinaryViews = false;
80 int optEndView = -1; // tells copyViewData to use default last view
85 char *endptr, *endstr;
86 int c = getopt_long (argc, argv, "", my_options, NULL);
96 optBinaryHeader = true;
99 optBinaryViews = true;
102 optStartView = strtol(optarg, &endptr, 10);
103 endstr = optarg + strlen(optarg);
104 if (endptr != endstr) {
105 cerr << "Error setting --startview to %s" << optarg << endl;
106 pjinfo_usage(argv[0]);
111 optEndView = strtol(optarg, &endptr, 10);
112 endstr = optarg + strlen(optarg);
113 if (endptr != endstr) {
114 cerr << "Error setting --endview to %s" << optarg << endl;
115 pjinfo_usage(argv[0]);
121 cout << "Version " << VERSION << endl << g_szIdStr << endl;
123 cout << "Unknown version number" << endl;
128 pjinfo_usage(argv[0]);
131 pjinfo_usage(argv[0]);
136 if (argc - optind != 1) {
137 pjinfo_usage(argv[0]);
141 pj_name = argv[optind];
144 Projections::copyHeader (pj_name, cout);
145 else if (optBinaryViews)
146 Projections::copyViewData (pj_name, cout, optStartView, optEndView);
149 if (! pj.read (pj_name)) {
150 sys_error (ERR_SEVERE, "Can not open projection file %s", pj_name.c_str());
155 pj.printProjectionData (optStartView, optEndView);
158 pj.printScanInfo (os);
169 main (const int argc, char *const argv[])
174 retval = pjinfo_main(argc, argv);
175 } catch (exception e) {
176 cerr << "Exception: " << e.what() << endl;
178 cerr << "Unknown exception" << endl;