** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: backprojectors.h,v 1.16 2000/12/03 15:16:17 kevin Exp $
+** $Id: backprojectors.h,v 1.17 2000/12/06 01:46:43 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
{
public:
BackprojectTrig (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
- : Backproject::Backproject (proj, im, interpID, interpFactor)
+ : Backproject (proj, im, interpID, interpFactor)
{}
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
};
BackprojectTable (const Projections& proj, ImageFile& im, int interpID, const int interpFactor);
virtual ~BackprojectTable ();
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
protected:
Array2d<kfloat64> arrayR;
BackprojectDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor);
~BackprojectDiff ();
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
protected:
double start_r;
{
public:
BackprojectDiff2 (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
- : BackprojectDiff::BackprojectDiff (proj, im, interpID, interpFactor)
+ : BackprojectDiff (proj, im, interpID, interpFactor)
{}
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
};
class BackprojectIntDiff2 : public BackprojectDiff
{
public:
BackprojectIntDiff2 (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
- : BackprojectDiff::BackprojectDiff (proj, im, interpID, interpFactor)
+ : BackprojectDiff (proj, im, interpID, interpFactor)
{}
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
};
{
public:
BackprojectIntDiff3 (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
- : BackprojectDiff::BackprojectDiff (proj, im, interpID, interpFactor)
+ : BackprojectDiff (proj, im, interpID, interpFactor)
{}
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
};
class BackprojectEquilinear : public BackprojectTable
{
public:
BackprojectEquilinear (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
- : BackprojectTable::BackprojectTable (proj, im, interpID, interpFactor)
+ : BackprojectTable (proj, im, interpID, interpFactor)
{}
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
virtual ~BackprojectEquilinear()
{}
{
public:
BackprojectEquiangular (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
- : BackprojectTable::BackprojectTable (proj, im, interpID, interpFactor)
+ : BackprojectTable (proj, im, interpID, interpFactor)
{}
- void BackprojectView (const double* const t, double view_angle);
+ void BackprojectView (const double* const t, const double view_angle);
virtual ~BackprojectEquiangular()
{}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctsupport.h,v 1.7 2000/11/28 14:54:07 kevin Exp $
+** $Id: ctsupport.h,v 1.8 2000/12/06 01:46:43 kevin Exp $
**
**
** This program is free software; you can redistribute it and/or modify
inline T nearest (double x)
{ return (x > 0 ? static_cast<T>(x+0.5) : static_cast<T>(x-0.5)); }
+inline int imax (int a, int b)\r
+{ return (a >= b ? a : b); }\r
+\r
template<class T>
inline T clamp (T value, T lowerBounds, T upperBounds)
{ return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); }
//////////////////////////////////////////////////////////////
// clip.cpp
-int clip_rect (double& x1, double& y1, double& x2, double& y2, const double rect[4]);
+bool clip_rect (double& x1, double& y1, double& x2, double& y2, const double rect[4]);
int clip_segment (double& x1, double& y1, double& x2, double& y2, const double u, const double v);
int clip_sector (double& x1, double& y1, double& x2, double& y2, const double u, const double v);
int clip_circle (double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.h,v 1.15 2000/11/28 14:54:07 kevin Exp $
+** $Id: ezplot.h,v 1.16 2000/12/06 01:46:43 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
string c_legend;; // current legend specified
int o_linestyle, o_color; // style to use for curves all subsequent curves to EZPLOT
- bool o_xaxis, o_yaxis; // Specifies where axis & labels are drawn
+ int o_xaxis, o_yaxis; // Specifies where axis & labels are drawn
bool o_grid; // Flag to draw a grid at major ticks
bool o_box; // Flag to draw a box around the graph
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phantom.h,v 1.15 2000/12/04 05:36:57 kevin Exp $
+** $Id: phantom.h,v 1.16 2000/12/06 01:46:43 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
#ifndef PHANTOM_H
#define PHANTOM_H
-#ifndef MSVC\r
-#include <slist>
-#endif\r
+#include <list>
#include "ctsupport.h"
using namespace std;
const double xmax() const {return m_xmax;}
const double ymin() const {return m_ymin;}
const double ymax() const {return m_ymax;}
- slist<PhantomElement*>& listPElem() {return m_listPElem;}
- const slist<PhantomElement*>& listPElem() const {return m_listPElem;}
+ list<PhantomElement*>& listPElem() {return m_listPElem;}
+ const list<PhantomElement*>& listPElem() const {return m_listPElem;}
const int nPElem() const {return m_nPElem;}
static const int getPhantomCount() {return s_iPhantomCount;}
int m_nPElem; // number of pelems in phantom
double m_xmin, m_xmax, m_ymin, m_ymax; // extent of pelems in pelem coordinates
double m_diameter; // diameter of object
- mutable slist<PhantomElement*> m_listPElem; // pelem lists
+ mutable list<PhantomElement*> m_listPElem; // pelem lists
string m_name;
int m_id;
bool m_fail;
Phantom& operator= (const Phantom&); // assignment operator
};
-typedef slist<PhantomElement*>::iterator PElemIterator;
-typedef slist<PhantomElement*>::const_iterator PElemConstIterator;
+typedef list<PhantomElement*>::iterator PElemIterator;
+typedef list<PhantomElement*>::const_iterator PElemConstIterator;
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.h,v 1.19 2000/12/04 04:15:48 kevin Exp $
+** $Id: sgp.h,v 1.20 2000/12/06 01:46:43 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
#include <string>
-
+using namespace std;
class SGPDriver {
private:
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: transformmatrix.h,v 1.1 2000/07/28 08:28:08 kevin Exp $
+** $Id: transformmatrix.h,v 1.2 2000/12/06 01:46:43 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
#ifndef __H_TRANSFORMMATRIX
#define __H_TRANSFORMMATRIX
-class ostream;
+#include <ostream>\r
+
class TransformationMatrix2D {
public:
double mtx[3][3];
void transformPoint (double *pX, double *pY) const;
- void print (ostream& ostr) const;
+ void print (std::ostream& ostr) const;
friend const TransformationMatrix2D operator* (const TransformationMatrix2D& lhs, const TransformationMatrix2D& rhs);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.cpp,v 1.15 2000/09/09 09:31:12 kevin Exp $
+** $Id: ezplot.cpp,v 1.16 2000/12/06 01:46:43 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
void
EZPlot::addCurve (const double *y, int n)
{
- double x [n];
+ double* x = new double [n];
for (int i = 0; i < n; i++)
x[i] = i;
addCurve (x, y, n);
+ delete x;
}
void
EZPlot::addCurve (const float *y, int n)
{
- double yDouble [n];
+ double* yDouble = new double [n];
for (int i = 0; i < n; i++)
yDouble[i] = y[i];
addCurve (yDouble, n);
+ delete yDouble;
}
void
EZPlot::addCurve (const float x[], const double y[], int num)
{
- double dx [num];
+ double* dx = new double [num];
for (int i = 0; i < num; i++)
dx[i] = x[i];
addCurve (dx, y, num);
+ delete dx;
}
void
EZPlot::addCurve (const double x[], const float y[], int num)
{
- double dy [num];
+ double* dy = new double [num];
for (int i = 0; i < num; i++)
dy[i] = y[i];
addCurve (x, dy, num);
+
+ delete dy;
}
// calculate legend box boundaries
int max_leg = 0; // longest legend in characters
int num_leg = 0; // number of legend titles
- for (EZPlotCurveConstIterator iterCurve = m_vecCurves.begin(); iterCurve != m_vecCurves.end(); iterCurve++) {
- const EZPlotCurve& curve = **iterCurve;
+ for (EZPlotCurveConstIterator iterCurve2 = m_vecCurves.begin(); iterCurve2 != m_vecCurves.end(); iterCurve2++) {
+ const EZPlotCurve& curve = **iterCurve2;
int nLegend = curve.m_sLegend.length();
if (nLegend > 0) {
++num_leg;
- max_leg = max (max_leg, nLegend);
+ if (nLegend > max_leg)\r
+ nLegend = max_leg;
}
}
double symwidth = charwidth;
double symheight = charheight;
- for (EZPlotCurveIterator iterCurve = m_vecCurves.begin(); iterCurve != m_vecCurves.end(); iterCurve++) {
- const EZPlotCurve& curve = **iterCurve;
+ for (EZPlotCurveIterator iterCurve3 = m_vecCurves.begin(); iterCurve3 != m_vecCurves.end(); iterCurve3++) {
+ const EZPlotCurve& curve = **iterCurve3;
rSGP.setColor (curve.m_iColor);
double delta = (maxval - minval) / nint;
double absmin = fabs(minval);
- double absmax = fabs(maxval);
- double logt = log10( max(absmin, absmax) );
+ double absmax = fabs(maxval);\r
+ if (absmin > absmax)\r
+ absmax = absmin;
+ double logt = log10( absmax );
if (fabs(logt) >= 6) { // use exponential format
if (fabs(logt) > 99)
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
- ** $Id: ezset.cpp,v 1.7 2000/07/29 19:50:08 kevin Exp $
+ ** $Id: ezset.cpp,v 1.8 2000/12/06 01:46:43 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
int code;
bool retval = true;
if (! pol_usertok (str, &code)) {
- cerr << "Illegal EZSET command: " << str << endl;
+ sys_error(ERR_WARNING, "Illegal EZSET command: %s", str);
pol_reader();
retval = false;
}
void
EZPlot::bad_option (char *opt)
{
- cerr << opt << " is an INVALID option\n";
+ sys_error (ERR_WARNING, "INVALID option: %s", opt);
}
/*----------------------------------------------------------------------*/
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.cpp,v 1.16 2000/10/11 08:16:08 kevin Exp $
+** $Id: sgp.cpp,v 1.17 2000/12/06 01:46:43 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
int SGP::s_iRGBColorCount = sizeof(s_aRGBColor) / sizeof(class RGBColor);
#ifdef HAVE_WXWINDOWS
-SGPDriver::SGPDriver (wxDC* pDC, int xsize = 640, int ysize = 480)
+SGPDriver::SGPDriver (wxDC* pDC, int xsize, int ysize)
: m_iPhysicalXSize(xsize), m_iPhysicalYSize(ysize), m_idDriver(0), m_pDC(pDC)
{
m_idDriver |= SGPDRIVER_WXWINDOWS;
}
#endif
-SGPDriver::SGPDriver (const char* szWinTitle = "", int xsize = 640, int ysize = 480)
+SGPDriver::SGPDriver (const char* szWinTitle, int xsize, int ysize)
: m_iPhysicalXSize(xsize), m_iPhysicalYSize(ysize), m_sWindowTitle(szWinTitle), m_idDriver(0)
{
#ifdef HAVE_G2_H
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: transformmatrix.cpp,v 1.2 2000/12/04 04:44:02 kevin Exp $
+** $Id: transformmatrix.cpp,v 1.3 2000/12/06 01:46:43 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
double determ = determinant ();
if (fabs(determ) < 1E-6) {
sys_error (ERR_WARNING, "Determinant = %g [TransformationMatrix2D::invert]", determ);\r
- print (cout);\r
- cout << endl;
+ print (std::cout);\r
+ std::cout << std::endl;
}
b[0][0] = (mtx[1][1] * mtx[2][2] - mtx[2][1] * mtx[1][2]) / determ;
}
void
-TransformationMatrix2D::print (ostream& ostr) const
+TransformationMatrix2D::print (std::ostream& ostr) const
{
- cout << mtx[0][0] << " " << mtx[0][1] << " " << mtx[0][2] << endl;
- cout << mtx[1][0] << " " << mtx[1][1] << " " << mtx[1][2] << endl;
- cout << mtx[2][0] << " " << mtx[2][1] << " " << mtx[2][2] << endl;
+ std::cout << mtx[0][0] << " " << mtx[0][1] << " " << mtx[0][2] << std::endl;
+ std::cout << mtx[1][0] << " " << mtx[1][1] << " " << mtx[1][2] << std::endl;
+ std::cout << mtx[2][0] << " " << mtx[2][1] << " " << mtx[2][2] << std::endl;
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: array2dfile.cpp,v 1.14 2000/12/04 19:50:57 kevin Exp $
+** $Id: array2dfile.cpp,v 1.15 2000/12/06 01:46:43 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
fs.writeFloat64 (m_offsetPV);
fs.writeFloat64 (m_scalePV);
- m_headersize = fs.tellp();
+ m_headersize = static_cast<kuint16>(fs.tellp());
fs.seekp (0);
fs.writeInt16 (m_headersize);
kuint16 strLength;
fs.readInt16 (strLength);
- char* labelStr = new char [strLength+1];
- fs.read (labelStr, strLength);
- labelStr[strLength] = 0;
+ char* pszLabelStr = new char [strLength+1];
+ fs.read (pszLabelStr, strLength);
+ pszLabelStr[strLength] = 0;
- Array2dFileLabel* pLabel = new Array2dFileLabel(labelType, labelStr, calcTime);
- delete labelStr;\r
+ Array2dFileLabel* pLabel = new Array2dFileLabel (labelType, pszLabelStr, calcTime);
+ delete pszLabelStr;\r
\r
pLabel->setDateTime (year, month, day, hour, minute, second);
m_labels.push_back (pLabel);\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: backprojectors.cpp,v 1.16 2000/12/04 19:50:57 kevin Exp $
+** $Id: backprojectors.cpp,v 1.17 2000/12/06 01:46:43 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
// Precalculates trigometric function value for each point in image for backprojection.
BackprojectTable::BackprojectTable (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
- : Backproject::Backproject (proj, im, interpType, interpFactor)
+ : Backproject (proj, im, interpType, interpFactor)
{
arrayR.initSetSize (im.nx(), im.ny());
arrayPhi.initSetSize (im.nx(), im.ny());
// Iterates in x & y direction by adding difference in L position
BackprojectDiff::BackprojectDiff (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
- : Backproject::Backproject (proj, im, interpType, interpFactor)
+ : Backproject (proj, im, interpType, interpFactor)
{
// calculate center of first pixel v[0][0]
double x = xMin + xInc / 2;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: imagefile.cpp,v 1.16 2000/12/04 05:36:57 kevin Exp $
+** $Id: imagefile.cpp,v 1.17 2000/12/06 01:46:43 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
F32Image::F32Image (int nx, int ny)\r
- : Array2dFile::Array2dFile (nx, ny, sizeof(kfloat32), Array2dFile::PIXEL_FLOAT32)\r
+ : Array2dFile (nx, ny, sizeof(kfloat32), Array2dFile::PIXEL_FLOAT32)\r
{\r
}\r
\r
-F32Image::F32Image (void)[\r
- : Array2dFile::Array2dFile()\r
+F32Image::F32Image (void)\r
+ : Array2dFile()\r
{\r
setPixelFormat (Array2dFile::PIXEL_FLOAT32);\r
setPixelSize (sizeof(kfloat32));\r
}\r
\r
F64Image::F64Image (int nx, int ny)\r
- : Array2dFile::Array2dFile (nx, ny, sizeof(kfloat64), Array2dFile::PIXEL_FLOAT64)\r
+ : Array2dFile (nx, ny, sizeof(kfloat64), Array2dFile::PIXEL_FLOAT64)\r
{\r
}\r
\r
F64Image::F64Image (void)\r
- : Array2dFile::Array2dFile ()\r
+ : Array2dFile ()\r
{\r
setPixelFormat (PIXEL_FLOAT64);\r
setPixelSize (sizeof(kfloat64));\r
double absErrorSum = 0.;
double sqDiffFromMeanSum = 0.;
double absValueSum = 0.;
- for (unsigned int ix = 0; ix < m_nx; ix++) {
+ for (unsigned int ix2 = 0; ix2 < m_nx; ix2++) {
for (unsigned int iy = 0; iy < m_ny; iy++) {
- double diff = v[ix][iy] - vComp[ix][iy];
+ double diff = v[ix2][iy] - vComp[ix2][iy];
sqErrorSum += diff * diff;
absErrorSum += fabs(diff);
- double diffFromMean = v[ix][iy] - myMean;
+ double diffFromMean = v[ix2][iy] - myMean;
sqDiffFromMeanSum += diffFromMean * diffFromMean;
- absValueSum += fabs(v[ix][iy]);
+ absValueSum += fabs(v[ix2][iy]);
}
}
int hx = m_nx / 2;
int hy = m_ny / 2;
double eMax = -1;
- for (int ix = 0; ix < hx; ix++) {
+ for (int ix3 = 0; ix3 < hx; ix3++) {
for (int iy = 0; iy < hy; iy++) {
- double avgPixel = 0.25 * (v[2*ix][2*iy] + v[2*ix+1][2*iy] + v[2*ix][2*iy+1] + v[2*ix+1][2*iy+1]);
- double avgPixelComp = 0.25 * (vComp[2*ix][2*iy] + vComp[2*ix+1][2*iy] + vComp[2*ix][2*iy+1] + vComp[2*ix+1][2*iy+1]);
+ double avgPixel = 0.25 * (v[2*ix3][2*iy] + v[2*ix3+1][2*iy] + v[2*ix3][2*iy+1] + v[2*ix3+1][2*iy+1]);
+ double avgPixelComp = 0.25 * (vComp[2*ix3][2*iy] + vComp[2*ix3+1][2*iy] + vComp[2*ix3][2*iy+1] + vComp[2*ix3+1][2*iy+1]);
double error = fabs (avgPixel - avgPixelComp);
if (error > eMax)
eMax = error;
double spread = max - min;
mode = 0;
stddev = 0;
- for (int ix = 0; ix < nx; ix++) {
+ for (int ix4 = 0; ix4 < nx; ix4++) {
for (int iy = 0; iy < ny; iy++) {
- int b = static_cast<int>((((v[ix][iy] - min) / spread) * (nbin - 1)) + 0.5);
+ int b = static_cast<int>((((v[ix4][iy] - min) / spread) * (nbin - 1)) + 0.5);
hist[b]++;
double diff = (v[ix][iy] - mean);
stddev += diff * diff;
mode = (max_binindex * spread / (nbin - 1)) + min;
int nPixels = nx * ny;
- slist<double> vecImage;
- for (int ix = 0; ix < nx; ix++)
+ list<double> vecImage;
+ for (int ix5 = 0; ix5 < nx; ix5++)
for (int iy = 0; iy < ny; iy++)
- vecImage.push_front (v[ix][iy]);
+ vecImage.push_front (v[ix5][iy]);
vecImage.sort();
- slist<double>::const_iterator iter = vecImage.begin();
+ list<double>::const_iterator iter = vecImage.begin();
for (int i = 0; i < (nPixels / 2) - 1; i++)
iter++; // Advance iterator to (nPixels / 2) - 1;
int ny = m_ny;
ImageFileArray v = getArray();
- unsigned char rowp [nx * nxcell];
+ unsigned char* rowp = new unsigned char [nx * nxcell];
if ((fp = fopen (outfile, "wb")) == NULL)
return;
fputc( rowp[ic], fp );
}
}
-
+\r
+ delete rowp;
fclose(fp);
}
int ny = m_ny;
ImageFileArray v = getArray();
- unsigned char rowp [nx * nxcell];
+ unsigned char* rowp = new unsigned char [nx * nxcell];
if ((fp = fopen (outfile, "wb")) == NULL)
return;
fprintf(fp, "\n");
}
}
-
+\r
+ delete rowp;
fclose(fp);
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phantom.cpp,v 1.20 2000/12/04 05:36:57 kevin Exp $
+** $Id: phantom.cpp,v 1.21 2000/12/06 01:46:43 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
#include "ct.h"
-const int Phantom::POINTS_PER_CIRCLE = 360;\r
-const double Phantom::SCALE_PELEM_EXTENT=0.005; // increase pelem limits by 0.5% \r
+const int PhantomElement::POINTS_PER_CIRCLE = 360;\r
+const double PhantomElement::SCALE_PELEM_EXTENT=0.005; // increase pelem limits by 0.5% \r
const int Phantom::PHM_INVALID = -1;
const int Phantom::PHM_HERMAN = 0;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: procsignal.cpp,v 1.7 2000/09/07 14:29:05 kevin Exp $
+** $Id: procsignal.cpp,v 1.8 2000/12/06 01:46:43 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_dFilterInc = (m_dFilterMax - m_dFilterMin) / (m_nFilterPoints - 1);
SignalFilter filter (m_idFilter, m_dFilterMin, m_dFilterMax, m_nFilterPoints, m_dBandwidth, m_dFilterParam, SignalFilter::DOMAIN_FREQUENCY);
m_adFilter = new double[ m_nFilterPoints ];
- double adFrequencyFilter [m_nFilterPoints];
+ double* adFrequencyFilter = new double [m_nFilterPoints];
filter.copyFilterData (adFrequencyFilter, 0, m_nFilterPoints);
#ifdef HAVE_SGP
EZPlot* pEZPlot = NULL;
}
#endif
ProcessSignal::finiteFourierTransform (adFrequencyFilter, m_adFilter, m_nFilterPoints, -1);
+ delete adFrequencyFilter;\r
#ifdef HAVE_SGP
if (pEZPlot && m_traceLevel >= Trace::TRACE_PLOT) {
pEZPlot->ezset ("title Inverse Fourier Frequency: Fourier Order");
if (m_traceLevel >= Trace::TRACE_CONSOLE)
cout << "nFilterPoints = " << m_nFilterPoints << endl;
#endif
- double adSpatialFilter [m_nFilterPoints];
+ double* adSpatialFilter = new double [m_nFilterPoints];\r
SignalFilter filter (m_idFilter, m_dFilterMin, m_dFilterMax, nSpatialPoints, m_dBandwidth, m_dFilterParam, SignalFilter::DOMAIN_SPATIAL);
filter.copyFilterData (adSpatialFilter, 0, nSpatialPoints);
#ifdef HAVE_SGP
double dScale = 0.5 * sinScale * sinScale;
adSpatialFilter[i] *= dScale;
}
- }
- for (int i = nSpatialPoints; i < m_nFilterPoints; i++)
+ }\r
+ int i;
+ for (i = nSpatialPoints; i < m_nFilterPoints; i++)
adSpatialFilter[i] = 0;
m_adFilter = new double [m_nFilterPoints];
- complex<double> acInverseFilter [m_nFilterPoints];
+ complex<double>* acInverseFilter = new complex<double> [m_nFilterPoints];\r
finiteFourierTransform (adSpatialFilter, acInverseFilter, m_nFilterPoints, 1);
- for (int i = 0; i < m_nFilterPoints; i++)
- m_adFilter[i] = abs(acInverseFilter[i]) * m_dSignalInc;
+ delete adSpatialFilter;\r
+ for (i = 0; i < m_nFilterPoints; i++)
+ m_adFilter[i] = abs(acInverseFilter[i]) * m_dSignalInc;
+ delete acInverseFilter;\r
#ifdef HAVE_SGP
if (pEZPlot && m_traceLevel >= Trace::TRACE_PLOT) {
pEZPlot->ezset ("title Spatial Filter: Inverse");
pEZPlot->ezset ("yporigin 0.50");
pEZPlot->addCurve (m_adFilter, m_nFilterPoints);
pEZPlot->plot();
- delete pEZPlot;
+ delete pEZPlot;\r
}
#endif
}
// precalculate sin and cosine tables for fourier transform
if (m_idFilterMethod == FILTER_METHOD_FOURIER_TABLE) {
- int nFourier = max(m_nFilterPoints,m_nOutputPoints) * max(m_nFilterPoints, m_nOutputPoints) + 1;
+ int nFourier = imax (m_nFilterPoints,m_nOutputPoints) * imax (m_nFilterPoints, m_nOutputPoints) + 1;
double angleIncrement = (2. * PI) / m_nFilterPoints;
m_adFourierCosTable = new double[ nFourier ];
m_adFourierSinTable = new double[ nFourier ];
void
ProcessSignal::filterSignal (const float constInput[], double output[]) const
{
- double input [m_nSignalPoints];
- for (int i = 0; i < m_nSignalPoints; i++)
+ double* input = new double [m_nSignalPoints];
+ int i;\r
+ for (i = 0; i < m_nSignalPoints; i++)
input[i] = constInput[i];
if (m_idGeometry == Scanner::GEOMETRY_EQUILINEAR) {
int iDetFromCenter = i - (m_nSignalPoints / 2);
input[i] *= m_dFocalLength * cos (iDetFromCenter * m_dSignalInc);
}
- }
+ }\r
if (m_idFilterMethod == FILTER_METHOD_CONVOLUTION) {
- for (int i = 0; i < m_nSignalPoints; i++)
+ for (i = 0; i < m_nSignalPoints; i++)
output[i] = convolve (input, m_dSignalInc, i, m_nSignalPoints);
} else if (m_idFilterMethod == FILTER_METHOD_FOURIER) {
- double inputSignal[m_nFilterPoints];
- for (int i = 0; i < m_nSignalPoints; i++)
+ double* inputSignal = new double [m_nFilterPoints];
+ for (i = 0; i < m_nSignalPoints; i++)
inputSignal[i] = input[i];
- for (int i = m_nSignalPoints; i < m_nFilterPoints; i++)
+ for (i = m_nSignalPoints; i < m_nFilterPoints; i++)
inputSignal[i] = 0; // zeropad
- complex<double> fftSignal[m_nFilterPoints];
- finiteFourierTransform (inputSignal, fftSignal, m_nFilterPoints, -1);
- for (int i = 0; i < m_nFilterPoints; i++)
+ complex<double>* fftSignal = new complex<double> [m_nFilterPoints];
+ finiteFourierTransform (inputSignal, fftSignal, m_nFilterPoints, -1);\r
+ delete inputSignal;
+ for (i = 0; i < m_nFilterPoints; i++)
fftSignal[i] *= m_adFilter[i];
- double inverseFourier[m_nFilterPoints];
- finiteFourierTransform (fftSignal, inverseFourier, m_nFilterPoints, 1);
- for (int i = 0; i < m_nSignalPoints; i++)
- output[i] = inverseFourier[i];
+ double* inverseFourier = new double [m_nFilterPoints];
+ finiteFourierTransform (fftSignal, inverseFourier, m_nFilterPoints, 1);\r
+ delete fftSignal;
+ for (i = 0; i < m_nSignalPoints; i++)
+ output[i] = inverseFourier[i];\r
+ delete inverseFourier;
} else if (m_idFilterMethod == FILTER_METHOD_FOURIER_TABLE) {
- double inputSignal[m_nFilterPoints];
- for (int i = 0; i < m_nSignalPoints; i++)
+ double* inputSignal = new double [m_nFilterPoints];
+ for (i = 0; i < m_nSignalPoints; i++)
inputSignal[i] = input[i];
- for (int i = m_nSignalPoints; i < m_nFilterPoints; i++)
+ for (i = m_nSignalPoints; i < m_nFilterPoints; i++)
inputSignal[i] = 0; // zeropad
- complex<double> fftSignal[m_nFilterPoints];
- finiteFourierTransform (inputSignal, fftSignal, -1);
- for (int i = 0; i < m_nFilterPoints; i++)
+ complex<double>* fftSignal = new complex<double> [m_nFilterPoints];
+ finiteFourierTransform (inputSignal, fftSignal, -1);\r
+ delete inputSignal;
+ for (i = 0; i < m_nFilterPoints; i++)
fftSignal[i] *= m_adFilter[i];
- double inverseFourier[m_nFilterPoints];
- finiteFourierTransform (fftSignal, inverseFourier, 1);
- for (int i = 0; i < m_nSignalPoints; i++)
- output[i] = inverseFourier[i];
+ double* inverseFourier = new double [m_nFilterPoints];
+ finiteFourierTransform (fftSignal, inverseFourier, 1);\r
+ delete fftSignal;
+ for (i = 0; i < m_nSignalPoints; i++)
+ output[i] = inverseFourier[i];\r
+ delete inverseFourier;
}
#if HAVE_FFTW
else if (m_idFilterMethod == FILTER_METHOD_RFFTW) {
for (int i = 0; i < m_nSignalPoints * m_iPreinterpolationFactor; i++)
output[i] = ifftOutput[i].re;
}
-#endif
+#endif\r
+ delete input;
}
void
ProcessSignal::finiteFourierTransform (const double input[], double output[], const int n, int direction)
{
- complex<double> complexOutput[n];
+ complex<double>* complexOutput = new complex<double> [n];
finiteFourierTransform (input, complexOutput, n, direction);
for (int i = 0; i < n; i++)
- output[i] = complexOutput[i].real();
+ output[i] = complexOutput[i].real();\r
+ delete [] complexOutput;
}
void
void
ProcessSignal::shuffleNaturalToFourierOrder (double* pdVector, const int n)
{
- double* pdTemp = new double [n];
+ double* pdTemp = new double [n];\r
+ int i;
if (n % 2) { // Odd
int iHalfN = (n - 1) / 2;
pdTemp[0] = pdVector[iHalfN];
- for (int i = 0; i < iHalfN; i++)
+ for (i = 0; i < iHalfN; i++)
pdTemp[i + 1] = pdVector[i + 1 + iHalfN];
- for (int i = 0; i < iHalfN; i++)
+ for (i = 0; i < iHalfN; i++)
pdTemp[i + iHalfN + 1] = pdVector[i];
} else { // Even
int iHalfN = n / 2;
pdTemp[0] = pdVector[iHalfN];
- for (int i = 0; i < iHalfN; i++)
+ for (i = 0; i < iHalfN; i++)
pdTemp[i + 1] = pdVector[i + iHalfN];
- for (int i = 0; i < iHalfN - 1; i++)
+ for (i = 0; i < iHalfN - 1; i++)
pdTemp[i + iHalfN + 1] = pdVector[i];
}
- for (int i = 0; i < n; i++)
+ for (i = 0; i < n; i++)
pdVector[i] = pdTemp[i];
delete pdTemp;
}
void
ProcessSignal::shuffleFourierToNaturalOrder (double* pdVector, const int n)
{
- double* pdTemp = new double [n];
+ double* pdTemp = new double [n];\r
+ int i;
if (n % 2) { // Odd
int iHalfN = (n - 1) / 2;
- pdTemp[iHalfN] = pdVector[0];
- for (int i = 0; i < iHalfN; i++)
+ pdTemp[iHalfN] = pdVector[0];\r
+ for (i = 0; i < iHalfN; i++)
pdTemp[i + 1 + iHalfN] = pdVector[i + 1];
- for (int i = 0; i < iHalfN; i++)
+ for (i = 0; i < iHalfN; i++)
pdTemp[i] = pdVector[i + iHalfN + 1];
} else { // Even
int iHalfN = n / 2;
pdTemp[iHalfN] = pdVector[0];
- for (int i = 0; i < iHalfN; i++)
+ for (i = 0; i < iHalfN; i++)
pdTemp[i] = pdVector[i + iHalfN];
- for (int i = 0; i < iHalfN - 1; i++)
+ for (i = 0; i < iHalfN - 1; i++)
pdTemp[i + iHalfN + 1] = pdVector[i+1];
}
- for (int i = 0; i < n; i++)
+ for (i = 0; i < n; i++)
pdVector[i] = pdTemp[i];
delete pdTemp;
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: projections.cpp,v 1.27 2000/12/04 05:36:57 kevin Exp $
+** $Id: projections.cpp,v 1.28 2000/12/06 01:46:43 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
return false;
}
- char remarkStorage[_remarksize+1];
- fs.read (remarkStorage, _remarksize);
+ char* pszRemarkStorage = new char [_remarksize+1];
+ fs.read (pszRemarkStorage, _remarksize);
if (! fs) {
sys_error (ERR_SEVERE, "Error reading remark, _remarksize = %d", _remarksize);
return false;
}
- remarkStorage[_remarksize] = 0;
- m_remark = remarkStorage;
+ pszRemarkStorage[_remarksize] = 0;
+ m_remark = pszRemarkStorage;
+ delete pszRemarkStorage;\r
off_t _hsizeread = fs.tellg();
if (!fs || _hsizeread != _hsize) {
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: reconstruct.cpp,v 1.1 2000/09/02 05:13:57 kevin Exp $
+** $Id: reconstruct.cpp,v 1.2 2000/12/06 01:46:43 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
void
Reconstructor::reconstructView (int iStartView, int iViewCount, SGP* pSGP)
{
- double adFilteredProj [m_nFilteredProjections]; // filtered projections
+ double* adFilteredProj = new double [m_nFilteredProjections]; // filtered projections
if (iViewCount <= 0)
iViewCount = m_rProj.nView() - iStartView;
}
#endif //HAVE_SGP
}
+\r
+ delete adFilteredProj;\r
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: scanner.cpp,v 1.16 2000/12/03 12:22:46 kevin Exp $
+** $Id: scanner.cpp,v 1.17 2000/12/06 01:46:43 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
}
void
-Scanner::collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews, bool bStoreAtViewPosition, const int trace, SGP* pSGP = NULL)
+Scanner::collectProjections (Projections& proj, const Phantom& phm, const int iStartView, const int iNumViews, bool bStoreAtViewPosition, const int trace, SGP* pSGP)
{
m_trace = trace;
double start_angle = iStartView * proj.rotInc();
{
char szValue[256];
- vsnprintf (szValue, sizeof(szValue), fmt, args);
+#ifdef MSVC
+ vsprintf (szValue, fmt, args);
+#else
+ vnsprintf (szValue, sizeof(szValue), fmt, args);
+#endif
// cio_set_cpos (raysum_trace_menu_column, row);
// cio_set_text_clr (color - 8, 0);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: clip.cpp,v 1.4 2000/07/23 01:49:03 kevin Exp $
+** $Id: clip.cpp,v 1.5 2000/12/06 01:46:43 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
static int rectcode (double x, double y, const double rect[4]);
-int
+bool\r
clip_rect (double& x1, double& y1, double& x2, double& y2, const double rect[4])
{
double x = 0, y = 0;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: syserror.cpp,v 1.6 2000/09/07 04:31:41 kevin Exp $
+** $Id: syserror.cpp,v 1.7 2000/12/06 01:46:43 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 (nErrorCount > MAX_ERROR_COUNT)
return;
else if (nErrorCount == MAX_ERROR_COUNT) {
- cout << "*****************************************************************" << endl;
- cout << "*** M A X I M U M E R R O R C O U N T R E A C H E D ***" << endl;
- cout << "*** ***" << endl;
- cout << "*** No further errors will be reported ***" << endl;
- cout << "*****************************************************************" << endl;
+ std::cout << "*****************************************************************\n";
+ std::cout << "*** M A X I M U M E R R O R C O U N T R E A C H E D ***\n";
+ std::cout << "*** ***\n";
+ std::cout << "*** No further errors will be reported ***\n";
+ std::cout << "*****************************************************************\n";
return;
}
}
switch (severity) {
case ERR_FATAL:
- cout << "FATAL ERROR: ";
+ std::cout << "FATAL ERROR: ";
break;
case ERR_SEVERE:
- cout << "SEVERE ERROR: ";
+ std::cout << "SEVERE ERROR: ";
break;
case ERR_WARNING:
- cout << "WARNING ERROR: ";
+ std::cout << "WARNING ERROR: ";
break;
default:
- cout << "Illegal error code #" << severity << ": ";
+ std::cout << "Illegal error code #" << severity << ": ";
}
char errStr[512];
vsprintf (errStr, msg, arg);
#endif
- cout << errStr << endl;
+ std::cout << errStr << std::endl;
if (severity == ERR_FATAL)
- throw runtime_error (errStr);
+ throw std::runtime_error (errStr);
#if INTERACTIVE_ERROR_DISPLAY
- cout << "A - Abort C - Continue W - Turn off warnings? ";
+ std::cout << "A - Abort C - Continue W - Turn off warnings? ";
// fflush(stderr);
do
{