1 /*****************************************************************************
2 * ** FILE IDENTIFICATION
4 * ** Name: phm2helix.cpp
5 * ** Purpose: Take projections of a phantom object
6 * ** Programmer: Ian Kay
7 * ** Date Started: Aug 2001
9 * ** This is part of the CTSim program
10 * ** Copyright (C) 1983-2000 Kevin Rosenberg
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 * ******************************************************************************/
32 enum { O_INTERPVIEW, O_VERBOSE, O_TRACE, O_HELP, O_DEBUG, O_VERSION};
35 static struct option my_options[] =
37 {"interpview", 1, 0, O_INTERPVIEW},
38 {"trace", 1, 0, O_TRACE},
39 {"debug", 0, 0, O_DEBUG},
40 {"verbose", 0, 0, O_VERBOSE},
41 {"help", 0, 0, O_HELP},
42 {"version", 0, 0, O_VERSION},
46 static const char* g_szIdStr = "$Id$";
48 void pjHinterp_usage ( const char *program )
50 std::cout << "usage: " << fileBasename(program) << " projection-file interp-projection-file [OPTIONS]" << std::endl;
51 std::cout << "Interpolation of helical data in raw data space" << std::endl;
52 std::cout << " projection-file Input projection file" << std::endl;
53 std::cout << " interp-file Output interpolated projection file " << std::endl;
54 std::cout << " --trace Set tracing to level" << std::endl;
55 std::cout << " none No tracing (default)" << std::endl;
56 std::cout << " console Text level tracing" << std::endl;
57 std::cout << " --verbose Turn on verbose mode" << std::endl;
58 std::cout << " --debug Turn on debug mode" << std::endl;
59 std::cout << " --version Print version" << std::endl;
60 std::cout << " --help Print this help message" << std::endl;
65 pjHinterp_main(int argc, char * const argv[])
67 Projections projGlobal;
68 char* pszProjFilename = NULL;
69 char* pszInterpFilename = NULL;
70 bool bOptVerbose = false;
72 int optTrace = Trace::TRACE_NONE;
75 int opt_interpview=-1;
78 int c = getopt_long(argc, argv, "", my_options, NULL);
85 opt_interpview = strtol(optarg, &endptr, 10);
86 endstr = optarg + strlen(optarg);
87 if (endptr != endstr) {
88 std::cerr << "Error setting --interpview to %s" << optarg << std::endl;
89 pjHinterp_usage(argv[0]);
100 if ((optTrace = Trace::convertTraceNameToID(optarg))
101 == Trace::TRACE_INVALID) {
102 pjHinterp_usage(argv[0]);
108 std::cout << "Version " << VERSION << std::endl <<
109 g_szIdStr << std::endl;
111 std::cout << "Unknown version number" << std::endl;
117 pjHinterp_usage(argv[0]);
120 pjHinterp_usage(argv[0]);
125 if (optind + 2 != argc) {
126 pjHinterp_usage(argv[0]);
130 pszProjFilename = argv[optind];
132 pszInterpFilename = argv[optind + 1];
134 Projections projections;
135 if ( projections.read(pszProjFilename) != true ){
136 std::cerr << "Error reading input file " << pszProjFilename << std::endl;
140 std::ostringstream os;
141 projections.printScanInfo(os);
142 std::cout << os.str();
145 int status = projections.Helical180LI(opt_interpview);
146 if ( status != 0 ) return (1);
147 status = projections.HalfScanFeather();
148 if ( status != 0 ) return (1);
149 projections.write( pszInterpFilename );
157 main (int argc, char* argv[])
162 retval = pjHinterp_main(argc, argv);
163 } catch (exception e) {
164 std::cerr << "Exception: " << e.what() << std::endl;
166 std::cerr << "Unknown exception" << std::endl;