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
# 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
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; }
if test -n "$lamdir" ; then
- lamprograms="ctrec-lam phm2if-lam phm2pj-lam"
+ lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
fi
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
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
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.
** 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
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; }
** 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
class Scanner;
class DetectorArray;
+class Array2dFileLabel;
+
// Projections
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]); }
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);
** 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
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;
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;
}
** 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
/* 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;
if (! fs)
return false;
- fs.writeInt32 (_hsize);
+ fs.writeInt16 (_hsize);
+ fs.writeInt16 (_signature);
fs.writeInt32 (_nView);
fs.writeInt32 (_nDet);
fs.writeInt32 (_geom);
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;
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);
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) {
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;
}
Projections::read (const char* filename)
{
frnetorderstream fileRead (filename, ios::in | ios::binary);
+ m_filename = filename;
if (! fileRead)
return false;
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;
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
** 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
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;
** 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
}
}
- 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);
** 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
#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)