** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2if.cpp,v 1.13 2000/06/22 10:17:28 kevin Exp $
+** $Id: phm2if.cpp,v 1.15 2000/06/26 21:15:24 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
Phantom phm;
int opt_nx = 0, opt_ny = 0;
int opt_nsample = 1;
- string optPhmName;
+ string optPhmName = Phantom::PHM_HERMAN_STR;
string optFilterName;
- string optDomainName = "spatial";
+ string optDomainName = SignalFilter::DOMAIN_SPATIAL_STR;
char *opt_outfile = NULL;
int opt_debug = 0;
string opt_desc;
- string opt_phmfilename;
+ string opt_phmFileName;
char *endstr, *endptr;
double opt_filter_param = 1;
double opt_filter_bw = 1.;
switch (c) {
case O_PHANTOM:
optPhmName = optarg;
- if (! phm.createFromPhantom (optPhmName.c_str())) {
- cout << "Invalid phantom name " << optPhmName << endl << endl;
- phm2if_usage(argv[0]);
- return (1);
- }
break;
case O_PHMFILE:
- 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;
- return (1);
-#endif
+ opt_phmFileName = optarg;
break;
case O_VERBOSE:
opt_verbose = true;
}
}
- if (phm.nPElem() == 0 && optPhmName == "" && optFilterName == "") {
- cerr << "No phantom defined" << endl;
+ if (optPhmName == "" && optFilterName == "" && opt_phmFileName == "") {
+ cerr << "No phantom defined" << endl << endl;
phm2if_usage(argv[0]);
return (1);
}
}
ostringstream oss;
- oss << "nx=" << opt_nx << ", ny=" << opt_ny << ", nsample=" << opt_nsample << ", ";
- if (opt_phmfilename.length())
- oss << "phantom=" << opt_phmfilename;
+ oss << "phm2if: nx=" << opt_nx << ", ny=" << opt_ny << ", nsample=" << opt_nsample << ", ";
+ if (opt_phmFileName != "")
+ oss << "phantom=" << opt_phmFileName;
else if (optPhmName != "")
oss << "phantom=" << optPhmName;
else if (optFilterName != "") {
oss << "filter=" << optFilterName << " - " << optDomainName;
}
- if (opt_desc.length())
+ if (opt_desc != "")
oss << ": " << opt_desc;
opt_desc = oss.str();
+ if (optPhmName != "") {
+ phm.createFromPhantom (optPhmName.c_str());
+ if (phm.fail()) {
+ cout << phm.failMessage() << endl << endl;
+ phm2if_usage(argv[0]);
+ return (1);
+ }
+ }
+
+ if (opt_phmFileName != "") {
+ phm.createFromFile(opt_phmFileName.c_str());
+#ifdef HAVE_MPI
+ if (mpiWorld.getRank() == 0)
+ cerr << "Can't use phantom from file in MPI mode" << endl;
+ return (1);
+#endif
+ }
+
if (opt_verbose)
cout << "Rasterize Phantom to Image" << endl << endl;
#ifdef HAVE_MPI
phm.createFromPhantom (optPhmName.c_str());
if (mpiWorld.getRank() == 0) {
- imGlobal = new ImageFile (opt_outfile, opt_nx, opt_ny);
- imGlobal->fileCreate();
+ imGlobal = new ImageFile (opt_nx, opt_ny);
}
imLocal = new ImageFile (opt_nx, opt_ny);
#else
- imGlobal = new ImageFile (opt_outfile, opt_nx, opt_ny);
- imGlobal->fileCreate ();
+ imGlobal = new ImageFile (opt_nx, opt_ny);
#endif
ImageFileArray v;
}
} else if (optFilterName != "") {
if (mpiWorld.getRank() == 0) {
- image_filter_response (*imGlobal, optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param, opt_trace);
+ imGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
}
} else {
TimerCollectiveMPI timerRasterize (mpiWorld.getComm());
if (phm.getComposition() == P_UNIT_PULSE) {
v[opt_nx/2][opt_ny/2] = 1.;
} else if (optFilterName != "") {
- image_filter_response (*imGlobal, optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param, opt_trace);
+ imGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
} else {
#if HAVE_SGP
if (opt_trace >= TRACE_PHM)
if (mpiWorld.getRank() == 0)
#endif
{
- imGlobal->arrayDataWrite ();
double calctime = timerProgram.timerEnd ();
imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
- imGlobal->fileClose ();
+ imGlobal->fileWrite (opt_outfile);
if (opt_verbose)
cout << "Time to rasterized phantom: " << calctime << " seconds" << endl;
scanf ("%d", &nscale);
printf ("Enter minimum and maximum densities (min, max): ");
scanf ("%lf %lf", &dmin, &dmax);
- image_display_scale (*imGlobal, nscale, dmin, dmax);
+ imGlobal->displayScaling (nscale, dmin, dmax);
}
}