From 949b7c917af311cd38f911bc5d0af36f524a6086 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 27 Jun 2000 10:48:11 +0000 Subject: [PATCH] r122: *** empty log message *** --- ChangeLog | 3 +- configure | 10 ++--- configure.in | 2 +- include/array2dfile.h | 8 +++- include/projections.h | 18 ++++++++- libctsim/array2dfile.cpp | 8 ++-- libctsim/projections.cpp | 87 ++++++++++++++++++++++++++++------------ src/Makefile.am | 2 +- src/ifinfo.cpp | 11 ++--- src/pj2if.cpp | 4 +- src/pjrec.cpp | 4 +- 11 files changed, 109 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76d6a7a..ee0e059 100644 --- 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 diff --git a/configure b/configure index 0143ad3..c4db024 100755 --- 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 <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff --git a/configure.in b/configure.in index 761d95a..947c976 100644 --- a/configure.in +++ b/configure.in @@ -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. diff --git a/include/array2dfile.h b/include/array2dfile.h index da4671e..05d7b85 100644 --- a/include/array2dfile.h +++ b/include/array2dfile.h @@ -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; } diff --git a/include/projections.h b/include/projections.h index 6446f57..8d5acac 100644 --- a/include/projections.h +++ b/include/projections.h @@ -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); diff --git a/libctsim/array2dfile.cpp b/libctsim/array2dfile.cpp index d603813..315ff46 100644 --- a/libctsim/array2dfile.cpp +++ b/libctsim/array2dfile.cpp @@ -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; } diff --git a/libctsim/projections.cpp b/libctsim/projections.cpp index cd151be..7b13546 100644 --- a/libctsim/projections.cpp +++ b/libctsim/projections.cpp @@ -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; diff --git a/src/Makefile.am b/src/Makefile.am index 5349601..616f189 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/ifinfo.cpp b/src/ifinfo.cpp index bf730ad..321fc5c 100644 --- a/src/ifinfo.cpp +++ b/src/ifinfo.cpp @@ -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; diff --git a/src/pj2if.cpp b/src/pj2if.cpp index 963a5cb..8723429 100644 --- a/src/pj2if.cpp +++ b/src/pj2if.cpp @@ -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); diff --git a/src/pjrec.cpp b/src/pjrec.cpp index b5760a7..1901952 100644 --- a/src/pjrec.cpp +++ b/src/pjrec.cpp @@ -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) -- 2.34.1