X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=tools%2Fphm2if.cpp;h=b027975bdc156f76bfc9b85115cee2bae164e795;hb=c4af77faf7f216b936f0782e918634d34980c63f;hp=1e6992efd1766638a12f0fb50c145d3d35168be7;hpb=73d188fc0cf01163d61ecb0662b8a16a44b57eab;p=ctsim.git diff --git a/tools/phm2if.cpp b/tools/phm2if.cpp index 1e6992e..b027975 100644 --- a/tools/phm2if.cpp +++ b/tools/phm2if.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phm2if.cpp,v 1.3 2000/07/22 15:45:33 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 @@ -98,13 +98,13 @@ phm2if_usage (const char *program) } #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; @@ -121,7 +121,7 @@ phm2if_main (int argc, char* argv[]) int opt_trace = TRACE_NONE; bool opt_verbose = false; #ifdef HAVE_MPI - ImageFile* imLocal = NULL; + ImageFile* pImLocal = NULL; MPIWorld mpiWorld (argc, argv); #endif @@ -296,17 +296,17 @@ phm2if_main (int argc, char* argv[]) 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) { @@ -314,31 +314,31 @@ phm2if_main (int argc, char* argv[]) } } 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 @@ -347,8 +347,8 @@ phm2if_main (int argc, char* argv[]) #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; @@ -360,33 +360,38 @@ phm2if_main (int argc, char* argv[]) 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); } } }