+0.6.1 - 6/12/2000
+ Converted Phantom and PhantomElements to Object-Oriented
+ Converted Detector to Object-Oriented
+
0.6.0-b3 - 6/10/2000
Improved Integer backprojection method
Fixed nearest neighbor to be truly nearest neighbor
dnl CDPATH=
AC_INIT(src/ctrec.cpp)
-AM_INIT_AUTOMAKE(ctsim,0.6.0-b3)
+AM_INIT_AUTOMAKE(ctsim,0.6.1)
AM_CONFIG_HEADER(config.h)
dnl Checks for programs.
-noinst_HEADERS=ascii.h cio.h ct.h ezplot.h ir.h keyboard.h kmath.h kstddef.h pol.h sgp.h array2d.h imagefile.h backprojectors.h mpiworld.h
+noinst_HEADERS=ascii.h cio.h ct.h ezplot.h ir.h keyboard.h kmath.h kstddef.h pol.h sgp.h array2d.h imagefile.h backprojectors.h mpiworld.h byteorder.h phantom.h timer.h sstream
+
+
+
--- /dev/null
+#ifndef NETORDER_H
+#define NETORDER_H
+
+/* netorder.cpp */
+
+void *strreverse (void *dest, const void *src, size_t n);
+int read_nint16 (kuint16 *n, int fd);
+int write_nint16 (kuint16 const *n, int fd);
+int read_nint32 (kuint32 *n, int fd);
+int write_nint32 (kuint32 const *n, int fd);
+int read_nfloat32 (float *f, int fd);
+int write_nfloat32 (float const *f, int fd);
+int read_nfloat64 (double *d, int fd);
+int write_nfloat64 (double const *d, int fd);
+void ConvertNetworkOrder (void* buffer, size_t bytes);
+void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+
+#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ct.h,v 1.13 2000/06/10 23:00:17 kevin Exp $
+** $Id: ct.h,v 1.14 2000/06/15 19:07:10 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 "png.h"
#endif
#ifdef HAVE_G2_H
- #ifdef __cplusplus
- extern "C" {
- #include "g2.h"
- }
- #else
- #include "g2.h"
- #endif
- #ifdef HAVE_X11
- #ifdef __cplusplus
- extern "C" {
- #include "g2_X11.h"
- }
- #else
- #include "g2_X11.h"
- #endif
- #endif
+extern "C" {
+#include "g2.h"
+}
+#ifdef HAVE_X11
+extern "C" {
+#include "g2_X11.h"
+}
+#endif
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#include "kmath.h"
#include "keyboard.h"
#include "cio.h"
+#include "byteorder.h"
#ifdef HAVE_SGP
#include "ezplot.h"
#endif
#include <iostream>
+#include <sstream>
#include <string>
+#include <iterator>
+#include <algorithm>
using namespace std;
#include "array2d.h"
#include "imagefile.h"
#include "ir.h"
+#include "phantom.h"
#include "backprojectors.h"
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ir.h,v 1.26 2000/06/13 16:20:31 kevin Exp $
+** $Id: ir.h,v 1.27 2000/06/15 19:07:10 kevin Exp $
**
**
** This program is free software; you can redistribute it and/or modify
#define IR_H
-static const int POINTS_PER_CIRCLE=90;
-#define MAXREMARK 99
-
-typedef enum {
- RECTANGLE,
- TRIANGLE,
- ELLIPSE,
- SECTOR,
- SEGMENT
-} PElmType;
-
-
-class PhmElement
-{
- public:
- PElmType type; /* pelm type (box, ellipse, etc) */
- double atten; /* X-ray attenuation coefficient */
- double cx,cy; /* center of pelm */
- double u,v; /* size of pelm */
- double rot; /* pelm rotation angle (in radians) */
- double *x, *y; /* ptr to array of points in obj world coord */
- int pts; /* number of points in outline arrays */
- double xmin, xmax, ymin, ymax; /* pelm limits */
- double radius; /* " */
- GRFMTX_2D p_to_o; /* map from phantom to standard pelm coords */
- GRFMTX_2D o_to_p; /* map from std pelm coords to phantom coords */
- class PhmElement *next; /* pointer to next pelm in phantom */
-};
-typedef class PhmElement PELM;
-
-typedef enum {
- P_PELMS, /* Phantom made of Pelms */
- P_UNIT_PULSE, /* Special phantom, not made of pelms */
- P_FILTER /* defined only by this type */
-} PhmType;
-
-
-/* Phantom class */
-class Phantom
-{
-public:
- PELM *pelm_list; /* pelm linked-list */
- PhmType type;
- int n_pelm; /* number of pelms in phantom */
- double xmin, xmax, ymin, ymax; /* extent of pelms in pelm coordinates */
- double radius; /* " " */
-};
-typedef class Phantom PHANTOM;
+#include "phantom.h"
/*----------------------------------------------------------------------*/
double xs1,ys1,xs2,ys2; /* Coordinates of source endpoints */
double angle; /* Starting angle */
} init;
+
+ Detector (const Phantom& phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
+ ~Detector();
+
};
-typedef class Detector DETECTOR;
class Projections
int geometry; /* Geometry of scanner */
struct DetectorArray **view; /* Pointer to array of detarray_st pointers */
- char remark[MAXREMARK+1]; /* description of raysum data */
+ string remark; /* description of raysum data */
double calctime; /* time required to calculate raysums */
int ndet; /* number of detectors in array */
double det_inc; /* increment between detectors */
double phmlen; /* Length of PHANTOM edge (phm is square) */
};
-typedef class Projections RAYSUM;
-
+typedef class Projections RAYSUM;
/*----------------------------------------------------------------------*/
/* USER SYMBOLS */
/*----------------------------------------------------------------------*/
-/* Codes for Coordinate Types */
-/* Defines coords for pelm_is_point_inside() */
-
-typedef enum {
- PELM_COORD, /* Normalized Pelm Coordinates */
- PHM_COORD /* User's phantom Coordinates */
-} CoordType;
-
/* Codes for Filter types */
typedef enum { /* filter types for filter_generate() */
I_LINEAR /* Linear interpolation */
} InterpolationType;
-/* Constants for sizing PHANTOM */
-
-static const double PERCENT_PHM_SIZE_INCR=0.0; /* Fractional increase in phantom limits compared to pelm size */
static const int N_EXTRA_DETECTORS=4; /* Number of extra detectors widths when calculating detlen */
static const char O_TRACE_NONE_STR[]= "none";
double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
/* dialogs.cpp */
-int phm_add_pelm_kb (PHANTOM *phm);
-PHANTOM *phm_select (void);
+bool phm_add_pelem_kb (Phantom& phm);
+const Phantom& phm_select (Phantom& phm);
int interpolation_select (void);
int filter_select (double *filter_param);
BackprojType opt_set_backproj(const char *optarg);
const char *name_of_backproj(const BackprojType backproj);
-/* phm.cpp */
-PHANTOM *phm_create(const int phmid);
-PHANTOM *phm_create_from_file(const char *fname);
-PHANTOM *phm_init(void);
-void phm_free (PHANTOM *phm);
-int phm_add_pelm_file(PHANTOM *phm, const char *fname);
-void phm_add_pelm (PHANTOM *phm, const char *type, const double cx, const double cy,
- const double u, const double v, const double rot, const double atten);
-int pelm_make_points(PELM *obj);
-void pelm_make_xform (PELM *obj);
-PELM *pelm_alloc(void);
-void calc_arc(double x[], double y[], const int pts, const double xcent, const double ycent,
- const double r, const double start, const double stop);
-void calc_ellipse(double x[], double y[], const int pts, const double u, const double v);
-int circle_pts(double theta);
-void phm_print(PHANTOM *phm);
-#if HAVE_SGP
-void phm_show(const PHANTOM *phm);
-void phm_draw(const PHANTOM *phm);
-#endif
-
-/* phmstd.cpp */
-void phm_std_herman (PHANTOM *phm);
-void phm_std_rowland (PHANTOM *phm);
-void phm_std_rowland_bordered (PHANTOM *phm);
-
/* raycollect.cpp */
-int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PHANTOM *phm, const int start_view, const int trace, const int unit_pulse);
-void rayview(const PHANTOM *phm, DETARRAY *darray, const DETECTOR *det, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
-double phm_ray_attenuation (const PHANTOM *phm, const double x1, const double y1, const double x2, const double y2);
-double pelm_ray_attenuation (PELM *pelm, const double x1, const double y1, const double x2, const double y2);
-int pelm_clip_line (const PELM *pelm, double& x1, double& y1, double& x2, double& y2);
+int raysum_collect (RAYSUM *rs, const Detector& det, const Phantom& phm, const int start_view, const int trace, const int unit_pulse);
+void rayview (const Phantom& phm, DETARRAY *darray, const Detector& det, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
+double phm_ray_attenuation (const Phantom& phm, const double x1, const double y1, const double x2, const double y2);
+double pelem_ray_attenuation (PhantomElement& pelem, const double x1, const double y1, const double x2, const double y2);
void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...);
-/* scanner.cpp */
-DETECTOR *detector_create(const PHANTOM *phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
-void detector_free(DETECTOR *det);
-
/* rayio.cpp */
RAYSUM *raysum_create(const char *fname, const int nview, const int ndet);
-RAYSUM *raysum_create_from_det(const char *fname, const DETECTOR *det);
+RAYSUM *raysum_create_from_det(const char *fname, const Detector& det);
RAYSUM *raysum_open(const char *filename);
void raysum_alloc_views(RAYSUM *rs);
void raysum_free(RAYSUM *rs);
int detarray_write(RAYSUM *rs, const DETARRAY *darray, const int view_num);
/* From phm2image.cpp */
-void phm_to_imagefile (const PHANTOM *phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
-int pelm_is_point_inside(PELM *obj, const double x, const double y, const CoordType coord_type);
+void phm_to_imagefile (const Phantom& phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
/* image.cpp */
void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: kmath.h,v 1.12 2000/06/13 16:20:31 kevin Exp $
+** $Id: kmath.h,v 1.13 2000/06/15 19:07:10 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 <stdio.h>
#include <math.h>
-#include <algo.h>
#define PI 3.14159265358979323846
#define HALFPI 1.57079632679489661923 /* PI divided by 2 */
#define F_EPSILON 1.0E-6
#define D_EPSILON 1.0E-10
-#define DEG_TO_RAD(x) (x*(PI/180.))
-#define RAD_TO_DEG(x) (x*(180./PI))
-
#define ASSUMEDZERO 1E-10
typedef double GRFMTX_2D[3][3];
typedef double GRFMTX_3D[4][4];
+inline double
+convertDegreesToRadians (double x)
+{ return (x * (PI/180.)); }
+
+inline double
+convertRadiansToDegrees (double x)
+{ return (x*(180./PI)); }
template<class T>
inline T nearest (double x)
{ return (x > 0 ? static_cast<T>(x+0.5) : static_cast<T>(x-0.5)); }
template<class T>
-inline T clamp (T value, T upperBounds, T lowerBounds)
+inline T clamp (T value, T lowerBounds, T upperBounds)
{ return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); }
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: kstddef.h,v 1.16 2000/06/13 16:20:31 kevin Exp $
+** $Id: kstddef.h,v 1.17 2000/06/15 19:07:10 kevin Exp $
**
**
** This program is free software; you can redistribute it and/or modify
#include <string.h>
#include <stdarg.h>
-#undef SHELL
-
#define TRUE 1
#define FALSE 0
#define OK TRUE
/*----------------------------------------------------------------------*/
-#define SHOW(var, fmt) fprintf (stderr, "var = fmt\n", var)
+#define SHOW(var, fmt) { cerr << "var = " << var << endl; }
/*----------------------------------------------------------------------*/
#define TAB '\t'
#define EOS '\0'
#define BLANK ' '
-#define ETX 26 /* end of text signal for PC-DOS */
-
-/*----------------------------------------------------------------------*/
-
-#define MAXPATHNAME 65 /* max length of pathname + 1 */
-#define MAXFILENAME 13 /* rootname(8) + '.'(1) + extension(3) + EOS */
-#define MAXROOTNAME 8
-#define MAXEXTNAME 3
-#define MAXFULLNAME MAXPATHNAME + MAXFILENAME
-
-/*----------------------------------------------------------------------*/
-
-#define ABS(x) ((x) < 0 ? -(x) : (x))
-#define SQR(x) ((x) * (x))
-
-#define ISWAP(a,b) {int i; i = a; a = b; b = i;}
-
-#define CLIP(n,lb,ub) if (n < lb) n = lb; else if (n > ub) n = ub
-#define STR_EQUAL(s1,s2) (strcmp (s1, s2) == 0)
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
-/* codes for input (inp_*) routines */
-
-#define INP_ERROR -1
-#define INP_NO FALSE
-#define INP_YES TRUE
-#define INP_NEITHER 'b'
-#define INP_RETURN 'r'
-#define INP_BREAK 0x8000
-
#ifndef O_BINARY
#define O_BINARY (0)
#endif
typedef double kfloat64;
#endif
+
/* filefuncs.cpp */
bool file_exists(const char* fname);
const char* fileBasename(const char* filename);
char *td_month_name(int n);
char *td_day_name(int n);
-/* netorder.cpp */
-void *strreverse (void *dest, const void *src, size_t n);
-int read_nint16 (kuint16 *n, int fd);
-int write_nint16 (kuint16 const *n, int fd);
-int read_nint32 (kuint32 *n, int fd);
-int write_nint32 (kuint32 const *n, int fd);
-int read_nfloat32 (float *f, int fd);
-int write_nfloat32 (float const *f, int fd);
-int read_nfloat64 (double *d, int fd);
-int write_nfloat64 (double const *d, int fd);
-void ConvertNetworkOrder (void* buffer, size_t bytes);
-void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
-
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.h,v 1.8 2000/06/13 16:20:31 kevin Exp $
+** $Id: sgp.h,v 1.9 2000/06/15 19:07:10 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
#if HAVE_G2_H
+extern "C" {
#include "g2.h"
#include "g2_X11.h"
+}
#endif
/* device names */
--- /dev/null
+#ifndef __CM_SSTREAM__
+#define __CM_SSTREAM__
+
+#include <string>
+#include <cstdio>
+#include <strstream>
+#include <algorithm>
+
+namespace std {
+
+class ostringstream
+{
+public:
+ ostringstream (const string & str = "")
+ : buffer(str) {}
+
+ const string & str() const
+ {
+ return buffer;
+ }
+
+ void str (const string & new_string)
+ {
+ buffer = new_string;
+ }
+
+ ostringstream & operator<< (const string & item)
+ {
+ buffer += item;
+
+ return *this;
+ }
+
+ ostringstream & operator<< (int item)
+ {
+ char temp[100];
+
+ sprintf (temp, "%d", item);
+ buffer += temp;
+
+ return *this;
+ }
+
+ ostringstream & operator<< (unsigned int item)
+ {
+ char temp[100];
+
+ sprintf (temp, "%u", item);
+ buffer += temp;
+
+ return *this;
+ }
+
+ ostringstream & operator<< (char item)
+ {
+ buffer += item;
+ return *this;
+ }
+
+ ostringstream & operator<< (double item)
+ {
+ char temp[1000];
+
+ sprintf (temp, "%g", item);
+ buffer += temp;
+
+ return *this;
+ }
+
+private:
+ string buffer;
+};
+
+
+
+class istringstream
+{
+ friend istringstream & getline (istringstream &, string &, char = '\n');
+
+public:
+ istringstream (const string & str = "")
+ : buffer (str.c_str(), str.length()) {}
+
+ template <class T>
+ istringstream & operator>> (T & item)
+ {
+ buffer >> item;
+ return *this;
+ }
+
+ operator void * () const
+ {
+ return (void *) buffer;
+ }
+
+private:
+ istrstream buffer;
+};
+
+
+inline istringstream & getline (istringstream & src_stream, string & str, char separator)
+{
+ getline (src_stream.buffer, str, separator);
+ return src_stream;
+}
+
+} // End of namespace std
+
+#endif
+
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctrec.cpp,v 1.8 2000/06/13 16:20:31 kevin Exp $
+** $Id: ctrec.cpp,v 1.9 2000/06/15 19:07:10 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
ImageFile *imGlobal = NULL;
RAYSUM *rsGlobal = NULL;
char *rs_name, *im_filename = NULL;
- char remark[MAXREMARK];
+ string remark;
char filt_name[80];
char *endptr;
int opt_verbose = 0;
else
snprintf (filt_name, sizeof(filt_name), "%s", name_of_filter (opt_filter));
- snprintf (remark, sizeof(remark), "Reconstruct: %dx%d, %s, %s, %s",
- nx, ny, filt_name, name_of_interpolation (opt_interp), name_of_backproj(opt_backproj));
+ ostringstream label;
+ label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
+ remark = label.str();
if (opt_verbose)
cout << "Remark: " << remark << endl;
raysum_close (rsGlobal);
double calctime = timerProgram.timerEnd();
imGlobal->arrayDataWrite ();
- imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, rsGlobal->remark, rsGlobal->calctime);
- imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark, calctime);
+ imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, rsGlobal->remark.c_str(), rsGlobal->calctime);
+ imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark.c_str(), calctime);
imGlobal->fileClose ();
if (opt_verbose)
cout << "Run time: " << calctime << " seconds" << endl;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2if.cpp,v 1.8 2000/06/13 16:20:31 kevin Exp $
+** $Id: phm2if.cpp,v 1.9 2000/06/15 19:07:10 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
phm2if_main (int argc, char* argv[])
{
ImageFile* imGlobal = NULL;
- PHANTOM *phm = NULL;
+ Phantom phm;
int opt_nx = 0, opt_ny = 0;
int opt_nsample = 1;
int opt_phmnum = -1;
break;
case O_PHMFILE:
strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
- phm = phm_create_from_file(opt_phmfilename);
+ phm.createFromFile(opt_phmfilename);
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0)
cerr << "Can't use phantom from file in MPI mode" << endl;
}
}
- if (phm == NULL && opt_phmnum == -1 && opt_filter == -1) {
+ if (phm.nPElem() == 0 && opt_phmnum == -1 && opt_filter == -1) {
cerr << "No phantom defined" << endl;
phm2if_usage(argv[0]);
return (1);
#endif
if (opt_phmnum >= 0)
- phm = phm_create (opt_phmnum);
+ phm.create (opt_phmnum);
#ifdef HAVE_MPI
else {
if (mpiWorld.getRank() == 0)
v = imGlobal->getArray ();
- if (phm->type == P_UNIT_PULSE) {
+ if (phm.getComposition() == P_UNIT_PULSE) {
if (mpiWorld.getRank() == 0) {
v[opt_nx/2][opt_ny/2] = 1.;
}
}
#else
v = imGlobal->getArray ();
- if (phm->type == P_UNIT_PULSE) {
+ if (phm.getComposition() == P_UNIT_PULSE) {
v[opt_nx/2][opt_ny/2] = 1.;
} else if (opt_filter != -1) {
image_filter_response (*imGlobal, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
} else {
#if HAVE_SGP
if (opt_trace >= TRACE_PHM)
- phm_show(phm);
+ phm.show();
#endif
phm_to_imagefile (phm, *imGlobal, 0, opt_nx, opt_nsample, opt_trace);
}
}
}
- phm_free (phm);
-
return (0);
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2rs.cpp,v 1.5 2000/06/13 16:20:31 kevin Exp $
+** $Id: phm2rs.cpp,v 1.6 2000/06/15 19:07:10 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
phm2rs_main (int argc, char* argv[])
{
- DETECTOR *det;
- PHANTOM *phm = NULL;
+ Detector *det;
+ Phantom phm;
RAYSUM *rsGlobal = NULL;
char *opt_outfile = NULL;
- char opt_desc[MAXREMARK+1];
- char opt_phmfilename[256];
+ string opt_desc;
+ string opt_phmfilename;
char *endptr, *endstr;
int opt_ndet, opt_nview;
int opt_nray = 1;
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0) {
#endif
- strcpy(opt_desc, "");
- strcpy(opt_phmfilename, "");
while (1) {
int c = getopt_long(argc, argv, "", phm2rs_options, NULL);
char *endptr = NULL;
phm2rs_usage(argv[0]);
return (1);
}
- phm = phm_create (opt_phmnum);
+ phm.create (opt_phmnum);
break;
case O_PHMFILE:
#ifdef HAVE_MPI
cerr << "Can not read phantom from file in MPI mode" << endl;
return (1);
#endif
- strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
- phm = phm_create_from_file(opt_phmfilename);
+ opt_phmfilename = optarg;
+ phm.createFromFile (opt_phmfilename.c_str());
break;
case O_VERBOSE:
opt_verbose = 1;
}
break;
case O_DESC:
- strncpy(opt_desc, optarg, sizeof(opt_desc));
+ opt_desc = optarg;
break;
case O_ROTANGLE:
opt_rotangle = strtod(optarg, &endptr);
}
}
- if (phm == NULL) {
+ if (phm.nPElem() == 0) {
cerr << "No phantom defined" << endl;
phm2rs_usage(argv[0]);
return (1);
return (1);
}
- char str[256];
- snprintf(str, sizeof(str),
- "Raysum_Collect: NDet=%d, Nview=%d, NRay=%d, RotAngle=%.2f, ",
- opt_ndet, opt_nview, opt_nray, opt_rotangle);
- if (opt_phmfilename[0]) {
- strncat(str, "Phantom=", sizeof(str));
- strncat(str, opt_phmfilename, sizeof(str));
+ ostringstream desc;
+ desc << "Raysum_Collect: NDet=" << opt_ndet << ", Nview=" << opt_nview << ", NRay=" << opt_nray << ", RotAngle=" << opt_rotangle << ", ";
+ if (opt_phmfilename.length()) {
+ desc << "PhantomFile=" << opt_phmfilename;
} else if (opt_phmnum != -1) {
- strncat(str, "Phantom=", sizeof(str));
- strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
+ desc << "Phantom=" << name_of_phantom(opt_phmnum);
}
- if (opt_desc[0]) {
- strncat(str, ": ", sizeof(str));
- strncat(str, opt_desc, sizeof(str));
+ if (opt_desc.length()) {
+ desc << ": " << opt_desc;
}
- strncpy(opt_desc, str, sizeof(opt_desc));
+ opt_desc = desc.str();
#ifdef HAVE_MPI
}
#endif
mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0);
if (mpiWorld.getRank() > 0 && opt_phmnum >= 0)
- phm = phm_create (opt_phmnum);
+ phm.create (opt_phmnum);
#endif
opt_rotangle *= PI;
- det = detector_create (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
+ det = new Detector (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
#ifdef HAVE_MPI
mpiWorld.setTotalWorkUnits (opt_nview);
if (mpiWorld.getRank() == 0) {
- rsGlobal = raysum_create_from_det (opt_outfile, det);
+ rsGlobal = raysum_create_from_det (opt_outfile, *det);
raysum_alloc_views(rsGlobal);
}
- rsLocal = raysum_create_from_det (NULL, det);
+ rsLocal = raysum_create_from_det (NULL, *det);
rsLocal->nview = mpiWorld.getMyLocalWorkUnits();
if (opt_debug)
cout << "rsLocal->nview = " << rsLocal->nview << " (process " << mpiWorld.getRank() << ")" << endl;;
TimerMPI timerProject (mpiWorld.getComm());
- raysum_collect (rsLocal, det, phm, mpiWorld.getMyStartWorkUnit(), opt_trace, FALSE);
+ raysum_collect (rsLocal, *det, phm, mpiWorld.getMyStartWorkUnit(), opt_trace, FALSE);
if (opt_verbose)
timerProject.timerEndAndReport ("Time to collect projections");
if (opt_verbose)
timerGather.timerEndAndReport ("Time to gather projections");
#else
- rsGlobal = raysum_create_from_det (opt_outfile, det);
- raysum_collect (rsGlobal, det, phm, 0, opt_trace, FALSE);
+ rsGlobal = raysum_create_from_det (opt_outfile, *det);
+ raysum_collect (rsGlobal, *det, phm, 0, opt_trace, FALSE);
#endif
#ifdef HAVE_MPI
#endif
{
rsGlobal->calctime = timerProgram.timerEnd();
- strncpy (rsGlobal->remark, opt_desc, sizeof(rsGlobal->remark));
+ rsGlobal->remark = opt_desc;
raysum_write (rsGlobal);
raysum_close (rsGlobal);
if (opt_verbose) {
}
}
- phm_free (phm);
- detector_free (det);
+ delete det;
return (0);
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: rs2if.cpp,v 1.5 2000/06/13 16:20:31 kevin Exp $
+** $Id: rs2if.cpp,v 1.6 2000/06/15 19:07:10 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
{
printf ("Number of detectors: %d\n", rs->ndet);
printf (" Number of views: %d\n", rs->nview);
- printf (" Remark: %s\n", rs->remark);
+ printf (" Remark: %s\n", rs->remark.c_str());
}
im = new ImageFile (im_name, rs->ndet, rs->nview);
im->fileCreate ();
im->arrayDataWrite ();
- im->labelAdd (Array2dFileLabel::L_HISTORY, rs->remark, rs->calctime);
+ im->labelAdd (Array2dFileLabel::L_HISTORY, rs->remark.c_str(), rs->calctime);
im->labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .rs to .idf");
im->fileClose ();