From 6afa21de8aa00b405de47584efe108c71df33e1b Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sat, 16 Dec 2000 02:44:26 +0000 Subject: [PATCH] r256: *** empty log message *** --- include/array2dfile.h | 12 +++++--- include/ct.h | 4 +-- include/ctsupport.h | 5 ++- libctsim/array2dfile.cpp | 4 +-- libctsim/imagefile.cpp | 5 +-- libctsim/procsignal.cpp | 66 +++++++++++++++++++++------------------- libctsim/reconstruct.cpp | 7 +++-- libctsim/scanner.cpp | 4 +-- libctsupport/msvc.cpp | 8 +++++ tools/pjrec.cpp | 6 ++-- 10 files changed, 70 insertions(+), 51 deletions(-) create mode 100644 libctsupport/msvc.cpp diff --git a/include/array2dfile.h b/include/array2dfile.h index 512772d..1a0d838 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.9 2000/12/06 15:17:51 kevin Exp $ +** $Id: array2dfile.h,v 1.10 2000/12/16 02:44:26 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 @@ -34,9 +34,11 @@ #include #include -#include -#include -#include +#include +#include +#include +#include +#include #include #include "ctsupport.h" #include "fnetorderstream.h" @@ -88,7 +90,7 @@ public: const string& getDateString () const; - void print (ostream& os) const; + void print (std::ostream& os) const; Array2dFileLabel (const Array2dFileLabel& rhs); diff --git a/include/ct.h b/include/ct.h index 16b79a6..255e905 100644 --- a/include/ct.h +++ b/include/ct.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ct.h,v 1.43 2000/12/15 23:48:25 kevin Exp $ +** $Id: ct.h,v 1.44 2000/12/16 02:44:26 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 @@ -41,7 +41,7 @@ #ifdef HAVE_CONFIG_H #include #endif - + #define HAVE_ANSI_CPP 1 #ifdef HAVE_ANSI_CPP #include diff --git a/include/ctsupport.h b/include/ctsupport.h index ce05b3b..6263b69 100644 --- a/include/ctsupport.h +++ b/include/ctsupport.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctsupport.h,v 1.10 2000/12/06 16:41:17 kevin Exp $ +** $Id: ctsupport.h,v 1.11 2000/12/16 02:44:26 kevin Exp $ ** ** ** This program is free software; you can redistribute it and/or modify @@ -225,6 +225,9 @@ inline T nearest (double x) inline int imax (int a, int b) { return (a >= b ? a : b); } +inline double dmax (double a, double b) +{ return (a >= b ? a : b); } + template inline T clamp (T value, T lowerBounds, T upperBounds) { return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); } diff --git a/libctsim/array2dfile.cpp b/libctsim/array2dfile.cpp index b3538da..b3dc432 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.19 2000/12/16 02:31:00 kevin Exp $ +** $Id: array2dfile.cpp,v 1.20 2000/12/16 02:44:26 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 @@ -139,7 +139,7 @@ Array2dFileLabel::operator= (const Array2dFileLabel& rhs) } void -Array2dFileLabel::print (ostream& os) const +Array2dFileLabel::print (std::ostream& os) const { if (m_labelType == L_HISTORY) { os << "History: " << endl; diff --git a/libctsim/imagefile.cpp b/libctsim/imagefile.cpp index 851b4fd..a751573 100644 --- a/libctsim/imagefile.cpp +++ b/libctsim/imagefile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: imagefile.cpp,v 1.18 2000/12/16 02:31:00 kevin Exp $ +** $Id: imagefile.cpp,v 1.19 2000/12/16 02:44:26 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 @@ -399,7 +399,7 @@ ImageFile::writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nyc int ny = m_ny; ImageFileArray v = getArray(); - unsigned char rowp [nx * nxcell * (bitdepth / 8)]; + unsigned char* rowp = new unsigned char [nx * nxcell * (bitdepth / 8)]; if ((fp = fopen (outfile, "wb")) == NULL) return; @@ -451,6 +451,7 @@ ImageFile::writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nyc png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); + delete rowp; fclose(fp); } diff --git a/libctsim/procsignal.cpp b/libctsim/procsignal.cpp index db00df7..cd44cf8 100644 --- a/libctsim/procsignal.cpp +++ b/libctsim/procsignal.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: procsignal.cpp,v 1.8 2000/12/06 01:46:43 kevin Exp $ +** $Id: procsignal.cpp,v 1.9 2000/12/16 02:44:26 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 @@ -115,7 +115,8 @@ ProcessSignal::ProcessSignal (const char* szFilterName, const char* szFilterMeth void ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandwidth, double dSignalIncrement, int nSignalPoints, double dFilterParam, const int idDomain, const int idFilterGeneration, const int iZeropad, const int iPreinterpolationFactor, int iTraceLevel, int iGeometry, double dFocalLength, SGP* pSGP) -{ +{ + int i; m_idFilter = idFilter; m_idDomain = idDomain; m_idFilterMethod = idFilterMethod; @@ -220,15 +221,15 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw delete pEZPlot; } #endif - for (int i = 0; i < m_nFilterPoints; i++) { + for (i = 0; i < m_nFilterPoints; i++) { m_adFilter[i] /= m_dSignalInc; } } if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) { - for (int i = 0; i < m_nFilterPoints; i++) + for (i = 0; i < m_nFilterPoints; i++) m_adFilter[i] *= 0.5; } else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) { - for (int i = 0; i < m_nFilterPoints; i++) { + for (i = 0; i < m_nFilterPoints; i++) { int iDetFromZero = i - ((m_nFilterPoints - 1) / 2); double sinScale = sin (iDetFromZero * m_dSignalInc); if (fabs(sinScale) < 1E-7) @@ -278,10 +279,10 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw // This doesn't work! // Need to add filtering for divergent geometries & Frequency/Direct filtering if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) { - for (int i = 0; i < m_nFilterPoints; i++) + for (i = 0; i < m_nFilterPoints; i++) m_adFilter[i] *= 0.5; } else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) { - for (int i = 0; i < m_nFilterPoints; i++) { + for (i = 0; i < m_nFilterPoints; i++) { int iDetFromZero = i - ((m_nFilterPoints - 1) / 2); double sinScale = sin (iDetFromZero * m_dSignalInc); if (fabs(sinScale) < 1E-7) @@ -350,10 +351,10 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw } #endif if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) { - for (int i = 0; i < m_nFilterPoints; i++) + for (i = 0; i < m_nFilterPoints; i++) adSpatialFilter[i] *= 0.5; } else if (m_idGeometry == Scanner::GEOMETRY_EQUIANGULAR) { - for (int i = 0; i < m_nFilterPoints; i++) { + for (i = 0; i < m_nFilterPoints; i++) { int iDetFromZero = i - ((m_nFilterPoints - 1) / 2); double sinScale = sin (iDetFromZero * m_dSignalInc); if (fabs(sinScale) < 1E-7) @@ -364,7 +365,6 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw adSpatialFilter[i] *= dScale; } } - int i; for (i = nSpatialPoints; i < m_nFilterPoints; i++) adSpatialFilter[i] = 0; @@ -395,7 +395,7 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw m_adFourierCosTable = new double[ nFourier ]; m_adFourierSinTable = new double[ nFourier ]; double angle = 0; - for (int i = 0; i < nFourier; i++) { + for (i = 0; i < nFourier; i++) { m_adFourierCosTable[i] = cos (angle); m_adFourierSinTable[i] = sin (angle); angle += angleIncrement; @@ -404,7 +404,7 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw #if HAVE_FFTW if (m_idFilterMethod == FILTER_METHOD_FFTW || m_idFilterMethod == FILTER_METHOD_RFFTW) { - for (int i = 0; i < m_nFilterPoints; i++) //fftw uses unnormalized fft + for (i = 0; i < m_nFilterPoints; i++) //fftw uses unnormalized fft m_adFilter[i] /= m_nFilterPoints; } @@ -413,16 +413,16 @@ ProcessSignal::init (const int idFilter, const int idFilterMethod, double dBandw m_realPlanBackward = rfftw_create_plan (m_nOutputPoints, FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE); m_adRealFftInput = new fftw_real [ m_nFilterPoints ]; m_adRealFftSignal = new fftw_real [ m_nOutputPoints ]; - for (int i = 0; i < m_nFilterPoints; i++) + for (i = 0; i < m_nFilterPoints; i++) m_adRealFftInput[i] = 0; } else if (m_idFilterMethod == FILTER_METHOD_FFTW) { m_complexPlanForward = fftw_create_plan (m_nFilterPoints, FFTW_FORWARD, FFTW_ESTIMATE); m_complexPlanBackward = fftw_create_plan (m_nOutputPoints, FFTW_BACKWARD, FFTW_ESTIMATE); m_adComplexFftInput = new fftw_complex [ m_nFilterPoints ]; m_adComplexFftSignal = new fftw_complex [ m_nOutputPoints ]; - for (int i = 0; i < m_nFilterPoints; i++) + for (i = 0; i < m_nFilterPoints; i++) m_adComplexFftInput[i].re = m_adComplexFftInput[i].im = 0; - for (int i = 0; i < m_nOutputPoints; i++) + for (i = 0; i < m_nOutputPoints; i++) m_adComplexFftSignal[i].re = m_adComplexFftSignal[i].im = 0; } #endif @@ -583,34 +583,38 @@ ProcessSignal::filterSignal (const float constInput[], double output[]) const } #if HAVE_FFTW else if (m_idFilterMethod == FILTER_METHOD_RFFTW) { - for (int i = 0; i < m_nSignalPoints; i++) + for (i = 0; i < m_nSignalPoints; i++) m_adRealFftInput[i] = input[i]; - fftw_real fftOutput [ m_nFilterPoints ]; + fftw_real* fftOutput = new fftw_real [ m_nFilterPoints ]; rfftw_one (m_realPlanForward, m_adRealFftInput, fftOutput); - for (int i = 0; i < m_nFilterPoints; i++) - m_adRealFftSignal[i] = m_adFilter[i] * fftOutput[i]; - for (int i = m_nFilterPoints; i < m_nOutputPoints; i++) - m_adRealFftSignal[i] = 0; + for (i = 0; i < m_nFilterPoints; i++) + m_adRealFftSignal[i] = m_adFilter[i] * fftOutput[i]; + delete [] fftOutput; + for (i = m_nFilterPoints; i < m_nOutputPoints; i++) + m_adRealFftSignal[i] = 0; - fftw_real ifftOutput [ m_nOutputPoints ]; + fftw_real* ifftOutput = new fftw_real [ m_nOutputPoints ]; rfftw_one (m_realPlanBackward, m_adRealFftSignal, ifftOutput); - for (int i = 0; i < m_nSignalPoints * m_iPreinterpolationFactor; i++) - output[i] = ifftOutput[i]; + for (i = 0; i < m_nSignalPoints * m_iPreinterpolationFactor; i++) + output[i] = ifftOutput[i]; + delete [] ifftOutput; } else if (m_idFilterMethod == FILTER_METHOD_FFTW) { - for (int i = 0; i < m_nSignalPoints; i++) + for (i = 0; i < m_nSignalPoints; i++) m_adComplexFftInput[i].re = input[i]; - fftw_complex fftOutput [ m_nFilterPoints ]; + fftw_complex* fftOutput = new fftw_complex [ m_nFilterPoints ]; fftw_one (m_complexPlanForward, m_adComplexFftInput, fftOutput); - for (int i = 0; i < m_nFilterPoints; i++) { + for (i = 0; i < m_nFilterPoints; i++) { m_adComplexFftSignal[i].re = m_adFilter[i] * fftOutput[i].re; m_adComplexFftSignal[i].im = m_adFilter[i] * fftOutput[i].im; - } - fftw_complex ifftOutput [ m_nOutputPoints ]; + } + delete [] fftOutput; + fftw_complex* ifftOutput = new fftw_complex [ m_nOutputPoints ]; fftw_one (m_complexPlanBackward, m_adComplexFftSignal, ifftOutput); - for (int i = 0; i < m_nSignalPoints * m_iPreinterpolationFactor; i++) - output[i] = ifftOutput[i].re; + for (i = 0; i < m_nSignalPoints * m_iPreinterpolationFactor; i++) + output[i] = ifftOutput[i].re; + delete [] ifftOutput; } #endif delete input; diff --git a/libctsim/reconstruct.cpp b/libctsim/reconstruct.cpp index 58f17bc..591aed2 100644 --- a/libctsim/reconstruct.cpp +++ b/libctsim/reconstruct.cpp @@ -8,7 +8,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: reconstruct.cpp,v 1.2 2000/12/06 01:46:43 kevin Exp $ +** $Id: reconstruct.cpp,v 1.3 2000/12/16 02:44:26 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 @@ -108,7 +108,7 @@ Reconstructor::plotFilter (SGP* pSGP) { #if HAVE_SGP int nVecFilter = m_pProcessSignal->getNFilterPoints(); - double adPlotXAxis [nVecFilter]; + double* adPlotXAxis = new double [nVecFilter]; if (nVecFilter > 0 && pSGP) { double f = m_pProcessSignal->getFilterMin(); @@ -123,7 +123,8 @@ Reconstructor::plotFilter (SGP* pSGP) ezplot.addCurve (adPlotXAxis, m_pProcessSignal->getFilter(), nVecFilter); ezplot.plot(); } - } + } + delete adPlotXAxis; #endif } diff --git a/libctsim/scanner.cpp b/libctsim/scanner.cpp index 48f2394..cf6c78c 100644 --- a/libctsim/scanner.cpp +++ b/libctsim/scanner.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: scanner.cpp,v 1.18 2000/12/16 02:31:00 kevin Exp $ +** $Id: scanner.cpp,v 1.19 2000/12/16 02:44:26 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 @@ -303,7 +303,7 @@ Scanner::collectProjections (Projections& proj, const Phantom& phm, const int iS if (pSGP && m_trace >= Trace::TRACE_PHANTOM) { m_pSGP = pSGP; m_pSGP->eraseWindow(); - double dWindowSize = max(m_detLen, m_dFocalLength * 2) * SQRT2; + double dWindowSize = dmax (m_detLen, m_dFocalLength * 2) * SQRT2; double dHalfWindowSize = dWindowSize / 2; m_dXMinWin = m_dXCenter - dHalfWindowSize; m_dXMaxWin = m_dXCenter + dHalfWindowSize; diff --git a/libctsupport/msvc.cpp b/libctsupport/msvc.cpp new file mode 100644 index 0000000..02266ae --- /dev/null +++ b/libctsupport/msvc.cpp @@ -0,0 +1,8 @@ +#include "ct.h" + +// Work around bug in VC6 +#ifdef MSVC +const struct fpos_t std::_Fpz = {0, 0}; +#endif + + diff --git a/tools/pjrec.cpp b/tools/pjrec.cpp index 33fe7d3..841a198 100644 --- a/tools/pjrec.cpp +++ b/tools/pjrec.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: pjrec.cpp,v 1.17 2000/09/02 05:10:39 kevin Exp $ +** $Id: pjrec.cpp,v 1.18 2000/12/16 02:44:26 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 @@ -27,7 +27,7 @@ #include "ct.h" #include "timer.h" - + enum {O_INTERP, O_FILTER, O_FILTER_METHOD, O_ZEROPAD, O_FILTER_PARAM, O_FILTER_GENERATION, O_BACKPROJ, O_PREINTERPOLATION_FACTOR, O_VERBOSE, O_TRACE, O_HELP, O_DEBUG, O_VERSION}; @@ -49,7 +49,7 @@ static struct option my_options[] = {0, 0, 0, 0} }; -static const char* g_szIdStr = "$Id: pjrec.cpp,v 1.17 2000/09/02 05:10:39 kevin Exp $"; +static const char* g_szIdStr = "$Id: pjrec.cpp,v 1.18 2000/12/16 02:44:26 kevin Exp $"; void pjrec_usage (const char *program) -- 2.34.1