X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fphm2if.cpp;h=2afac40c8030132cec197c927aa62f3610d05087;hp=cb5fca02e6e021fabd735cf59168e53c57f49e59;hb=59ff52843f44bec1ecd1ad36625cdda305cc7ef8;hpb=2ab37d1cdf6caa543510f370cbeb3749d0d61fe0 diff --git a/src/phm2if.cpp b/src/phm2if.cpp index cb5fca0..2afac40 100644 --- a/src/phm2if.cpp +++ b/src/phm2if.cpp @@ -2,8 +2,11 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phm2if.cpp,v 1.2 2000/06/07 03:50:27 kevin Exp $ +** $Id: phm2if.cpp,v 1.3 2000/06/07 07:43:19 kevin Exp $ ** $Log: phm2if.cpp,v $ +** Revision 1.3 2000/06/07 07:43:19 kevin +** Converted to IF data files and C++ +** ** Revision 1.2 2000/06/07 03:50:27 kevin ** *** empty log message *** ** @@ -135,13 +138,13 @@ phm2sdf_usage (const char *program) } #ifdef MPI_CT -void mpi_gather_image (ImageFile *im_global, ImageFile *im_local, const int opt_debug); +void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug); #endif int phm2sdf_main (const int argc, char *const argv[]) { - ImageFile *im_global = NULL; + ImageFile* im_global = NULL; PHANTOM *phm = NULL; int opt_nx = 0, opt_ny = 0; int opt_nsample = 1; @@ -159,7 +162,7 @@ phm2sdf_main (const int argc, char *const argv[]) int opt_verbose = 0; double time_start=0, time_end=0; #ifdef MPI_CT - ImageFile *im_local = NULL; + ImageFile* im_local = NULL; int mpi_argc = argc; char **mpi_argv = (char **) argv; double mpi_t1, mpi_t2, mpi_t, mpi_t_g; @@ -380,7 +383,7 @@ phm2sdf_main (const int argc, char *const argv[]) } #endif - ImageFileArray v = im_global->adf.getArray (); + ImageFileArray v = im_global->getArray (); double calctime = 0; #ifdef MPI_CT @@ -391,14 +394,13 @@ phm2sdf_main (const int argc, char *const argv[]) } } else if (opt_filter != -1) { if (mpi_ct.my_rank == 0) { - image_filter_response (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); + image_filter_response (*im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); calctime = 0; } } else { if (opt_verbose) mpi_t1 = MPI_Wtime(); - phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank], - mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace); + phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank], mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace); if (opt_verbose) { mpi_t2 = MPI_Wtime(); mpi_t = mpi_t2 - mpi_t1; @@ -406,14 +408,14 @@ phm2sdf_main (const int argc, char *const argv[]) if (mpi_ct.my_rank == 0) printf("Time to compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g); } - mpi_gather_image(im_global, im_local, opt_debug); + mpi_gather_image(*im_global, *im_local, opt_debug); } #else if (phm->type == P_UNIT_PULSE) { v[opt_nx/2][opt_ny/2] = 1.; calctime = 0; } else if (opt_filter != -1) { - // image_filter_response (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); + image_filter_response (*im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); calctime = 0; } else { #if HAVE_SGP @@ -442,17 +444,16 @@ phm2sdf_main (const int argc, char *const argv[]) fprintf (stdout, "Time to compile image = %.2f sec\n\n", calctime); } - if (opt_trace >= TRACE_PHM) - { - double dmin, dmax; - int nscale; + if (opt_trace >= TRACE_PHM) { + double dmin, dmax; + int nscale; - printf ("Enter display size scale (nominal = 1): "); - scanf ("%d", &nscale); - printf ("Enter minimum and maximum densities (min, max): "); - scanf ("%lf %lf", &dmin, &dmax); - // image_display_scale (im_global, nscale, dmin, dmax); - } + printf ("Enter display size scale (nominal = 1): "); + scanf ("%d", &nscale); + printf ("Enter minimum and maximum densities (min, max): "); + scanf ("%lf %lf", &dmin, &dmax); + image_display_scale (*im_global, nscale, dmin, dmax); + } phm_free (phm); @@ -462,34 +463,30 @@ phm2sdf_main (const int argc, char *const argv[]) #ifdef MPI_CT -void mpi_gather_image (ImageFile *im_global, ImageFile *im_local, const int opt_debug) +void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug) { - int iproc; - int end_work_unit; - int iw; - - end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1; - for (iw = 0; iw <= end_work_unit; iw++) { - MPI_Send(im_local->v[iw], im_local->ny, im_local->getMPIDataType(), 0, 0, mpi_ct.comm); + ImageFileArray vLocal = im_local.getArray(); + ImageFileArray vGlobal = im_global.getArray(); + int nyLocal = im_local.ny(); + int nyGlobal = im_global.ny(); + + int end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1; + for (int iw = 0; iw <= end_work_unit; iw++) { + MPI_Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0, mpi_ct.comm); } if (mpi_ct.my_rank == 0) { - for (iproc = 0; iproc < mpi_ct.nproc; iproc++) { - end_work_unit = mpi_ct.start_work_unit[iproc] - + mpi_ct.local_work_units[iproc] - - 1; + for (int iproc = 0; iproc < mpi_ct.nproc; iproc++) { + end_work_unit = mpi_ct.start_work_unit[iproc] + mpi_ct.local_work_units[iproc] - 1; if (opt_debug) { - fprintf(stdout, "Recv rs data from process %d (%d-%d)\n", iproc, - mpi_ct.start_work_unit[iproc], end_work_unit); + fprintf(stdout, "Recv rs data from process %d (%d-%d)\n", iproc, mpi_ct.start_work_unit[iproc], end_work_unit); fflush(stdout); } - - for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) { + for (int iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) { MPI_Status status; - - MPI_Recv(im_global->v[iw], im_global->ny, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status); + MPI_Recv(vGlobal[iw], nyGlobal, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status); } } }