** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2if.cpp,v 1.1 2000/07/13 07:01:35 kevin Exp $
+** $Id: phm2if.cpp,v 1.4 2000/07/23 01:49:03 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
}
#ifdef HAVE_MPI
-void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* imGlobal, ImageFile* imLocal, const int opt_debug);
+void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int opt_debug);
#endif
int
phm2if_main (int argc, char* argv[])
{
- ImageFile* imGlobal = NULL;
+ ImageFile* pImGlobal = NULL;
Phantom phm;
int opt_nx = 0, opt_ny = 0;
int opt_nsample = 1;
- string optPhmName = Phantom::PHM_HERMAN_STR;
+ string optPhmName (Phantom::convertPhantomIDToName(Phantom::PHM_HERMAN));
string optFilterName;
- string optDomainName = SignalFilter::DOMAIN_SPATIAL_STR;
+ string optDomainName (SignalFilter::convertDomainIDToName (SignalFilter::DOMAIN_SPATIAL));
char *opt_outfile = NULL;
int opt_debug = 0;
string opt_desc;
int opt_trace = TRACE_NONE;
bool opt_verbose = false;
#ifdef HAVE_MPI
- ImageFile* imLocal = NULL;
+ ImageFile* pImLocal = NULL;
MPIWorld mpiWorld (argc, argv);
#endif
opt_debug = 1;
break;
case O_TRACE:
- if ((opt_trace = convertTraceNameToID(optarg)) == TRACE_INVALID) {
+ if ((opt_trace = TraceLevel::convertTraceNameToID(optarg)) == TRACE_INVALID) {
phm2if_usage(argv[0]);
return (1);
}
phm.createFromPhantom (optPhmName.c_str());
if (mpiWorld.getRank() == 0) {
- imGlobal = new ImageFile (opt_nx, opt_ny);
+ pImGlobal = new ImageFile (opt_nx, opt_ny);
}
- imLocal = new ImageFile (opt_nx, opt_ny);
+ pImLocal = new ImageFile (opt_nx, opt_ny);
#else
- imGlobal = new ImageFile (opt_nx, opt_ny);
+ pImGlobal = new ImageFile (opt_nx, opt_ny);
#endif
ImageFileArray v;
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0)
- v = imGlobal->getArray ();
+ v = pImGlobal->getArray ();
if (phm.getComposition() == P_UNIT_PULSE) {
if (mpiWorld.getRank() == 0) {
}
} else if (optFilterName != "") {
if (mpiWorld.getRank() == 0) {
- imGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
+ pImGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
}
} else {
TimerCollectiveMPI timerRasterize (mpiWorld.getComm());
- phm.convertToImagefile (*imLocal, opt_nsample, opt_trace, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits());
+ phm.convertToImagefile (*pImLocal, opt_nsample, opt_trace, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits());
if (opt_verbose)
timerRasterize.timerEndAndReport ("Time to rasterize phantom");
TimerCollectiveMPI timerGather (mpiWorld.getComm());
- mpi_gather_image (mpiWorld, imGlobal, imLocal, opt_debug);
+ mpi_gather_image (mpiWorld, pImGlobal, pImLocal, opt_debug);
if (opt_verbose)
timerGather.timerEndAndReport ("Time to gather image");
}
#else
- v = imGlobal->getArray ();
+ v = pImGlobal->getArray ();
if (phm.getComposition() == P_UNIT_PULSE) {
v[opt_nx/2][opt_ny/2] = 1.;
} else if (optFilterName != "") {
- imGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
+ pImGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
} else {
#if HAVE_SGP
if (opt_trace >= TRACE_PHM)
phm.show();
#endif
- phm.convertToImagefile (*imGlobal, opt_nsample, opt_trace);
+ phm.convertToImagefile (*pImGlobal, opt_nsample, opt_trace);
}
#endif
#endif
{
double calctime = timerProgram.timerEnd ();
- imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
- imGlobal->fileWrite (opt_outfile);
+ pImGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
+ pImGlobal->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);
- imGlobal->displayScaling (nscale, dmin, dmax);
+ pImGlobal->displayScaling (nscale, dmin, dmax);
}
}
+ delete pImGlobal;
+#ifdef HAVE_MPI
+ delete pImLocal;
+#endif
+
return (0);
}
#ifdef HAVE_MPI
-void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* imGlobal, ImageFile* imLocal, const int opt_debug)
+void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int opt_debug)
{
- ImageFileArray vLocal = imLocal->getArray();
+ ImageFileArray vLocal = pImLocal->getArray();
ImageFileArray vGlobal = NULL;
- int nyLocal = imLocal->ny();
+ int nyLocal = pImLocal->ny();
if (mpiWorld.getRank() == 0)
- vGlobal = imGlobal->getArray();
+ vGlobal = pImGlobal->getArray();
for (int iw = 0; iw < mpiWorld.getMyLocalWorkUnits(); iw++)
- mpiWorld.getComm().Send(vLocal[iw], nyLocal, imLocal->getMPIDataType(), 0, 0);
+ mpiWorld.getComm().Send(vLocal[iw], nyLocal, pImLocal->getMPIDataType(), 0, 0);
if (mpiWorld.getRank() == 0) {
for (int iProc = 0; iProc < mpiWorld.getNumProcessors(); iProc++) {
for (int iw = mpiWorld.getStartWorkUnit(iProc); iw <= mpiWorld.getEndWorkUnit(iProc); iw++) {
MPI::Status status;
- mpiWorld.getComm().Recv(vGlobal[iw], nyLocal, imLocal->getMPIDataType(), iProc, 0, status);
+ mpiWorld.getComm().Recv(vGlobal[iw], nyLocal, pImLocal->getMPIDataType(), iProc, 0, status);
}
}
}