X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=tools%2Fphm2pj.cpp;h=2bc4d98a4ffa351b02638ceb5cea87f126db6add;hp=82cad2f5ab8d92b69e97280a04336c233ed909ac;hb=1e88cf0f7fa4f690ea9f110e8ed3f2b5338d0a10;hpb=74a34e63a9a356e1467acdba65497ab15190dde0 diff --git a/tools/phm2pj.cpp b/tools/phm2pj.cpp index 82cad2f..2bc4d98 100644 --- a/tools/phm2pj.cpp +++ b/tools/phm2pj.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phm2pj.cpp,v 1.9 2000/08/03 09:57:29 kevin Exp $ +** $Id: phm2pj.cpp,v 1.10 2000/08/25 15:59:13 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 @@ -29,7 +29,7 @@ #include "timer.h" -enum { O_PHANTOM, O_DESC, O_NRAY, O_ROTANGLE, O_PHMFILE, +enum { O_PHANTOM, O_DESC, O_NRAY, O_ROTANGLE, O_PHMFILE, O_GEOMETRY, O_FOCAL_LENGTH, O_FIELD_OF_VIEW, O_TRACE, O_VERBOSE, O_HELP, O_DEBUG, O_VERSION }; static struct option phm2pj_options[] = @@ -39,6 +39,9 @@ static struct option phm2pj_options[] = {"desc", 1, 0, O_DESC}, {"nray", 1, 0, O_NRAY}, {"rotangle", 1, 0, O_ROTANGLE}, + {"geometry", 1, 0, O_GEOMETRY}, + {"focal-length", 1, 0, O_FOCAL_LENGTH}, + {"field-of-view", 1, 0, O_FIELD_OF_VIEW}, {"trace", 1, 0, O_TRACE}, {"verbose", 0, 0, O_VERBOSE}, {"help", 0, 0, O_HELP}, @@ -47,39 +50,43 @@ static struct option phm2pj_options[] = {0, 0, 0, 0} }; -static const char* g_szIdStr = "$Id: phm2pj.cpp,v 1.9 2000/08/03 09:57:29 kevin Exp $"; +static const char* g_szIdStr = "$Id: phm2pj.cpp,v 1.10 2000/08/25 15:59:13 kevin Exp $"; void phm2pj_usage (const char *program) { - cout << "usage: " << fileBasename(program) << " outfile ndet nview [--phantom phantom-name] [--phmfile filename] [OPTIONS]" << endl; - cout << "Calculate (projections) through phantom object, either a predefined --phantom or a --phmfile" << endl; - cout << "" << endl; - cout << " outfile Name of output file for raysums" << endl; - cout << " ndet Number of detectors" << endl; - cout << " nview Number of rotated views" << endl; - cout << " --phantom Phantom to use for projection" << endl; - cout << " herman Herman head phantom" << endl; - cout << " bherman Bordered herman head phantom" << endl; - cout << " rowland Rowland head phantom" << endl; - cout << " browland Bordered Rowland head phantom" << endl; - cout << " unitpulse Unit pulse phantom" << endl; - cout << " --phmfile Get Phantom from phantom file" << endl; - cout << " --desc Description of raysum" << endl; - cout << " --nray Number of rays per detector (default = 1)" << endl; - cout << " --rotangle Degrees to rotate view through, multiple of PI (default = 1)" << endl; - cout << " --trace Trace level to use" << endl; - cout << " none No tracing (default)" << endl; - cout << " text Trace text level" << endl; - cout << " phm Trace phantom image" << endl; - cout << " rays Trace rays" << endl; - cout << " plot Trace plot" << endl; - cout << " clipping Trace clipping" << endl; - cout << " --verbose Verbose mode" << endl; - cout << " --debug Debug mode" << endl; - cout << " --version Print version" << endl; - cout << " --help Print this help message" << endl; + cout << "usage: " << fileBasename(program) << " outfile ndet nview [--phantom phantom-name] [--phmfile filename] [OPTIONS]\n"; + cout << "Calculate (projections) through phantom object, either a predefined --phantom or a --phmfile\n\n"; + cout << " outfile Name of output file for raysums\n"; + cout << " ndet Number of detectors\n"; + cout << " nview Number of rotated views\n"; + cout << " --phantom Phantom to use for projection\n"; + cout << " herman Herman head phantom\n"; + cout << " herman-b Herman head phantom (Bordered)\n"; + cout << " shepp-logan Shepp-Logan head phantom\n"; + cout << " shepp-logan-b Shepp-Logan head phantom (Bordered)\n"; + cout << " unitpulse Unit pulse phantom\n"; + cout << " --phmfile Get Phantom from phantom file\n"; + cout << " --desc Description of raysum\n"; + cout << " --nray Number of rays per detector (default = 1)\n"; + cout << " --rotangle Degrees to rotate view through (multiple of PI)\n"; + cout << " (default = 1)\n"; + cout << " --focal-length Focal length ratio (ratio to radius of phantom)\n"; + cout << " (default = 1)\n"; + cout << " --field-of-view Field of view (ratio to diameter of phantom square)\n"; + cout << " (default = 1)\n"; + cout << " --trace Trace level to use\n"; + cout << " none No tracing (default)\n"; + cout << " text Trace text level\n"; + cout << " phm Trace phantom image\n"; + cout << " rays Trace rays\n"; + cout << " plot Trace plot\n"; + cout << " clipping Trace clipping\n"; + cout << " --verbose Verbose mode\n"; + cout << " --debug Debug mode\n"; + cout << " --version Print version\n"; + cout << " --help Print this help message\n"; } #ifdef HAVE_MPI @@ -97,6 +104,8 @@ phm2pj_main (int argc, char* argv[]) int opt_ndet; int opt_nview; int opt_nray = 1; + double dOptFocalLength = 1.; + double dOptFieldOfView = 1.; int opt_trace = 0; string optPhmName (Phantom::convertPhantomIDToName(Phantom::PHM_HERMAN)); int opt_verbose = 0; @@ -152,6 +161,27 @@ phm2pj_main (int argc, char* argv[]) return (1); } break; + case O_GEOMETRY: + optGeometryName = optarg; + break; + case O_FOCAL_LENGTH: + dOptFocalLength = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + cerr << "Error setting --focal-length to " << optarg << endl; + phm2pj_usage(argv[0]); + return (1); + } + break; + case O_FIELD_OF_VIEW: + dOptFieldOfView = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + cerr << "Error setting --field-of-view to " << optarg << endl; + phm2pj_usage(argv[0]); + return (1); + } + break; case O_NRAY: opt_nray = strtol(optarg, &endptr, 10); endstr = optarg + strlen(optarg); @@ -165,7 +195,7 @@ phm2pj_main (int argc, char* argv[]) #ifdef VERSION cout << "Version: " << VERSION << endl << g_szIdStr << endl; #else - cout << "Unknown version number" << endl; + cout << "Unknown version number\n"; #endif return (0); case O_HELP: @@ -179,7 +209,7 @@ phm2pj_main (int argc, char* argv[]) } if (optPhmName == "" && optPhmFileName == "") { - cerr << "No phantom defined" << endl << endl; + cerr << "No phantom defined\n" << endl; phm2pj_usage(argv[0]); return (1); } @@ -227,7 +257,7 @@ phm2pj_main (int argc, char* argv[]) if (optPhmFileName != "") { #ifdef HAVE_MPI - cerr << "Can not read phantom from file in MPI mode" << endl; + cerr << "Can not read phantom from file in MPI mode\n"; return (1); #endif phm.createFromFile (optPhmFileName.c_str()); @@ -254,7 +284,7 @@ phm2pj_main (int argc, char* argv[]) #endif opt_rotangle *= PI; - Scanner scanner (phm, optGeometryName.c_str(), opt_ndet, opt_nview, opt_nray, opt_rotangle); + Scanner scanner (phm, optGeometryName.c_str(), opt_ndet, opt_nview, opt_nray, opt_rotangle, dOptFocalLength, dOptFieldOfView); if (scanner.fail()) { cout << "Scanner Creation Error: " << scanner.failMessage() << endl; return (1); @@ -273,10 +303,10 @@ phm2pj_main (int argc, char* argv[]) pjLocal.setNView (mpiWorld.getMyLocalWorkUnits()); if (opt_debug) - cout << "pjLocal->nview = " << pjLocal.nView() << " (process " << mpiWorld.getRank() << ")" << endl;; + cout << "pjLocal->nview = " << pjLocal.nView() << " (process " << mpiWorld.getRank() << ")\n";; TimerCollectiveMPI timerProject (mpiWorld.getComm()); - scanner.collectProjections (pjLocal, phm, mpiWorld.getMyStartWorkUnit(), opt_trace); + scanner.collectProjections (pjLocal, phm, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits(), false, opt_trace); if (opt_verbose) timerProject.timerEndAndReport ("Time to collect projections"); @@ -294,7 +324,7 @@ phm2pj_main (int argc, char* argv[]) pSGPDriver = new SGPDriver ("phm2pj", 600, 600); pSGP = new SGP (*pSGPDriver); } - scanner.collectProjections (pjGlobal, phm, 0, opt_trace, pSGP); + scanner.collectProjections (pjGlobal, phm, opt_trace, pSGP); if (opt_trace >= TRACE_PHM) { cout << "Press enter to continue\n"; cio_kb_getc(); @@ -303,7 +333,7 @@ phm2pj_main (int argc, char* argv[]) } #else - scanner.collectProjections (pjGlobal, phm, 0, opt_trace); + scanner.collectProjections (pjGlobal, phm, opt_trace); #endif #endif @@ -321,7 +351,7 @@ phm2pj_main (int argc, char* argv[]) pjGlobal.printScanInfo(); cout << endl; cout << " Remark: " << pjGlobal.remark() << endl; - cout << "Run time: " << pjGlobal.calcTime() << " seconds" << endl; + cout << "Run time: " << pjGlobal.calcTime() << " seconds\n"; } } @@ -384,7 +414,7 @@ main (int argc, char* argv[]) } catch (exception e) { cerr << "Exception: " << e.what() << endl; } catch (...) { - cerr << "Unknown exception" << endl; + cerr << "Unknown exception\n"; } return (retval);