X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fctrec.cpp;h=0ec840217f0944b6a759c9235a57913c116dea91;hp=586f2b65744dbf41863ca77667c2a6bfd01fa6c2;hb=f4a23943110823118f35756dd41fbd6707f04511;hpb=b5857e74e5735455b5ef11cbea5044ae7b2e8a0d diff --git a/src/ctrec.cpp b/src/ctrec.cpp index 586f2b6..0ec8402 100644 --- a/src/ctrec.cpp +++ b/src/ctrec.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctrec.cpp,v 1.9 2000/06/15 19:07:10 kevin Exp $ +** $Id: ctrec.cpp,v 1.10 2000/06/17 20:12:15 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 @@ -95,7 +95,7 @@ ctrec_usage (const char *program) #ifdef HAVE_MPI -static void ScatterProjectionsMPI (MPIWorld& mpiWorld, RAYSUM *rsGlobal, RAYSUM *rsLocal, const int debug); +static void ScatterProjectionsMPI (MPIWorld& mpiWorld, Projections& projGlobal, Projections& projLocal, const int debug); static void ReduceImageMPI (MPIWorld& mpiWorld, ImageFile* imLocal, ImageFile* imGlobal); #endif @@ -104,8 +104,8 @@ int ctrec_main (int argc, char * argv[]) { ImageFile *imGlobal = NULL; - RAYSUM *rsGlobal = NULL; - char *rs_name, *im_filename = NULL; + Projections projGlobal; + char *pj_name, *im_filename = NULL; string remark; char filt_name[80]; char *endptr; @@ -120,7 +120,6 @@ ctrec_main (int argc, char * argv[]) int nx, ny; #ifdef HAVE_MPI ImageFile *imLocal; - RAYSUM *rsLocal; int mpi_nview, mpi_ndet; double mpi_detinc, mpi_rotinc, mpi_phmlen; MPIWorld mpiWorld (argc, argv); @@ -198,7 +197,7 @@ ctrec_main (int argc, char * argv[]) return (1); } - rs_name = argv[optind]; + pj_name = argv[optind]; im_filename = argv[optind + 1]; @@ -223,16 +222,15 @@ ctrec_main (int argc, char * argv[]) #ifdef HAVE_MPI if (mpiWorld.getRank() == 0) { - rsGlobal = raysum_open (rs_name); - raysum_read (rsGlobal); + projGlobal.read (pj_name); if (opt_verbose) - raysum_print_info(rsGlobal); + projGlobal.printScanInfo(); - mpi_ndet = rsGlobal->ndet; - mpi_nview = rsGlobal->nview; - mpi_detinc = rsGlobal->det_inc; - mpi_phmlen = rsGlobal->phmlen; - mpi_rotinc = rsGlobal->rot_inc; + mpi_ndet = projGlobal.nDet(); + mpi_nview = projGlobal.nView(); + mpi_detinc = projGlobal.detInc(); + mpi_phmlen = projGlobal.phmLen(); + mpi_rotinc = projGlobal.rotInc(); } TimerCollectiveMPI timerBcast (mpiWorld.getComm()); @@ -256,15 +254,13 @@ ctrec_main (int argc, char * argv[]) mpiWorld.setTotalWorkUnits (mpi_nview); - rsLocal = raysum_create (NULL, mpiWorld.getMyLocalWorkUnits(), mpi_ndet); - rsLocal->ndet = mpi_ndet; - rsLocal->nview = mpi_nview; - rsLocal->det_inc = mpi_detinc; - rsLocal->phmlen = mpi_phmlen; - rsLocal->rot_inc = mpi_rotinc; + Projections projLocal (mpiWorld.getMyLocalWorkUnits(), mpi_ndet); + projLocal.setDetInc (mpi_detinc); + projLocal.setPhmLen (mpi_phmlen); + projLocal.setRotInc (mpi_rotinc); TimerCollectiveMPI timerScatter (mpiWorld.getComm()); - ScatterProjectionsMPI (mpiWorld, rsGlobal, rsLocal, opt_debug); + ScatterProjectionsMPI (mpiWorld, projGlobal, projLocal, opt_debug); if (opt_verbose) timerScatter.timerEndAndReport ("Time to scatter projections"); @@ -275,10 +271,9 @@ ctrec_main (int argc, char * argv[]) imLocal = new ImageFile (nx, ny); #else - rsGlobal = raysum_open (rs_name); - raysum_read (rsGlobal); + projGlobal.read (pj_name); if (opt_verbose) - raysum_print_info(rsGlobal); + projGlobal.printScanInfo(); imGlobal = new ImageFile (im_filename, nx, ny); imGlobal->fileCreate(); @@ -286,7 +281,7 @@ ctrec_main (int argc, char * argv[]) #ifdef HAVE_MPI TimerCollectiveMPI timerReconstruct (mpiWorld.getComm()); - proj_reconst (*imLocal, rsLocal, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); + proj_reconst (*imLocal, projLocal, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); if (opt_verbose) timerReconstruct.timerEndAndReport ("Time to reconstruct"); @@ -295,21 +290,20 @@ ctrec_main (int argc, char * argv[]) if (opt_verbose) timerReduce.timerEndAndReport ("Time to reduce image"); #else - proj_reconst (*imGlobal, rsGlobal, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); + proj_reconst (*imGlobal, projGlobal, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); #endif #ifdef HAVE_MPI if (mpiWorld.getRank() == 0) #endif { - raysum_close (rsGlobal); - double calctime = timerProgram.timerEnd(); + double calcTime = timerProgram.timerEnd(); imGlobal->arrayDataWrite (); - imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, rsGlobal->remark.c_str(), rsGlobal->calctime); - imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark.c_str(), calctime); + imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, projGlobal.remark(), projGlobal.calcTime()); + imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark.c_str(), calcTime); imGlobal->fileClose (); if (opt_verbose) - cout << "Run time: " << calctime << " seconds" << endl; + cout << "Run time: " << calcTime << " seconds" << endl; } #ifdef HAVE_MPI MPI::Finalize(); @@ -325,25 +319,34 @@ ctrec_main (int argc, char * argv[]) ////////////////////////////////////////////////////////////////////////////////////// #ifdef HAVE_MPI -static void ScatterProjectionsMPI (MPIWorld& mpiWorld, RAYSUM *rsGlobal, RAYSUM *rsLocal, const int opt_debug) +static void ScatterProjectionsMPI (MPIWorld& mpiWorld, Projections& projGlobal, Projections& projLocal, const int opt_debug) { if (mpiWorld.getRank() == 0) { for (int iProc = 0; iProc < mpiWorld.getNumProcessors(); iProc++) { for (int iw = mpiWorld.getStartWorkUnit(iProc); iw <= mpiWorld.getEndWorkUnit(iProc); iw++) { - mpiWorld.getComm().Send(&rsGlobal->view[iw]->ndet, 1, MPI::INT, iProc, 0); - mpiWorld.getComm().Send(&rsGlobal->view[iw]->view_angle, 1, MPI::DOUBLE, iProc, 0); - mpiWorld.getComm().Send(rsGlobal->view[iw]->detval, rsGlobal->ndet, MPI::FLOAT, iProc, 0); + DetectorArray& detarray = projGlobal.getDetectorArray( iw ); + int nDet = detarray.nDet(); + DetectorValue* detval = detarray.detValues(); + + double viewAngle = detarray.viewAngle(); + mpiWorld.getComm().Send(&nDet, 1, MPI::INT, iProc, 0); + mpiWorld.getComm().Send(&viewAngle, 1, MPI::DOUBLE, iProc, 0); + mpiWorld.getComm().Send(detval, nDet, MPI::FLOAT, iProc, 0); } } } for (int iw = 0; iw < mpiWorld.getMyLocalWorkUnits(); iw++) { MPI::Status status; - mpiWorld.getComm().Recv(&rsLocal->view[iw]->ndet, 1, MPI::INT, 0, 0, status); - mpiWorld.getComm().Recv(&rsLocal->view[iw]->view_angle, 1, MPI::DOUBLE, 0, 0, status); - mpiWorld.getComm().Recv(rsLocal->view[iw]->detval, rsLocal->ndet, MPI::FLOAT, 0, 0, status); + int nDet; + double viewAngle; + DetectorValue* detval = projLocal.getDetectorArray(iw).detValues(); + + mpiWorld.getComm().Recv(&nDet, 1, MPI::INT, 0, 0, status); + mpiWorld.getComm().Recv(&viewAngle, 1, MPI::DOUBLE, 0, 0, status); + mpiWorld.getComm().Recv(detval, nDet, MPI::FLOAT, 0, 0, status); + projLocal.getDetectorArray(iw).setViewAngle( viewAngle ); } - rsLocal->nview = mpiWorld.getMyLocalWorkUnits(); } static void