r122: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 27 Jun 2000 10:48:11 +0000 (10:48 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 27 Jun 2000 10:48:11 +0000 (10:48 +0000)
ChangeLog
configure
configure.in
include/array2dfile.h
include/projections.h
libctsim/array2dfile.cpp
libctsim/projections.cpp
src/Makefile.am
src/ifinfo.cpp
src/pj2if.cpp
src/pjrec.cpp

index 76d6a7a3a851b3d775d9364041375c1e39f5f598..ee0e0592bd9192094dcde60736cc2f52db5223d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,8 @@
    Rewrote Array2dFile class to make reads and writes atomic. No disk files are kept open.
    Rewrote Array2dFileLabel class to make members private, added access routines
    Removed timedate.cpp in favor of standard C library time/date functions
-   Renamed ctrec to pjrec
+   Renamed ctrec to pjrec, sample-ctrec.sh to sample-ctsim
+   Added signature tag and creation date/time to projection files
        
 1.9.7 - 6/25/2000
    Standardized string option processing by classes. All classes use character strings
index 0143ad3f6df2e55ed7a81c8f4df141c9f9d0d7dd..c4db024e2730d0b5322651916b2ed2051df6d018 100755 (executable)
--- a/configure
+++ b/configure
@@ -470,7 +470,7 @@ echo > confdefs.h
 
 # A filename unique to this package, relative to the directory that
 # configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=src/ctrec.cpp
+ac_unique_file=src/pjrec.cpp
 
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
@@ -711,7 +711,7 @@ fi
 
 PACKAGE=ctsim
 
-VERSION=1.9.7
+VERSION=1.9.8
 
 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
   { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
@@ -4047,7 +4047,7 @@ ctlibs="$ctlibs_base -lctsim $ctlibs_graphics -lctsupport $ctlibs_tools"
 
 
 if test -n "$lamdir" ; then
-  lamprograms="ctrec-lam phm2if-lam phm2pj-lam"
+  lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
   
 fi
 
@@ -4152,7 +4152,7 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "Makefile src/Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile src/sample-ctrec.sh cgi-bin/ctsim.conf config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile src/Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile src/sample-ctsim.sh cgi-bin/ctsim.conf config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -4277,7 +4277,7 @@ EOF
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile src/Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile src/sample-ctrec.sh cgi-bin/ctsim.conf"}
+CONFIG_FILES=\${CONFIG_FILES-"Makefile src/Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile src/sample-ctsim.sh cgi-bin/ctsim.conf"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
index 761d95a089fe982c9bead8a98bce97059f68aeb8..947c97653dffa554bb704a8a286a73d7219e525f 100644 (file)
@@ -4,7 +4,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout
 dnl CDPATH=
 
 AC_INIT(src/pjrec.cpp)
-AM_INIT_AUTOMAKE(ctsim,1.9.7)
+AM_INIT_AUTOMAKE(ctsim,1.9.8)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
index da4671e859517b754fba299805a1cb4a3faf6013..05d7b851764a35c6cb54c10ab0cac15d6cefced6 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: array2dfile.h,v 1.1 2000/06/26 21:15:24 kevin Exp $
+**  $Id: array2dfile.h,v 1.2 2000/06/27 10:48:11 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
@@ -62,6 +62,12 @@ public:
     kfloat64 getCalcTime (void) const
        { return m_calcTime; }
 
+    void setCalcTime (kfloat64 calcTime)
+       { m_calcTime = calcTime; }
+
+    void setLabelType (int labelType)
+       { m_labelType = labelType; }
+
     int getLabelType (void) const
        { return m_labelType; }
 
index 6446f572b3c3b3d1175ee418ea46e8a11cbc3f2b..8d5acacc9c3d0adc0a46a4fd5b1cca175fdcbb73 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: projections.h,v 1.5 2000/06/25 17:32:24 kevin Exp $
+**  $Id: projections.h,v 1.6 2000/06/27 10:48:11 kevin Exp $
 **
 **
 **  This program is free software; you can redistribute it and/or modify
@@ -31,6 +31,8 @@
 
 class Scanner;
 class DetectorArray;
+class Array2dFileLabel;
+
 
 // Projections
 class Projections
@@ -70,6 +72,10 @@ class Projections
   const double rotInc(void) const {return m_rotInc;}
   const int nDet(void) const {return m_nDet;}
   const int nView(void) const {return m_nView;}
+  const string& getFilename(void) const {return m_filename;}
+  Array2dFileLabel& getLabel(void) {return m_label;}
+  const Array2dFileLabel& getLabel(void) const {return m_label;}
+
   DetectorArray& getDetectorArray (const int iview)
       { return (*m_projData[iview]); }
   
@@ -86,6 +92,16 @@ class Projections
   double m_detStart;           // distance of beginning detector to center phantom
   double m_detInc;             // increment between detectors 
   double m_phmLen;             // Length of phantom edge (phm is square) 
+  kuint32 m_year;                   // Creation date & time
+  kuint32 m_month;
+  kuint32 m_day;
+  kuint32 m_hour;
+  kuint32 m_minute;
+  kuint32 m_second;
+  string m_filename;
+  Array2dFileLabel m_label;
+
+  const static kuint16 m_signature = ('P'*256 + 'J');
 
   bool headerRead (void);
   bool headerWrite (void);
index d60381318d132fc35fe6e47b63f78c5a5231d0f8..315ff4663bb0e79842f4a9baa2ed22ac41eb60eb 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: array2dfile.cpp,v 1.1 2000/06/26 21:15:24 kevin Exp $
+**  $Id: array2dfile.cpp,v 1.2 2000/06/27 10:48:11 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
@@ -46,8 +46,8 @@ Array2dFileLabel::init (void)
     m_labelType = L_EMPTY;
     time_t t = time(0);
     tm* lt = localtime(&t);
-    m_year = lt->tm_year + 1900;
-    m_month = lt->tm_mon + 1;
+    m_year = lt->tm_year;
+    m_month = lt->tm_mon;
     m_day = lt->tm_mday;
     m_hour = lt->tm_hour;
     m_minute = lt->tm_min;
@@ -107,7 +107,7 @@ const string&
 Array2dFileLabel::getDateString (void) const
 {
   ostringstream oss;
-  oss <<  m_month <<"/"<< m_day <<"/"<< m_year << " " << m_hour <<":"<<  m_minute <<":"<< m_second;
+  oss <<  m_month + 1 <<"/"<< m_day <<"/"<< m_year + 1900 << " " << m_hour <<":"<<  m_minute <<":"<< m_second;
   m_strDate = oss.str();
   return m_strDate;
 }
index cd151be0e18013b9936bd0103ecc7822ef832857..7b13546bf19ab8c711e8ae1baa81f05fd8ab5b5c 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: projections.cpp,v 1.5 2000/06/25 17:32:24 kevin Exp $
+**  $Id: projections.cpp,v 1.6 2000/06/27 10:48:11 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
@@ -132,18 +132,26 @@ Projections::deleteProjData (void)
 
 
 /* NAME
- *    projections_write_header         Write data header for projections file
+ *    Projections::headerWwrite         Write data header for projections file
  *
  */
 
 bool 
 Projections::headerWrite (fnetorderstream& fs)
 {
-  kuint32 _hsize = m_headerSize;
+  kuint16 _hsize = m_headerSize;
+  kuint16 _signature = m_signature;
   kuint32 _nView = m_nView;
   kuint32 _nDet = m_nDet;
   kuint32 _geom = m_geometry;
-  kuint32 _remarksize = m_remark.length();
+  kuint16 _remarksize = m_remark.length();
+  kuint16 _year = m_year;
+  kuint16 _month = m_month;
+  kuint16 _day = m_day;
+  kuint16 _hour = m_hour;
+  kuint16 _minute = m_minute;
+  kuint16 _second = m_second;
+
   kfloat64 _calcTime = m_calcTime;
   kfloat64 _rotStart = m_rotStart;
   kfloat64 _rotInc = m_rotInc;
@@ -155,7 +163,8 @@ Projections::headerWrite (fnetorderstream& fs)
   if (! fs)
     return false;
 
-  fs.writeInt32 (_hsize);
+  fs.writeInt16 (_hsize);
+  fs.writeInt16 (_signature);
   fs.writeInt32 (_nView);
   fs.writeInt32 (_nDet);
   fs.writeInt32 (_geom);
@@ -165,13 +174,19 @@ Projections::headerWrite (fnetorderstream& fs)
   fs.writeFloat64 (_detStart);
   fs.writeFloat64 (_detInc);
   fs.writeFloat64 (_phmLen);
-  fs.writeInt32 (_remarksize);
+  fs.writeInt16 (_year);
+  fs.writeInt16 (_month);
+  fs.writeInt16 (_day);
+  fs.writeInt16 (_hour);
+  fs.writeInt16 (_minute);
+  fs.writeInt16 (_second);
+  fs.writeInt16 (_remarksize);
   fs.write (m_remark.c_str(), _remarksize);
 
   m_headerSize = fs.tellp();
   _hsize = m_headerSize;
   fs.seekp(0);
-  fs.writeInt32 (_hsize);
+  fs.writeInt16 (_hsize);
   if (! fs)
       return false;
   
@@ -185,24 +200,17 @@ Projections::headerWrite (fnetorderstream& fs)
 bool
 Projections::headerRead (fnetorderstream& fs)
 {
-  kuint32 _hsize;
-  kuint32 _nView;
-  kuint32 _nDet;
-  kuint32 _geom;
-  kuint32 _remarksize = 0;
-  kfloat64 _calcTime;
-  kfloat64 _rotStart;
-  kfloat64 _rotInc;
-  kfloat64 _detStart;
-  kfloat64 _detInc;
-  kfloat64 _phmLen;
+  kuint16 _hsize, _signature, _year, _month, _day, _hour, _minute, _second, _remarksize = 0;
+  kuint32 _nView, _nDet, _geom;
+  kfloat64 _calcTime, _rotStart, _rotInc, _detStart, _detInc, _phmLen;
   
   fs.seekg(0);
   if (! fs)
       return false;
 
   off_t testPos;
-  fs.readInt32 (_hsize);
+  fs.readInt16 (_hsize);
+  fs.readInt16 (_signature);
   fs.readInt32 (_nView);
   fs.readInt32 (_nDet);
   fs.readInt32 (_geom);
@@ -212,17 +220,24 @@ Projections::headerRead (fnetorderstream& fs)
   fs.readFloat64 (_detStart);
   fs.readFloat64 (_detInc);
   fs.readFloat64 (_phmLen);
-  fs.readInt32 (_remarksize);
-  if (_remarksize > 100000) {
-    sys_error (ERR_SEVERE, "Insane _remarksize %d [projections::headerRead]", _remarksize);
-    return false;
-  }
+  fs.readInt16 (_year);
+  fs.readInt16 (_month);
+  fs.readInt16 (_day);
+  fs.readInt16 (_hour);
+  fs.readInt16 (_minute);
+  fs.readInt16 (_second);
+  fs.readInt16 (_remarksize);
 
   if (! fs) {
       sys_error (ERR_SEVERE, "Error reading header information , _remarksize=%d [projections_read_header]", _remarksize);
       return false;
   }
 
+  if (_signature != m_signature) {
+    sys_error (ERR_SEVERE, "File %s does not have a valid projection file signature", m_filename.c_str());
+    return false;
+  }
+
   char remarkStorage[_remarksize+1];
   fs.read (remarkStorage, _remarksize);
   if (! fs) {
@@ -248,6 +263,17 @@ Projections::headerRead (fnetorderstream& fs)
   m_detStart = _detStart;
   m_detInc = _detInc;
   m_phmLen = _phmLen;
+  m_year = _year;
+  m_month = _month;
+  m_day = _day;
+  m_hour = _hour;
+  m_minute = _minute;
+  m_second = _second;
+
+  m_label.setLabelType (Array2dFileLabel::L_HISTORY);
+  m_label.setLabelString (m_remark);
+  m_label.setCalcTime (m_calcTime);
+  m_label.setDateTime (m_year, m_month, m_day, m_hour, m_minute, m_second);
 
   return true;
 }
@@ -256,6 +282,7 @@ bool
 Projections::read (const char* filename)
 {
   frnetorderstream fileRead (filename, ios::in | ios::binary);
+  m_filename = filename;
 
   if (! fileRead)
     return false;
@@ -280,11 +307,21 @@ bool
 Projections::write (const char* filename)
 {
   frnetorderstream fs (filename, ios::out | ios::binary | ios::trunc | ios::ate);
-
+  m_filename = filename;
   if (! fs) {
     sys_error (ERR_SEVERE, "Error opening file %s for output [projections_create]", filename);
     return false;
   }
+
+  time_t t = time(NULL);
+  tm* lt = localtime(&t);
+  m_year = lt->tm_year;
+  m_month = lt->tm_mon;
+  m_day = lt->tm_mday;
+  m_hour = lt->tm_hour;
+  m_minute = lt->tm_min;
+  m_second = lt->tm_sec;
+
   if (! headerWrite (fs))
       return false;
 
index 5349601e3e4d044b022c7f4ce9916fe9aa9fee76..616f189333405a165cdc87093324842912745555 100644 (file)
@@ -1,5 +1,5 @@
 bin_PROGRAMS = ctsim pjrec phm2pj pj2if @lamprograms@  ifinfo phm2if if-1 if-2 if2img 
-bin_SCRIPTS = sample-pjrec.sh
+bin_SCRIPTS = sample-ctsim.sh
 EXTRA_PROGRAMS = pjrec-lam phm2pj-lam phm2if-lam
 INCLUDES=@my_includes@
 EXTRA_DIST=Makefile.nt mpiworld.cpp
index bf730ad7d902f1581ec5329d6f6caf3e7e0d2d4a..321fc5c5890a2fefe6e4b5a3bda926cbefb1804c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ifinfo.cpp,v 1.11 2000/06/26 21:15:24 kevin Exp $
+**  $Id: ifinfo.cpp,v 1.12 2000/06/27 10:48:11 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
@@ -145,22 +145,23 @@ ifinfo_main (int argc, char *const argv[])
   if (opt_stats)
     cout << "Image size: (" << im->nx() << "," << im->ny() << ")" << endl << endl;
 
+  if (im2)
+    cout << "Image 1: " << im->getFilename() << endl;
+    
   if (opt_labels) 
     im->printLabels (cout);
 
   if (opt_stats) {
-    if (im2)
-      cout << "Image 1" << endl;
-    
     im->printStatistics (cout);
 
     if (im2) {
       cout << endl;
 
+      cout << "Image 2: " << im2->getFilename() << endl;
+
       if (opt_labels)
        im2->printLabels(cout);
 
-      cout << "Image 2" << endl;
       im2->printStatistics (cout);
       cout << endl;
       
index 963a5cb2b4088294476f7373d15a9c4e54927f81..8723429cf541e18b959094799b60eabacebbf2c9 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pj2if.cpp,v 1.4 2000/06/26 21:15:24 kevin Exp $
+**  $Id: pj2if.cpp,v 1.5 2000/06/27 10:48:11 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
@@ -126,7 +126,7 @@ pj2if_main (const int argc, char *const argv[])
        }
     }
 
-  im.labelAdd (Array2dFileLabel::L_HISTORY, pj.remark(), pj.calcTime());
+  im.labelAdd (pj.getLabel());
   im.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .pj to .if");
   im.fileWrite (im_name);
   
index b5760a79361252a0047751acdc2e2cc5537b2906..1901952e5b9b03bdb30b10bcb3c4e2b0c0f228cc 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pjrec.cpp,v 1.1 2000/06/26 21:15:24 kevin Exp $
+**  $Id: pjrec.cpp,v 1.2 2000/06/27 10:48:11 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
@@ -288,7 +288,7 @@ pjrec_main (int argc, char * argv[])
 #endif
     {
       double calcTime = timerProgram.timerEnd();
-      imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, projGlobal.remark(), projGlobal.calcTime());
+      imGlobal->labelAdd (projGlobal.getLabel());
       imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark.c_str(), calcTime);
       imGlobal->fileWrite (filenameImage);
       if (optVerbose)