+2.0.0-b9 - 8/5/00
+ Added RPM Spec file for RPM package creation
+ Added loading of ASCII phanthom definitions from files
+
2.0.0-b8 - 8/1/00
Added line color support to SGP
Fixed lineAbs bug
Convert pol to C++ object.
+Add loading / saving of arbitrary phantom objections in ASCII format.
+
+Adding animation of X-ray projection collection
+
+Add animation of filtering & backprojections
+
PACKAGE=ctsim
-VERSION=2.0.0b8
+VERSION=2.0.0b9
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; }
dnl CDPATH=
AC_INIT(src/ctsim.cpp)
-AM_INIT_AUTOMAKE(ctsim,2.0.0b8)
+AM_INIT_AUTOMAKE(ctsim,2.0.0b9)
AM_CONFIG_HEADER(config.h)
dnl Checks for programs.
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: scanner.h,v 1.10 2000/07/31 14:48:35 kevin Exp $
+** $Id: scanner.h,v 1.11 2000/08/02 18:06:00 kevin Exp $
**
**
** This program is free software; you can redistribute it and/or modify
Scanner (const Phantom& phm, const char* const geometryName, int nDet, int nView, int nSample, const double rot_anglen);
~Scanner();
- void collectProjections (Projections& proj, const Phantom& phm, const int start_view, const int trace = TRACE_NONE, SGP* pSGP = NULL);
+ void collectProjections (Projections& proj, const Phantom& phm, const int start_view = 0, const int trace = TRACE_NONE, SGP* pSGP = NULL);
void setNView (int nView);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.h,v 1.12 2000/07/29 19:50:08 kevin Exp $
+** $Id: sgp.h,v 1.13 2000/08/02 18:06:00 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
};
#ifdef HAVE_WXWINDOWS
- SGPDriver (wxDC* pDC, const char* szWinTitle = "", int xsize = 640, int ysize = 480);
+ SGPDriver (wxDC* pDC, int xsize = 640, int ysize = 480);
#endif
SGPDriver (const char* szWinTitle = "", int xsize = 640, int ysize = 480);
void setTextAngle (double angle);
void setTextColor (int iFGcolor, int iBGcolor);
void setMarker (int idMarker, int color);
+ void setRasterOp (int ro);
void ctmClear ();
void ctmSet (const TransformationMatrix2D& m);
C_WHITE = 15,
};
+enum RasterOp {
+ RO_AND = 1,
+ RO_AND_INVERT,
+ RO_AND_REVERSE,
+ RO_CLEAR,
+ RO_COPY,
+ RO_EQUIV,
+ RO_INVERT,
+ RO_NAND,
+ RO_NOR,
+ RO_NO_OP,
+ RO_OR,
+ RO_OR_INVERT,
+ RO_OR_REVERSE,
+ RO_SET,
+ RO_SRC_INVERT,
+ RO_XOR,
+};
+
+
class RGBColor {
private:
short int r;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.cpp,v 1.8 2000/07/31 14:48:35 kevin Exp $
+** $Id: sgp.cpp,v 1.9 2000/08/02 18:06:00 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, const char* szWinTitle = "", int xsize = 640, int ysize = 480)
- : m_iPhysicalXSize(xsize), m_iPhysicalYSize(ysize), m_sWindowTitle(szWinTitle), m_idDriver(0)
+SGPDriver::SGPDriver (wxDC* pDC, int xsize = 640, int ysize = 480)
+ : m_iPhysicalXSize(xsize), m_iPhysicalYSize(ysize), m_idDriver(0)
{
m_pDC = pDC;
m_idDriver |= SGPDRIVER_WXWINDOWS;
}
}
+void
+SGP::setRasterOp (int ro)
+{
+#if HAVE_WXWINDOWS
+ if (m_driver.isWX()) {
+ int wxFxn = -1;
+ switch (ro) {
+ case RO_AND:
+ wxFxn = wxAND;
+ break;
+ case RO_AND_INVERT:
+ wxFxn = wxAND_INVERT;
+ break;
+ case RO_AND_REVERSE:
+ wxFxn = wxAND_REVERSE;
+ break;
+ case RO_CLEAR:
+ wxFxn = wxCLEAR;
+ break;
+ case RO_COPY:
+ wxFxn = wxCOPY;
+ break;
+ case RO_EQUIV:
+ wxFxn = wxEQUIV;
+ break;
+ case RO_INVERT:
+ wxFxn = wxINVERT;
+ break;
+ case RO_NAND:
+ wxFxn = wxNAND;
+ break;
+ case RO_NOR:
+ wxFxn = wxNOR;
+ break;
+ case RO_NO_OP:
+ wxFxn = wxNO_OP;
+ break;
+ case RO_OR:
+ wxFxn = wxOR;
+ break;
+ case RO_OR_INVERT:
+ wxFxn = wxOR_INVERT;
+ break;
+ case RO_OR_REVERSE:
+ wxFxn = wxOR_REVERSE;
+ break;
+ case RO_SET:
+ wxFxn = wxSET;
+ break;
+ case RO_SRC_INVERT:
+ wxFxn = wxSRC_INVERT;
+ break;
+ case RO_XOR:
+ wxFxn = wxXOR;
+ break;
+ }
+ if (wxFxn >= 0)
+ m_driver.idWX()->SetLogicalFunction (wxFxn);
+ }
+#endif
+}
+
+
void
SGP::setMarker (int idMarke, int iColor)
{
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phantom.cpp,v 1.14 2000/07/31 14:48:35 kevin Exp $
+** $Id: phantom.cpp,v 1.15 2000/08/02 18:06:00 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);
do {
- double cx, cy, u, v, rot, dens;
- char pelemtype[80];
- int n = fscanf (fp, "%79s %lf %lf %lf %lf %lf %lf",
- pelemtype, &cx, &cy, &u, &v, &rot, &dens);
+ if (! feof(fp)) {
+ double cx, cy, u, v, rot, dens;
+ char pelemtype[80];
+ char str[1024];
+ fgets (str, sizeof(str), fp);
+ int n = sscanf (str, "%79s %lf %lf %lf %lf %lf %lf", pelemtype, &cx, &cy, &u, &v, &rot, &dens);
- if (n == EOF || n == 0) { /* end of file */
- stoploop = true;
- retval = false;
- } else if (n != 7) {
- stoploop = true;
- retval = false;
+ if (n == EOF || n == 0) { /* end of file */
+ stoploop = true;
+ retval = false;
+ } else if (n != 7) {
+ stoploop = true;
+ retval = false;
+ } else {
+ addPElem (pelemtype, cx, cy, u, v, rot, dens);
+ retval = true;
+ }
} else {
- addPElem (pelemtype, cx, cy, u, v, rot, dens);
+ stoploop = true;
retval = true;
}
} while (stoploop == false);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: scanner.cpp,v 1.8 2000/07/31 14:48:35 kevin Exp $
+** $Id: scanner.cpp,v 1.9 2000/08/02 18:06:00 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 start_view, const int trace = TRACE_NONE, SGP* pSGP = NULL)
+Scanner::collectProjections (Projections& proj, const Phantom& phm, const int start_view = 0, const int trace = TRACE_NONE, SGP* pSGP = NULL)
{
GRFMTX_2D rotmtx_initial, temp;
GRFMTX_2D rotmtx_incr;
#ifdef HAVE_SGP
if (pSGP && m_trace >= TRACE_PHM) {
- double wsize = 1.42 * m_phmLen / 2; /* sqrt(2) * radius */
+ double halfPhmLen = m_phmLen / 2;
+ double wsize = SQRT2 * halfPhmLen;
+ pSGP->setRasterOp (RO_SET);
+ pSGP->eraseWindow ();
pSGP->setColor (C_LTBLUE);
pSGP->setWindow (xcent - wsize, ycent - wsize, xcent + wsize, ycent + wsize);
pSGP->setColor (C_BROWN);
-#if RADIUS
- pSGP->drawCircle (m_phmLen / 2);
-#else
- pSGP->drawRect (xcent - m_phmLen / 2, ycent - m_phmLen / 2,
- xcent + m_phmLen / 2, ycent + m_phmLen / 2);
-#endif
+ pSGP->drawRect (xcent - halfPhmLen, ycent - halfPhmLen, xcent + halfPhmLen, ycent + halfPhmLen);
pSGP->setColor (C_BROWN);
pSGP->moveAbs (0., 0.);
pSGP->drawCircle (wsize);
- // raysum_trace_menu_column = (crt->xsize * crt->asp) / 8 + 3;
+
traceShowParam ("X-Ray Simulator", "%s", RAYSUM_TRACE_ROW_TITLE, C_BLACK, " ");
traceShowParam ("---------------", "%s", RAYSUM_TRACE_ROW_TITLE2, C_BLACK, " ");
traceShowParam ("Phantom:", "%s", RAYSUM_TRACE_ROW_PHANT_ID, C_YELLOW, " Herman");
traceShowParam ("Chomaticity :", "%s", RAYSUM_TRACE_ROW_CHROMATIC, C_LTGREEN, "Mono");
traceShowParam ("Scatter :", "%5.1f", RAYSUM_TRACE_ROW_SCATTER, C_LTGREEN, 0.);
traceShowParam ("Photon Uncert:", "%5.1f", RAYSUM_TRACE_ROW_PHOT_STAT, C_LTGREEN, 0.);
- traceShowParam ("Num Scanners:", "%5d", RAYSUM_TRACE_ROW_NDET, C_LTRED, proj.nDet());
+ traceShowParam ("Num Detectors:", "%5d", RAYSUM_TRACE_ROW_NDET, C_LTRED, proj.nDet());
traceShowParam ("Num Views :", "%5d", RAYSUM_TRACE_ROW_NVIEW, C_LTRED, proj.nView());
traceShowParam ("Samples / Ray:", "%5d", RAYSUM_TRACE_ROW_SAMPLES, C_LTRED, m_nSample);
#ifdef HAVE_SGP
if (pSGP && m_trace >= TRACE_PHM) {
+ pSGP->setRasterOp (RO_XOR);
pSGP->setColor (C_RED);
pSGP->moveAbs (xd1, yd1);
pSGP->lineAbs (xd2, yd2);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.12 2000/07/31 23:07:23 kevin Exp $
+** $Id: views.cpp,v 1.13 2000/08/02 18:06:00 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
rProj.initFromScanner (theScanner);
#if 1
- //wxScrolledWindow win (m_canvas, -1, wxDefaultPosition, wxSize(500,500), 0);
- //win.SetSize (500, 500);
- // wxClientDC dc (&win);
- //win.PrepareDC ();
- //win.Show();
- wxClientDC dc (m_canvas);
- SGPDriver driver ((wxDC*) &dc, "Projections", 400, 400);
+ wxFrame frame (m_frame, -1, "", wxDefaultPosition, wxSize(500,500));
+ frame.Show();
+ wxClientDC dc (&frame);
+ int x, y;
+ frame.GetClientSize(&x, &y);
+ SGPDriver driver (dynamic_cast<wxDC*>(&dc), x, y);
SGP sgp (driver);
theScanner.collectProjections (rProj, rPhantom, 0, TRACE_PHM, &sgp);
#else
- theScanner.collectProjections (rProj, rPhantom, 0, TRACE_PHM);
+ theScanner.collectProjections (rProj, rPhantom);
#endif
pProjectionDoc->Modify(true);
{
int xsize, ysize;
m_canvas->GetClientSize (&xsize, &ysize);
- SGPDriver driver (dc, "", xsize, ysize);
+ SGPDriver driver (dc, xsize, ysize);
SGP sgp (driver);
const Phantom& rPhantom = GetDocument()->getPhantom();
sgp.setColor (C_RED);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2if.cpp,v 1.4 2000/07/23 01:49:03 kevin Exp $
+** $Id: phm2if.cpp,v 1.5 2000/08/02 18:06:00 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
{0, 0, 0, 0}
};
+static const char* szIdStr = "$Id";
+
void
phm2if_usage (const char *program)
{
}
#ifdef HAVE_MPI
-void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int opt_debug);
+void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int optDebug);
#endif
int
{
ImageFile* pImGlobal = NULL;
Phantom phm;
- int opt_nx = 0, opt_ny = 0;
- int opt_nsample = 1;
string optPhmName (Phantom::convertPhantomIDToName(Phantom::PHM_HERMAN));
string optFilterName;
string optDomainName (SignalFilter::convertDomainIDToName (SignalFilter::DOMAIN_SPATIAL));
- char *opt_outfile = NULL;
- int opt_debug = 0;
- string opt_desc;
- string opt_phmFileName;
- char *endstr, *endptr;
- double opt_filter_param = 1;
- double opt_filter_bw = 1.;
- int opt_trace = TRACE_NONE;
- bool opt_verbose = false;
+ string optOutFilename;
+ string optDesc;
+ string optPhmFilename;
+ int opt_nx = 0;
+ int opt_ny = 0;
+ int opt_nsample = 1;
+ double optFilterParam = 1.;
+ double optFilterBW = 1.;
+ int optTrace = TRACE_NONE;
+ bool optVerbose = false;
+ bool optDebug = false;
+ Timer timerProgram;
+
#ifdef HAVE_MPI
ImageFile* pImLocal = NULL;
MPIWorld mpiWorld (argc, argv);
-#endif
-
- Timer timerProgram;
-
-#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0) {
#endif
while (1) {
optPhmName = optarg;
break;
case O_PHMFILE:
- opt_phmFileName = optarg;
+ optPhmFilename = optarg;
break;
case O_VERBOSE:
- opt_verbose = true;
+ optVerbose = true;
break;
case O_DEBUG:
- opt_debug = 1;
+ optDebug = true;
break;
case O_TRACE:
- if ((opt_trace = TraceLevel::convertTraceNameToID(optarg)) == TRACE_INVALID) {
+ if ((optTrace = TraceLevel::convertTraceNameToID(optarg)) == TRACE_INVALID) {
phm2if_usage(argv[0]);
return (1);
}
optDomainName = optarg;
break;
case O_DESC:
- opt_desc = optarg;
+ optDesc = optarg;
break;
case O_FILTER_BW:
- opt_filter_bw = strtod(optarg, &endptr);
+ optFilterBW = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
sys_error(ERR_SEVERE,"Error setting --filter-bw to %s\n", optarg);
}
break;
case O_FILTER_PARAM:
- opt_filter_param = strtod(optarg, &endptr);
+ optFilterParam = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
sys_error(ERR_SEVERE,"Error setting --filter-param to %s\n", optarg);
}
}
- if (optPhmName == "" && optFilterName == "" && opt_phmFileName == "") {
+ if (optPhmName == "" && optFilterName == "" && optPhmFilename == "") {
cerr << "No phantom defined" << endl << endl;
phm2if_usage(argv[0]);
return (1);
phm2if_usage(argv[0]);
return (1);
}
- opt_outfile = argv[optind];
+ optOutFilename = argv[optind];
opt_nx = strtol(argv[optind+1], &endptr, 10);
endstr = argv[optind+1] + strlen(argv[optind+1]);
if (endptr != endstr) {
ostringstream oss;
oss << "phm2if: nx=" << opt_nx << ", ny=" << opt_ny << ", nsample=" << opt_nsample << ", ";
- if (opt_phmFileName != "")
- oss << "phantom=" << opt_phmFileName;
+ if (optPhmFilename != "")
+ oss << "phantomFile=" << optPhmFilename;
else if (optPhmName != "")
oss << "phantom=" << optPhmName;
else if (optFilterName != "") {
oss << "filter=" << optFilterName << " - " << optDomainName;
}
- if (opt_desc != "")
- oss << ": " << opt_desc;
- opt_desc = oss.str();
+ if (optDesc != "")
+ oss << ": " << optDesc;
+ optDesc = oss.str();
if (optPhmName != "") {
phm.createFromPhantom (optPhmName.c_str());
}
}
- if (opt_phmFileName != "") {
- phm.createFromFile(opt_phmFileName.c_str());
+ if (optPhmFilename != "") {
+ phm.createFromFile(optPhmFilename.c_str());
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0)
cerr << "Can't use phantom from file in MPI mode" << endl;
#endif
}
- if (opt_verbose)
+ if (optVerbose)
cout << "Rasterize Phantom to Image" << endl << endl;
#ifdef HAVE_MPI
}
#ifdef HAVE_MPI
TimerCollectiveMPI timerBcast (mpiWorld.getComm());
mpiWorld.BcastString (optPhmName);
- mpiWorld.getComm().Bcast (&opt_verbose, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_debug, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optVerbose, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optDebug, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optTrace, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_nx, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_ny, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_nsample, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
- mpiWorld.getComm().Bcast (&opt_filter_bw, 1, MPI::DOUBLE, 0);
+ mpiWorld.getComm().Bcast (&optFilterParam, 1, MPI::DOUBLE, 0);
+ mpiWorld.getComm().Bcast (&optFilterBW, 1, MPI::DOUBLE, 0);
mpiWorld.BcastString (optFilterName);
mpiWorld.BcastString (optDomainName);
- if (opt_verbose)
+ if (optVerbose)
timerBcast.timerEndAndReport ("Time to broadcast variables");
mpiWorld.setTotalWorkUnits (opt_nx);
}
} else if (optFilterName != "") {
if (mpiWorld.getRank() == 0) {
- pImGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
+ pImGlobal->filterResponse (optDomainName.c_str(), optFilterBW, optFilterName.c_str(), optFilterParam);
}
} else {
TimerCollectiveMPI timerRasterize (mpiWorld.getComm());
- phm.convertToImagefile (*pImLocal, opt_nsample, opt_trace, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits());
- if (opt_verbose)
+ phm.convertToImagefile (*pImLocal, opt_nsample, optTrace, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits());
+ if (optVerbose)
timerRasterize.timerEndAndReport ("Time to rasterize phantom");
TimerCollectiveMPI timerGather (mpiWorld.getComm());
- mpi_gather_image (mpiWorld, pImGlobal, pImLocal, opt_debug);
- if (opt_verbose)
+ mpi_gather_image (mpiWorld, pImGlobal, pImLocal, optDebug);
+ if (optVerbose)
timerGather.timerEndAndReport ("Time to gather image");
}
#else
if (phm.getComposition() == P_UNIT_PULSE) {
v[opt_nx/2][opt_ny/2] = 1.;
} else if (optFilterName != "") {
- pImGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
+ pImGlobal->filterResponse (optDomainName.c_str(), optFilterBW, optFilterName.c_str(), optFilterParam);
} else {
#if HAVE_SGP
- if (opt_trace >= TRACE_PHM)
+ if (optTrace >= TRACE_PHM)
phm.show();
#endif
- phm.convertToImagefile (*pImGlobal, opt_nsample, opt_trace);
+ phm.convertToImagefile (*pImGlobal, opt_nsample, optTrace);
}
#endif
#endif
{
double calctime = timerProgram.timerEnd ();
- pImGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
- pImGlobal->fileWrite (opt_outfile);
- if (opt_verbose)
+ pImGlobal->labelAdd (Array2dFileLabel::L_HISTORY, optDesc.c_str(), calctime);
+ pImGlobal->fileWrite (optOutFilename.c_str());
+ if (optVerbose)
cout << "Time to rasterized phantom: " << calctime << " seconds" << endl;
- if (opt_trace >= TRACE_PHM) {
+ if (optTrace >= TRACE_PHM) {
double dmin, dmax;
int nscale;
#ifdef HAVE_MPI
-void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int opt_debug)
+void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int optDebug)
{
ImageFileArray vLocal = pImLocal->getArray();
ImageFileArray vGlobal = NULL;