X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fifinfo.cpp;h=c911aa5c80948c37d7535b6dddf0a95244e9076c;hp=000b255e29a6aa7f3ec04ab7223528c05402072e;hb=2d39e823ba389fc68e5317c422b55be006094252;hpb=92a7e95f339442d5d87f0febcae338306e1c6edd diff --git a/src/ifinfo.cpp b/src/ifinfo.cpp index 000b255..c911aa5 100644 --- a/src/ifinfo.cpp +++ b/src/ifinfo.cpp @@ -1,25 +1,15 @@ /***************************************************************************** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: ifinfo.cpp,v 1.2 2000/06/07 03:50:27 kevin Exp $ -** $Log: ifinfo.cpp,v $ -** Revision 1.2 2000/06/07 03:50:27 kevin -** *** empty log message *** -** -** Revision 1.1 2000/06/07 02:29:05 kevin -** Initial C++ versions +** FILE IDENTIFICATION ** -** 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 +** Name: ifinfo.cpp +** Purpose: Display information about an image file +** Programmer: Kevin Rosenberg +** Date Started: April 2000 ** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg ** +** $Id: ifinfo.cpp,v 1.9 2000/06/19 17:58:13 kevin Exp $ ** ** 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 @@ -59,19 +49,19 @@ static struct option my_options[] = void ifinfo_usage (const char *program) { - fprintf(stdout, "usage: %s infile [OPTIONS]\n", kbasename(program)); - fprintf(stdout, "Imagefile information\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " infile Name of input SDF file\n"); - fprintf(stdout, " --display Display image\n"); - fprintf(stdout, " --labels Print image labels (default)\n"); - fprintf(stdout, " --no-labels Do not print image labels\n"); - fprintf(stdout, " --stats Print image statistics (default)\n"); - fprintf(stdout, " --no-stats Do not print image statistics\n"); - fprintf(stdout, " --debug Debug mode\n"); - fprintf(stdout, " --verbose Verbose mode\n"); - fprintf(stdout, " --version Print version\n"); - fprintf(stdout, " --help Print this help message\n"); + cout << "usage: " << fileBasename(program) << " infile [OPTIONS]" << endl; + cout << "Imagefile information" << endl; + cout << endl; + cout << " infile Name of input IF file" << endl; + cout << " --display Display image" << endl; + cout << " --labels Print image labels (default)" << endl; + cout << " --no-labels Do not print image labels" << endl; + cout << " --stats Print image statistics (default)" << endl; + cout << " --no-stats Do not print image statistics" << endl; + cout << " --debug Debug mode" << endl; + cout << " --verbose Verbose mode" << endl; + cout << " --version Print version" << endl; + cout << " --help Print this help message" << endl; } int @@ -113,11 +103,11 @@ ifinfo_main (int argc, char *const argv[]) break; case O_VERSION: #ifdef VERSION - fprintf(stdout, "Version %s\n", VERSION); + cout << "Version " << VERSION << endl; #else - fprintf(stderr, "Unknown version number"); + cout << "Unknown version number" << endl; #endif - exit(0); + return (0); case O_HELP: case '?': ifinfo_usage(argv[0]); @@ -137,29 +127,31 @@ ifinfo_main (int argc, char *const argv[]) in_file = argv[optind]; im = new ImageFile (in_file); - im->adf.fileRead (); + if (! im->fileRead ()) { + sys_error (ERR_WARNING, "Unable to read file %s", in_file); + return (1); + } if (opt_labels) { - int nlabels = im->adf.getNumLabels(); + int nlabels = im->getNumLabels(); int i; for (i = 0; i < nlabels; i++) { Array2dFileLabel label; - string str; - - im->adf.labelRead (label, i); - label.getDateString (str); + im->labelRead (label, i); if (label.getLabelType() == Array2dFileLabel::L_HISTORY) { - cout << "History: " << label.getLabelString() << endl; + cout << "History: " << endl; + cout << " " << label.getLabelString() << endl; cout << " calc time = " << label.getCalcTime() << " secs" << endl; - cout << " Timestamp = " << str << endl; + cout << " Timestamp = " << label.getDateString() << endl; } else if (label.getLabelType() == Array2dFileLabel::L_USER) { cout << "Note: " << label.getLabelString() << endl; - cout << " Timestamp = %s" << str << endl; - } + cout << " Timestamp = %s" << label.getDateString() << endl; + } + cout << endl; } } @@ -175,9 +167,9 @@ ifinfo_main (int argc, char *const argv[]) int ix, iy; maxbin = nbin - 1; - ImageFileArray v = im->adf.getArray(); - int nx = im->adf.nx(); - int ny = im->adf.ny(); + ImageFileArray v = im->getArray(); + int nx = im->nx(); + int ny = im->ny(); for (ix = 0; ix < nx; ix++) { @@ -228,13 +220,13 @@ ifinfo_main (int argc, char *const argv[]) } } stddev = sqrt(stddev / (nx * ny)); - cout << "nx=" << nx << endl; - cout << "nx=" << ny << endl; - cout << "min=" << minfound << endl; - cout << "max=" << maxfound << endl; - cout << "mean=" << mean << endl; - cout << "mode=" << mode << endl; - cout << "stddef=" << stddev << endl; + cout << " nx: " << nx << endl; + cout << " nx: " << ny << endl; + cout << " min: " << minfound << endl; + cout << " max: " << maxfound << endl; + cout << " mean: " << mean << endl; + cout << " mode: " << mode << endl; + cout << "stddef: " << stddev << endl; } return (0); @@ -244,6 +236,16 @@ ifinfo_main (int argc, char *const argv[]) int main (int argc, char *const argv[]) { - return (ifinfo_main(argc, argv)); + int retval = 1; + + try { + retval = ifinfo_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif