1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/*****************************************************************************
** FILE IDENTIFICATION
**
** Name: pjHinterp.cpp
** Purpose: Interpolate helical data in projection space
** Programmer: Ian Kay and Kevin Rosenberg
** Date Started: Aug 2001
**
** This is part of the CTSim program
** Copyright (C) 1983-2009 Kevin Rosenberg
**
** 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
******************************************************************************/
#include "ct.h"
#include "timer.h"
enum { O_INTERPVIEW, O_VERBOSE, O_TRACE, O_HELP, O_DEBUG, O_VERSION};
static struct option my_options[] =
{
{"interpview", 1, 0, O_INTERPVIEW},
{"trace", 1, 0, O_TRACE},
{"debug", 0, 0, O_DEBUG},
{"verbose", 0, 0, O_VERBOSE},
{"help", 0, 0, O_HELP},
{"version", 0, 0, O_VERSION},
{0, 0, 0, 0}
};
static const char* g_szIdStr = "$Id$";
void pjHinterp_usage ( const char *program )
{
std::cout << "usage: " << fileBasename(program) << " projection-file interp-projection-file [OPTIONS]" << std::endl;
std::cout << "Interpolation of helical data in raw data space" << std::endl;
std::cout << " projection-file Input projection file" << std::endl;
std::cout << " interp-file Output interpolated projection file " << std::endl;
std::cout << " --trace Set tracing to level" << std::endl;
std::cout << " none No tracing (default)" << std::endl;
std::cout << " console Text level tracing" << std::endl;
std::cout << " --verbose Turn on verbose mode" << std::endl;
std::cout << " --debug Turn on debug mode" << std::endl;
std::cout << " --version Print version" << std::endl;
std::cout << " --help Print this help message" << std::endl;
}
int
pjHinterp_main(int argc, char * const argv[])
{
Projections projGlobal;
char* pszProjFilename = NULL;
char* pszInterpFilename = NULL;
bool bOptVerbose = false;
bool bOptDebug = false;
int optTrace = Trace::TRACE_NONE;
char *endptr = NULL;
char *endstr;
int opt_interpview=-1;
UNUSED(bOptDebug);
while (1) {
int c = getopt_long(argc, argv, "", my_options, NULL);
if (c == -1)
break;
switch (c) {
case O_INTERPVIEW:
opt_interpview = strtol(optarg, &endptr, 10);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
std::cerr << "Error setting --interpview to %s" << optarg << std::endl;
pjHinterp_usage(argv[0]);
return(1);
}
break;
case O_VERBOSE:
bOptVerbose = true;
break;
case O_DEBUG:
bOptDebug = true;
break;
case O_TRACE:
if ((optTrace = Trace::convertTraceNameToID(optarg))
== Trace::TRACE_INVALID) {
pjHinterp_usage(argv[0]);
return (1);
}
break;
case O_VERSION:
#ifdef VERSION
std::cout << "Version " << VERSION << std::endl <<
g_szIdStr << std::endl;
#else
std::cout << "Unknown version number" << std::endl;
#endif
return (0);
case O_HELP:
case '?':
pjHinterp_usage(argv[0]);
return (0);
default:
pjHinterp_usage(argv[0]);
return (1);
} // end switch
} // end while
if (optind + 2 != argc) {
pjHinterp_usage(argv[0]);
return (1);
}
pszProjFilename = argv[optind];
pszInterpFilename = argv[optind + 1];
Projections projections;
if ( projections.read(pszProjFilename) != true ){
std::cerr << "Error reading input file " << pszProjFilename << std::endl;
return (1);
}
if (bOptVerbose) {
std::ostringstream os;
projections.printScanInfo(os);
std::cout << os.str();
}
int status = projections.Helical180LI(opt_interpview);
if ( status != 0 ) return (1);
status = projections.HalfScanFeather();
if ( status != 0 ) return (1);
projections.write( pszInterpFilename );
return (0);
}
#ifndef NO_MAIN
int
main (int argc, char* argv[])
{
int retval = 1;
try {
retval = pjHinterp_main(argc, argv);
} catch (exception e) {
std::cerr << "Exception: " << e.what() << std::endl;
} catch (...) {
std::cerr << "Unknown exception" << std::endl;
}
return (retval);
}
#endif
|