** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2pj.cpp,v 1.3 2000/06/22 10:17:28 kevin Exp $
+** $Id: phm2pj.cpp,v 1.6 2000/07/04 22:21:01 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
phm2pj_main (int argc, char* argv[])
{
Phantom phm;
- ScannerGeometry opt_geometry = DETECTOR_PARALLEL;
+ string optGeometryName = Scanner::GEOMETRY_PARALLEL_STR;
char *opt_outfile = NULL;
string opt_desc;
- string opt_phmfilename;
+ string optPhmFileName;
int opt_ndet;
int opt_nview;
int opt_nray = 1;
int opt_trace = 0;
- string optPhmName;
+ string optPhmName = Phantom::PHM_HERMAN_STR;
int opt_verbose = 0;
int opt_debug = 0;
double opt_rotangle = 1;
switch (c) {
case O_PHANTOM:
optPhmName = optarg;
- if (! phm.createFromPhantom (optPhmName.c_str())) {
- cout << "ERROR: Invalid phantom name " << optPhmName << endl << endl;
- phm2pj_usage(argv[0]);
- return (1);
- }
break;
case O_PHMFILE:
-#ifdef HAVE_MPI
- if (mpiWorld.getRank() == 0)
- cerr << "Can not read phantom from file in MPI mode" << endl;
- return (1);
-#endif
- opt_phmfilename = optarg;
- phm.createFromFile (opt_phmfilename.c_str());
+ optPhmFileName = optarg;
break;
case O_VERBOSE:
opt_verbose = 1;
break;
break;
case O_TRACE:
- if ((opt_trace = opt_set_trace(optarg)) < 0) {
+ if ((opt_trace = convertTraceNameToID(optarg)) == TRACE_INVALID) {
phm2pj_usage(argv[0]);
return (1);
}
}
}
- if (phm.nPElem() == 0) {
- cerr << "No phantom defined" << endl;
+ if (optPhmName == "" && optPhmFileName == "") {
+ cerr << "No phantom defined" << endl << endl;
phm2pj_usage(argv[0]);
return (1);
}
}
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;
+ desc << "phm2pj: NDet=" << opt_ndet << ", Nview=" << opt_nview << ", NRay=" << opt_nray << ", RotAngle=" << opt_rotangle << ", ";
+ if (optPhmFileName.length()) {
+ desc << "PhantomFile=" << optPhmFileName;
} else if (optPhmName != "") {
desc << "Phantom=" << optPhmName;
}
desc << ": " << opt_desc;
}
opt_desc = desc.str();
+
+ if (optPhmName != "") {
+ phm.createFromPhantom (optPhmName.c_str());
+ if (phm.fail()) {
+ cout << phm.failMessage() << endl << endl;
+ phm2pj_usage(argv[0]);
+ return (1);
+ }
+ }
+
+ if (optPhmFileName != "") {
+#ifdef HAVE_MPI
+ cerr << "Can not read phantom from file in MPI mode" << endl;
+ return (1);
+#endif
+ phm.createFromFile (optPhmFileName.c_str());
+ }
+
#ifdef HAVE_MPI
}
#endif
#endif
opt_rotangle *= PI;
- Scanner scanner (phm, opt_geometry, opt_ndet, opt_nview, opt_nray, opt_rotangle);
-
+ Scanner scanner (phm, optGeometryName.c_str(), opt_ndet, opt_nview, opt_nray, opt_rotangle);
+ if (scanner.fail()) {
+ cout << "Scanner Creation Error: " << scanner.failMessage() << endl;
+ return (1);
+ }
#ifdef HAVE_MPI
mpiWorld.setTotalWorkUnits (opt_nview);