r97: Converted Scanner and Projections to C++
[ctsim.git] / src / ifinfo.cpp
index 8ef592a92e46d721527f5975bfe3ac844ae6586b..a054f2a989d6d397e47fa31df246bbff2dab7629 100644 (file)
@@ -1,22 +1,15 @@
 /*****************************************************************************
-**  This is part of the CTSim program
-**  Copyright (C) 1983-2000 Kevin Rosenberg
-**
-**  $Id: ifinfo.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
-**  $Log: ifinfo.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
+** FILE IDENTIFICATION
 **
-**  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.7 2000/06/17 20:12:15 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
@@ -56,7 +49,7 @@ static struct option my_options[] =
 void 
 ifinfo_usage (const char *program)
 {
-  fprintf(stdout, "usage: %s infile [OPTIONS]\n", kbasename(program));
+  fprintf(stdout, "usage: %s infile [OPTIONS]\n", fileBasename(program));
   fprintf(stdout, "Imagefile information\n");
   fprintf(stdout, "\n");
   fprintf(stdout, "     infile       Name of input SDF file\n");
@@ -134,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;
        }
     }
 
@@ -172,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++)
        {
@@ -225,13 +220,13 @@ ifinfo_main (int argc, char *const argv[])
            }
        }
       stddev = sqrt(stddev / (nx * ny));
-      fprintf(stdout,"nx=%d\n", nx);
-      fprintf(stdout,"ny=%d\n", ny);
-      fprintf(stdout,"min=%f\n", minfound);
-      fprintf(stdout,"max=%f\n", maxfound);
-      fprintf(stdout,"mean=%f\n", mean);
-      fprintf(stdout,"mode=%f\n", mode);
-      fprintf(stdout,"stddev=%f\n", stddev);
+      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);