#ifndef NETORDER_H
#define NETORDER_H
+#include <iostream>
+
/* netorder.cpp */
-void *strreverse (void *dest, const void *src, size_t n);
bool read_nint16 (kuint16 *n, int fd);
bool write_nint16 (kuint16 const *n, int fd);
bool read_nint32 (kuint32 *n, int fd);
bool write_nfloat32 (float const *f, int fd);
bool read_nfloat64 (double *d, int fd);
bool write_nfloat64 (double const *d, int fd);
-void ConvertNetworkOrder (void* buffer, size_t bytes);
-void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+void ConvertNetworkOrder (void* buffer, size_t bytes);
+void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+
+class inetorderstream : public istream {
+ public:
+ inetorderstream& readInt16 (kuint16& n);
+ inetorderstream& readInt32 (kuint32& n);
+ inetorderstream& readFloat32 (kfloat32& n);
+ inetorderstream& readFloat64 (kfloat64& n);
+};
+
+class onetorderstream : public ostream {
+ public:
+ onetorderstream& writeInt16 (kuint16 n);
+ onetorderstream& writeInt32 (kuint32 n);
+ onetorderstream& writeFloat32 (kfloat32 n);
+ onetorderstream& writeFloat64 (kfloat64 n);
+};
+
+void read_rnint16 (kuint16& n, istream istr);
+void write_rnint16 (kuint16 n, ostream ostr);
+void read_rnint32 (kuint32& n, istream istr);
+void write_rnint32 (kuint32 n, ostream ostr);
+void read_rnfloat32 (kfloat32& n, istream istr);
+void write_rnfloat32 (kfloat32 n, ostream ostr);
+void read_rnfloat64 (kfloat64& n, istream istr);
+void write_rnfloat64 (kfloat64 n, ostream ostr);
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ct.h,v 1.15 2000/06/17 20:12:14 kevin Exp $
+** $Id: ct.h,v 1.16 2000/06/18 10:27: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
#include "sgp.h"
#endif
+#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.h,v 1.5 2000/06/13 16:20:31 kevin Exp $
+** $Id: ezplot.h,v 1.6 2000/06/18 10:27: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
};
#define XBUF_DEF 600
-#define YBUF_DEF XBUF_DEF * (72. / 120.) * 0.75
+#define YBUF_DEF 600
#define PRTMODE_DEF 1
/*----------------------------------------------------------------------*/
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: kmath.h,v 1.14 2000/06/17 20:12:14 kevin Exp $
+** $Id: kmath.h,v 1.15 2000/06/18 10:27: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
inline T lineLength (T x1, T y1, T x2, T y2)
{ return static_cast<T>( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); }
+template<class T>
+inline void minmax_array (const T* array, const int n, T& min, T& max)
+{
+ max = min = array[0];
+
+ for (int i = 1; i < n; i++)
+ if (array[i] < min)
+ min = array[i];
+ else if (array[i] > max)
+ max = array[i];
+}
+
/* clip.cpp */
int 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);
/* simpson.cpp */
double simpson(const double xmin, const double xmax, const double *y, const int np);
-/* minmax.cpp */
-void minmax_dvector(const double array[], const int pts, double *xmin, double *xmax);
-
-
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctrec.cpp,v 1.10 2000/06/17 20:12:15 kevin Exp $
+** $Id: ctrec.cpp,v 1.11 2000/06/18 10:27: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
Projections projGlobal;
char *pj_name, *im_filename = NULL;
string remark;
- char filt_name[80];
char *endptr;
int opt_verbose = 0;
int opt_debug = 0;
nx = strtol(argv[optind + 2], &endptr, 10);
ny = strtol(argv[optind + 3], &endptr, 10);
+ ostringstream filt_name;
if (opt_filter == FILTER_G_HAMMING || opt_filter == FILTER_ABS_G_HAMMING)
- snprintf (filt_name, sizeof(filt_name), "%s: alpha = %.2f",
- name_of_filter (opt_filter), opt_filter_param);
+ filt_name << name_of_filter (opt_filter) << ": alpha=" << opt_filter_param;
else
- snprintf (filt_name, sizeof(filt_name), "%s", name_of_filter (opt_filter));
+ filt_name << name_of_filter (opt_filter);
ostringstream label;
- label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
+ label << "Reconstruct: " << nx << "x" << ny << ", " << filt_name.str() << ", " << name_of_interpolation (opt_interp) << ", " << name_of_backproj(opt_backproj);
remark = label.str();
if (opt_verbose)
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if-1.cpp,v 1.6 2000/06/13 16:20:31 kevin Exp $
+** $Id: if-1.cpp,v 1.7 2000/06/18 10:27: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
void
if1_usage (const char *program)
{
- fprintf(stdout, "if1_usage: %s infile outfile [OPTIONS]\n", fileBasename(program));
- fprintf(stdout, "Generate a IF file from a IF file\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " --invert Invert image\n");
- fprintf(stdout, " --log Natural logrithm of image\n");
- fprintf(stdout, " --exp Natural exponential of image\n");
- fprintf(stdout, " --sqr Square of image\n");
- fprintf(stdout, " --sqrt Square root of image\n");
- fprintf(stdout, " --verbose Verbose modem\n");
- fprintf(stdout, " --version Print version\n");
- fprintf(stdout, " --help Print this help message\n");
+ cout << "usage: " << fileBasename(program) << " infile outfile [OPTIONS]" << endl;
+ cout << "Generate a IF file from a IF file" << endl;
+ cout << endl;
+ cout << " --invert Invert image" << endl;
+ cout << " --log Natural logrithm of image" << endl;
+ cout << " --exp Natural exponential of image" << endl;
+ cout << " --sqr Square of image" << endl;
+ cout << " --sqrt Square root of image" << endl;
+ cout << " --verbose Verbose modem" << endl;
+ cout << " --version Print version" << endl;
+ cout << " --help Print this help message" << endl;
}
int
break;
case O_VERSION:
#ifdef VERSION
- fprintf(stdout, "Version %s\n", VERSION);
+ cout << "Version " << VERSION << endl;
#else
- fprintf(stderr, "Unknown version number");
+ cout << "Unknown version number" << endl;
#endif
- exit(0);
+ return (0);
case O_HELP:
case '?':
if1_usage(argv[0]);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if-2.cpp,v 1.4 2000/06/13 16:20:31 kevin Exp $
+** $Id: if-2.cpp,v 1.5 2000/06/18 10:27: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
******************************************************************************/
/* FILE
- * sdf-2.c Generate a SDF file from two input SDF files
+ * if-2.c Generate a IF file from two input IF files
*/
#include "ct.h"
};
void
-sdf2_usage (const char *program)
+if2_usage (const char *program)
{
- fprintf(stdout, "sdf2_usage: %s infile1 infile2 outfile [OPTIONS]\n", fileBasename(program));
- fprintf(stdout, "Generate an SDF2D file from two input SDF2D files\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " infile1 Name of first input SDF file\n");
- fprintf(stdout, " infile2 Name of second input SDF file\n");
- fprintf(stdout, " outfile Name of output SDF file\n");
- fprintf(stdout, " --add Add images\n");
- fprintf(stdout, " --sub Subtract image 2 from image 1\n");
- fprintf(stdout, " --mul Multiply images\n");
- fprintf(stdout, " --comp Compare images\n");
- fprintf(stdout, " --verbose Verbose modem\n");
- fprintf(stdout, " --version Print version\n");
- fprintf(stdout, " --help Print this help message\n");
+ cout << "usage: " << fileBasename(program) << " infile1 infile2 outfile [OPTIONS]" << endl;
+ cout << "Generate an image file from two input image files files" << endl;
+ cout << endl;
+ cout << " infile1 Name of first input IF file" << endl;
+ cout << " infile2 Name of second input IF file" << endl;
+ cout << " outfile Name of output IF file" << endl;
+ cout << " --add Add images" << endl;
+ cout << " --sub Subtract image 2 from image 1" << endl;
+ cout << " --mul Multiply images" << endl;
+ cout << " --comp Compare images" << endl;
+ cout << " --verbose Verbose modem" << endl;
+ cout << " --version Print version" << endl;
+ cout << " --help Print this help message" << endl;
}
int
-sdf2_main (int argc, char *const argv[])
+if2_main (int argc, char *const argv[])
{
ImageFile* pim_in1;
ImageFile* pim_in2;
break;
case O_VERSION:
#ifdef VERSION
- fprintf(stdout, "Version %s\n", VERSION);
+ cout << "Version " << VERSION << endl;
#else
- fprintf(stderr, "Unknown version number");
+ cout << "Unknown version number" << endl;
#endif
- exit(0);
+ return (0);
case O_HELP:
case '?':
- sdf2_usage(argv[0]);
+ if2_usage(argv[0]);
return (0);
default:
- sdf2_usage(argv[0]);
+ if2_usage(argv[0]);
return (1);
}
}
if (optind + 3 != argc) {
- sdf2_usage(argv[0]);
+ if2_usage(argv[0]);
return (1);
}
}
if (im_in1.nx() != im_in2.nx() || im_in1.ny() != im_in2.ny()) {
- fprintf(stderr, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match\n",
+ sys_error (ERR_SEVERE, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match",
im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
return(1);
}
if (im_in1.nx() < 0 || im_in1.ny() < 0) {
- fprintf(stderr, "Error: Size of image < 0");
+ sys_error (ERR_SEVERE, "Error: Size of image < 0");
return(1);
}
}
}
abs_error /= (im_in1.nx() * im_in1.ny());
- fprintf(stdout, "Average Error = %f\n", abs_error);
+ cout << "Average Error: " << abs_error << endl;
}
im_out.arrayDataWrite();
int
main (int argc, char *const argv[])
{
- return (sdf2_main(argc, argv));
+ return (if2_main(argc, argv));
}
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if2img.cpp,v 1.5 2000/06/17 20:12:15 kevin Exp $
+** $Id: if2img.cpp,v 1.6 2000/06/18 10:27: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
void
if2img_usage (const char *program)
{
- fprintf(stdout, "usage: %s sdfname outfile [OPTIONS]\n", fileBasename(program));
- fprintf(stdout, "Convert IF file to an image file\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " sdfname Name of input SDF file\n");
- fprintf(stdout, " outfile Name of output file\n");
- fprintf(stdout, " --format Output format\n");
- fprintf(stdout, " pgm PGM (portable graymap) format (default)\n");
- fprintf(stdout, " pgmasc PGM (portable graymap) ASCII format\n");
+ cout << "usage: " << fileBasename(program) << " ifname outfile [OPTIONS]" << endl;
+ cout << "Convert IF file to an image file" << endl;
+ cout << endl;
+ cout << " sdfname Name of input SDF file" << endl;
+ cout << " outfile Name of output file" << endl;
+ cout << " --format Output format" << endl;
+ cout << " pgm PGM (portable graymap) format (default)" << endl;
+ cout << " pgmasc PGM (portable graymap) ASCII format" << endl;
#ifdef HAVE_PNG
- fprintf(stdout, " png PNG (8-bit) format\n");
- fprintf(stdout, " png16 PNG (16-bit) format\n");
+ cout << " png PNG (8-bit) format" << endl;
+ cout << " png16 PNG (16-bit) format" << endl;
#endif
#ifdef HAVE_GIF
- fprintf(stdout, " gif GIF format\n");
+ cout << " gif GIF format" << endl;
#endif
- fprintf(stdout, " disp Display on screen\n");
- fprintf(stdout, " --center Center of window\n");
- fprintf(stdout, " mode Mode is center of window (default)\n");
- fprintf(stdout, " mean Mean is center of window\n");
- fprintf(stdout, " --auto Set auto window\n");
- fprintf(stdout, " full Use full window (default)\n");
- fprintf(stdout, " std0.1 Use 0.1 standard deviation about center\n");
- fprintf(stdout, " std0.5 Use 0.5 standard deviation about center\n");
- fprintf(stdout, " std1 Use one standard deviation about center\n");
- fprintf(stdout, " std2 Use two standard deviations about center\n");
- fprintf(stdout, " std3 Use three standard deviations about center\n");
- fprintf(stdout, " --scale Scaling factor for output size\n");
- fprintf(stdout, " --min Set minimum intensity\n");
- fprintf(stdout, " --max Set maximum intensity\n");
- fprintf(stdout, " --stats Print image statistics\n");
- fprintf(stdout, " --labels Print image labels\n");
- fprintf(stdout, " --debug Set debug mode\n");
- fprintf(stdout, " --verbose Set verbose mode\n");
- fprintf(stdout, " --version Print version\n");
- fprintf(stdout, " --help Print this help message\n");
+ cout << " disp Display on screen" << endl;
+ cout << " --center Center of window" << endl;
+ cout << " mode Mode is center of window (default)" << endl;
+ cout << " mean Mean is center of window" << endl;
+ cout << " --auto Set auto window" << endl;
+ cout << " full Use full window (default)" << endl;
+ cout << " std0.1 Use 0.1 standard deviation about center" << endl;
+ cout << " std0.5 Use 0.5 standard deviation about center" << endl;
+ cout << " std1 Use one standard deviation about center" << endl;
+ cout << " std2 Use two standard deviations about center" << endl;
+ cout << " std3 Use three standard deviations about center" << endl;
+ cout << " --scale Scaling factor for output size" << endl;
+ cout << " --min Set minimum intensity" << endl;
+ cout << " --max Set maximum intensity" << endl;
+ cout << " --stats Print image statistics" << endl;
+ cout << " --labels Print image labels" << endl;
+ cout << " --debug Set debug mode" << endl;
+ cout << " --verbose Set verbose mode" << endl;
+ cout << " --version Print version" << endl;
+ cout << " --help Print this help message" << endl;
}
endstr = optarg + strlen(optarg);
if (endptr != endstr)
{
- fprintf(stderr, "Error setting --min to %s\n", optarg);
+ sys_error (ERR_SEVERE, "Error setting --min to %s", optarg);
if2img_usage(argv[0]);
return (1);
}
endstr = optarg + strlen(optarg);
if (endptr != endstr)
{
- fprintf(stderr, "Error setting --max to %s\n", optarg);
+ sys_error (ERR_SEVERE, "Error setting --max to %s", optarg);
if2img_usage(argv[0]);
return (1);
}
endstr = optarg + strlen(optarg);
if (endptr != endstr)
{
- fprintf(stderr,"Error setting --scale to %s\n", optarg);
+ sys_error (ERR_SEVERE, "Error setting --scale to %s", optarg);
if2img_usage(argv[0]);
return (1);
}
opt_auto = O_AUTO_STD3;
else
{
- fprintf(stderr, "Invalid auto mode %s\n", optarg);
+ sys_error (ERR_SEVERE, "Invalid auto mode %s", optarg);
if2img_usage(argv[0]);
return (1);
}
opt_center = O_CENTER_MODE;
else
{
- fprintf(stderr, "Invalid center mode %s\n", optarg);
+ sys_error (ERR_SEVERE, "Invalid center mode %s", optarg);
if2img_usage(argv[0]);
return (1);
}
- break;
+ break;
case O_FORMAT:
if (strcmp(optarg, O_FORMAT_PGM_STR) == 0)
opt_format = O_FORMAT_PGM;
else if (strcmp(optarg, O_FORMAT_DISP_STR) == 0)
opt_format = O_FORMAT_DISP;
else {
- fprintf(stderr, "Invalid format mode %s\n", optarg);
+ sys_error (ERR_SEVERE, "Invalid format mode %s", optarg);
if2img_usage(argv[0]);
return (1);
}
break;
case O_VERSION:
#ifdef VERSION
- fprintf(stdout, "Version %s\n", VERSION);
+ cout << "Version " << VERSION;
#else
- fprintf(stderr, "Unknown version number");
+ cout << "Unknown version number" << endl;
#endif
exit(0);
case O_HELP:
pim = new ImageFile (in_file);
ImageFile& im = *pim;
if (! im.fileRead()) {
- fprintf(stderr, "File %s does not exist\n", in_file);
+ sys_error (ERR_SEVERE, "File %s does not exist", in_file);
return (1);
}
else if (opt_auto == O_AUTO_STD3)
window = stddev * 3;
else {
- fprintf(stderr, "Internal Error: Invalid auto mode %d\n", opt_auto);
+ sys_error (ERR_SEVERE, "Internal Error: Invalid auto mode %d", opt_auto);
return (1);
}
}
if (opt_stats) {
- fprintf(stdout,"nx=%d\n", nx);
- fprintf(stdout,"ny=%d\n", ny);
- fprintf(stdout,"min=%f\n", minfound);
- fprintf(stdout,"max=%f\n", maxfound);
- fprintf(stdout,"mean=%f\n", mean);
- fprintf(stdout,"mode=%f\n", mode);
- fprintf(stdout,"stddev=%f\n", stddev);
+ cout <<"nx: " << nx << endl;
+ cout <<"ny: " << ny << endl;
+ cout <<"min: " << minfound << endl;
+ cout <<"max: " << maxfound << endl;
+ cout <<"mean: " << mean << endl;
+ cout <<"mode: " << mode << endl;
+ cout <<"stddev: " << stddev << endl;
}
if (opt_auto != O_AUTO_FULL) {
double center;
else if (opt_center == O_CENTER_MEAN)
center = mean;
else {
- fprintf(stderr, "Internal Error: Invalid center mode %d\n", opt_center);
+ sys_error (ERR_SEVERE, "Internal Error: Invalid center mode %d", opt_center);
return (1);
}
if (! opt_set_max)
}
if (opt_stats) {
- fprintf(stdout,"min_disp=%f\n", densmin);
- fprintf(stdout,"max_disp=%f\n", densmax);
+ cout << "min display: " << densmin << endl;
+ cout << "max display: " << densmax << endl;
}
if (opt_format == O_FORMAT_PGM)
}
else
{
- fprintf(stderr, "Internal Error: Invalid format mode %d\n", opt_format);
+ sys_error (ERR_SEVERE, "Internal Error: Invalid format mode %d", opt_format);
return (1);
}
return (0);
delete rowp;
if ((out = fopen(outfile,"w")) == NULL) {
- fprintf(stderr,"Error opening output file %s for writing\n", outfile);
+ sys_error(ERR_SEVERE,"Error opening output file %s for writing", outfile);
exit(1);
}
gdImageGif(gif,out);
fclose(out);
gdImageDestroy(gif);
#else
- fprintf(stderr, "This version does not support GIF");
+ cout << "This version does not support GIF" << endl;
#endif
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ifinfo.cpp,v 1.7 2000/06/17 20:12:15 kevin Exp $
+** $Id: ifinfo.cpp,v 1.8 2000/06/18 10:27: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
void
ifinfo_usage (const char *program)
{
- fprintf(stdout, "usage: %s infile [OPTIONS]\n", fileBasename(program));
- fprintf(stdout, "Imagefile information\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " infile Name of input SDF file\n");
- fprintf(stdout, " --display Display image\n");
- fprintf(stdout, " --labels Print image labels (default)\n");
- fprintf(stdout, " --no-labels Do not print image labels\n");
- fprintf(stdout, " --stats Print image statistics (default)\n");
- fprintf(stdout, " --no-stats Do not print image statistics\n");
- fprintf(stdout, " --debug Debug mode\n");
- fprintf(stdout, " --verbose Verbose mode\n");
- fprintf(stdout, " --version Print version\n");
- fprintf(stdout, " --help Print this help message\n");
+ cout << "usage: " << fileBasename(program) << " infile [OPTIONS]" << endl;
+ cout << "Imagefile information" << endl;
+ cout << endl;
+ cout << " infile Name of input IF file" << endl;
+ cout << " --display Display image" << endl;
+ cout << " --labels Print image labels (default)" << endl;
+ cout << " --no-labels Do not print image labels" << endl;
+ cout << " --stats Print image statistics (default)" << endl;
+ cout << " --no-stats Do not print image statistics" << endl;
+ cout << " --debug Debug mode" << endl;
+ cout << " --verbose Verbose mode" << endl;
+ cout << " --version Print version" << endl;
+ cout << " --help Print this help message" << endl;
}
int
break;
case O_VERSION:
#ifdef VERSION
- fprintf(stdout, "Version %s\n", VERSION);
+ cout << "Version " << VERSION << endl;
#else
- fprintf(stderr, "Unknown version number");
+ cout << "Unknown version number" << endl;
#endif
- exit(0);
+ return (0);
case O_HELP:
case '?':
ifinfo_usage(argv[0]);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2if.cpp,v 1.9 2000/06/15 19:07:10 kevin Exp $
+** $Id: phm2if.cpp,v 1.10 2000/06/18 10:27: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
DomainType opt_filter_domain = D_SPATIAL;
char *opt_outfile = NULL;
int opt_debug = 0;
- char str[256];
- char opt_desc[256], opt_phmfilename[256];
+ string opt_desc;
+ string opt_phmfilename;
char *endstr, *endptr;
double opt_filter_param = 1;
double opt_filter_bw = 1.;
int opt_trace = TRACE_NONE;
- int opt_verbose = 0;
+ bool opt_verbose = false;
#ifdef HAVE_MPI
ImageFile* imLocal = NULL;
MPIWorld mpiWorld (argc, argv);
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0) {
#endif
- strcpy(opt_desc, "");
- strcpy(opt_phmfilename, "");
while (1) {
int c = getopt_long(argc, argv, "", my_options, NULL);
char *endptr = NULL;
}
break;
case O_PHMFILE:
- strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
- phm.createFromFile(opt_phmfilename);
+ opt_phmfilename = optarg;
+ phm.createFromFile(opt_phmfilename.c_str());
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0)
cerr << "Can't use phantom from file in MPI mode" << endl;
#endif
break;
case O_VERBOSE:
- opt_verbose = 1;
+ opt_verbose = true;
break;
case O_DEBUG:
opt_debug = 1;
}
break;
case O_DESC:
- strncpy(opt_desc, optarg, sizeof(opt_desc));
+ opt_desc = optarg;
break;
case O_FILTER_BW:
opt_filter_bw = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
- fprintf(stderr,"Error setting --filter-bw to %s\n", optarg);
+ sys_error(ERR_SEVERE,"Error setting --filter-bw to %s\n", optarg);
phm2if_usage(argv[0]);
return (1);
}
opt_filter_param = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
- fprintf(stderr,"Error setting --filter-param to %s\n", optarg);
+ sys_error(ERR_SEVERE,"Error setting --filter-param to %s\n", optarg);
phm2if_usage(argv[0]);
return (1);
}
opt_nsample = strtol(optarg, &endptr, 10);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
- fprintf(stderr,"Error setting --nsample to %s\n", optarg);
+ sys_error(ERR_SEVERE,"Error setting --nsample to %s\n", optarg);
phm2if_usage(argv[0]);
return (1);
}
opt_nx = strtol(argv[optind+1], &endptr, 10);
endstr = argv[optind+1] + strlen(argv[optind+1]);
if (endptr != endstr) {
- fprintf(stderr,"Error setting nx to %s\n", argv[optind+1]);
+ sys_error(ERR_SEVERE,"Error setting nx to %s\n", argv[optind+1]);
phm2if_usage(argv[0]);
return (1);
}
opt_ny = strtol(argv[optind+2], &endptr, 10);
endstr = argv[optind+2] + strlen(argv[optind+2]);
if (endptr != endstr) {
- fprintf(stderr,"Error setting ny to %s\n", argv[optind+2]);
+ sys_error(ERR_SEVERE,"Error setting ny to %s\n", argv[optind+2]);
phm2if_usage(argv[0]);
return (1);
}
- snprintf(str, sizeof(str), "nx=%d, ny=%d, nsample=%d, ", opt_nx, opt_ny, opt_nsample);
- if (opt_phmfilename[0]) {
- strncat(str, "phantom=", sizeof(str));
- strncat(str, opt_phmfilename, sizeof(str));
- }
- else if (opt_phmnum != -1) {
- strncat(str, "phantom=", sizeof(str));
- strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
- }
+ ostringstream oss;
+ oss << "nx=" << opt_nx << ", ny=" << opt_ny << ", nsample=" << opt_nsample << ", ";
+ if (opt_phmfilename.length())
+ oss << "phantom=" << opt_phmfilename;
+ else if (opt_phmnum != -1)
+ oss << "phantom=" << name_of_phantom(opt_phmnum);
else if (opt_filter != -1) {
- strncat(str, "filter=", sizeof(str));
- strncat(str, name_of_filter(opt_filter), sizeof(str));
- strncat(str, " - ", sizeof(str));
- strncat(str, name_of_filter_domain(opt_filter_domain), sizeof(str));
- }
- if (opt_desc[0]) {
- strncat(str, ": ", sizeof(str));
- strncat(str, opt_desc, sizeof(str));
+ oss << "filter=" << name_of_filter(opt_filter);
+ oss << " - " << name_of_filter_domain(opt_filter_domain);
}
- strncpy(opt_desc, str, sizeof(opt_desc));
+ if (opt_desc.length())
+ oss << ": " << opt_desc;
+ opt_desc = oss.str();
if (opt_verbose)
cout << "Rasterize Phantom to Image" << endl << endl;
{
imGlobal->arrayDataWrite ();
double calctime = timerProgram.timerEnd ();
- imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc, calctime);
+ imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
imGlobal->fileClose ();
if (opt_verbose)
cout << "Time to rasterized phantom: " << calctime << " seconds" << endl;
/*****************************************************************************
** FILE IDENTIFICATION
**
-** Name: proj2if.cpp
+** Name: pj2if.cpp
** Purpose: Convert an projection data file to an image file
** Programmer: Kevin Rosenberg
** Date Started: April 2000
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: pj2if.cpp,v 1.1 2000/06/17 20:12:15 kevin Exp $
+** $Id: pj2if.cpp,v 1.2 2000/06/18 10:27: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
******************************************************************************/
/* FILE
- * proj2if.c Convert Raysum to image
+ * pj2if.c Convert Raysum to image
*
* DATE
* Apr 1999
void
-proj2if_usage (const char *program)
+pj2if_usage (const char *program)
{
- fprintf(stdout, "usage: %s in-proj-file out-if-file [OPTIONS]\n", fileBasename(program));
- fprintf(stdout, "This program converts a projection file to a IF file\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " --verbose Verbose mode\n");
- fprintf(stdout, " --version Print version\n");
- fprintf(stdout, " --help Print this help message\n");
+ cout << "usage: " << fileBasename(program) << " in-proj-file out-if-file [OPTIONS]" << endl;
+ cout << "Converts a projection file to a IF file" << endl;
+ cout << endl;
+ cout << " --verbose Verbose mode" << endl;
+ cout << " --version Print version" << endl;
+ cout << " --help Print this help message" << endl;
}
int
-proj2if_main (const int argc, char *const argv[])
+pj2if_main (const int argc, char *const argv[])
{
- char *proj_name, *im_name;
+ char *pj_name, *im_name;
int ix, iy;
bool opt_verbose = false;
extern int optind;
break;
case O_VERSION:
#ifdef VERSION
- fprintf(stdout, "Version %s\n", VERSION);
+ cout << "Version " << VERSION << endl;
#else
- fprintf(stderr, "Unknown version number");
+ cout << "Unknown version number" << endl;
#endif
- exit(0);
+ return (0);
case O_HELP:
case '?':
- proj2if_usage(argv[0]);
+ pj2if_usage(argv[0]);
return (0);
default:
- proj2if_usage(argv[0]);
+ pj2if_usage(argv[0]);
return (1);
}
}
if (argc - optind != 2) {
- proj2if_usage(argv[0]);
+ pj2if_usage(argv[0]);
return (1);
}
- proj_name = argv[optind];
+ pj_name = argv[optind];
im_name = argv[optind + 1];
- Projections proj;
- if (! proj.read (proj_name)) {
- sys_error (ERR_SEVERE, "Can not open projection file %s", proj_name);
+ Projections pj;
+ if (! pj.read (pj_name)) {
+ sys_error (ERR_SEVERE, "Can not open projection file %s", pj_name);
return (1);
}
if (opt_verbose)
- proj.printScanInfo();
+ pj.printScanInfo();
- ImageFile im (im_name, proj.nDet(), proj.nView());
+ ImageFile im (im_name, pj.nDet(), pj.nView());
ImageFileArray v = im.getArray();
- for (iy = 0; iy < proj.nView(); iy++)
+ for (iy = 0; iy < pj.nView(); iy++)
{
- DetectorArray& detarray = proj.getDetectorArray (iy);
+ DetectorArray& detarray = pj.getDetectorArray (iy);
const DetectorValue* detval = detarray.detValues();
- for (ix = 0; ix < proj.nDet(); ix++)
+ for (ix = 0; ix < pj.nDet(); ix++)
{
v[ix][iy] = detval[ix];
}
im.fileCreate ();
im.arrayDataWrite ();
- im.labelAdd (Array2dFileLabel::L_HISTORY, proj.remark(), proj.calcTime());
+ im.labelAdd (Array2dFileLabel::L_HISTORY, pj.remark(), pj.calcTime());
im.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .pj to .if");
im.fileClose ();
int
main (const int argc, char *const argv[])
{
- return (proj2if_main(argc, argv));
+ return (pj2if_main(argc, argv));
}
#endif