X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fctrec.cpp;h=a7b8ee575f98a6d575a8c0317c5ad405ec69177e;hp=f48fc584de6d60b110b1835060df5ebaf71d44d6;hb=59ff52843f44bec1ecd1ad36625cdda305cc7ef8;hpb=2ab37d1cdf6caa543510f370cbeb3749d0d61fe0 diff --git a/src/ctrec.cpp b/src/ctrec.cpp index f48fc58..a7b8ee5 100644 --- a/src/ctrec.cpp +++ b/src/ctrec.cpp @@ -2,8 +2,11 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctrec.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $ +** $Id: ctrec.cpp,v 1.2 2000/06/07 07:43:19 kevin Exp $ ** $Log: ctrec.cpp,v $ +** Revision 1.2 2000/06/07 07:43:19 kevin +** Converted to IF data files and C++ +** ** Revision 1.1 2000/06/07 02:29:05 kevin ** Initial C++ versions ** @@ -147,12 +150,11 @@ static void print_raysum_info(const RAYSUM *rs); int ctrec_main (const int argc, char *const argv[]) { - IMAGE *im_global = NULL; + ImageFile *im_global = NULL; RAYSUM *rs_global = NULL; char *rs_name, *im_filename = NULL; char remark[MAXREMARK]; char filt_name[80]; - int nx, ny; double time_start = 0, time_end = 0; char *endptr; int opt_verbose = 0; @@ -163,15 +165,15 @@ ctrec_main (const int argc, char *const argv[]) InterpolationType opt_interp = I_LINEAR; int opt_interp_param = 1; BackprojType opt_backproj = O_BPROJ_DIFF2; + int nx, ny; #ifdef MPI_CT - IMAGE *im_local; + ImageFile *im_local; RAYSUM *rs_local; int mpi_argc = argc; char **mpi_argv = (char **) argv; int mpi_nview, mpi_ndet; double mpi_detinc, mpi_rotinc, mpi_phmlen; double mpi_t1, mpi_t2, mpi_t, mpi_t_g; - int ix; MPI_Init(&mpi_argc, &mpi_argv); MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm); @@ -343,11 +345,10 @@ ctrec_main (const int argc, char *const argv[]) } if (mpi_ct.my_rank == 0) { - im_global = image_create (im_filename, nx, ny); - sdf_add_label (LT_HISTORY, rs_global->remark, rs_global->calctime, im_global->dfp_2d->dfp); - sdf_add_empty_label (im_global->dfp_2d->dfp); + im_global = new ImageFile (im_filename, nx, ny); + im_global->adf.fileCreate(); } - im_local = image_create (NULL, nx, ny); + im_local = new ImageFile (nx, ny); #else rs_global = raysum_open (rs_name); @@ -355,14 +356,14 @@ ctrec_main (const int argc, char *const argv[]) if (opt_verbose) print_raysum_info(rs_global); - im_global = image_create (im_filename, nx, ny); - sdf_add_label (LT_HISTORY, rs_global->remark, rs_global->calctime, im_global->dfp_2d->dfp); - sdf_add_empty_label (im_global->dfp_2d->dfp); + im_global = new ImageFile (im_filename, nx, ny); + im_global->adf.fileCreate(); + #endif #ifdef MPI_CT mpi_t1 = MPI_Wtime(); - image_reconst (im_local, rs_local, opt_filter, opt_filter_param, + proj_reconst (*im_local, rs_local, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); mpi_t2 = MPI_Wtime(); mpi_t = mpi_t2 - mpi_t1; @@ -370,7 +371,7 @@ ctrec_main (const int argc, char *const argv[]) if (mpi_ct.my_rank == 0 && opt_verbose) printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g); #else - image_reconst (im_global, rs_global, opt_filter, opt_filter_param, + proj_reconst (*im_global, rs_global, opt_filter, opt_filter_param, opt_interp, opt_interp_param, opt_backproj, opt_trace); #endif @@ -378,12 +379,17 @@ ctrec_main (const int argc, char *const argv[]) if (opt_verbose) mpi_t1 = MPI_Wtime(); - for (ix = 0; ix < im_local->nx; ix++) { + int nxLocal = im_local->adf.nx(); + int nyLocal = im_local->adf.ny(); + ImageFileArray vLocal = im_local->getArray(); + ImageFileArray vGlobal = im_global->getArray(); + + for (int ix = 0; ix < nxLocal; ix++) { void *recvbuf = NULL; if (mpi_ct.my_rank == 0) - recvbuf = im_global->v[ix]; + recvbuf = vGlobal[ix]; - MPI_Reduce(im_local->v[ix], recvbuf, im_local->ny, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm); + MPI_Reduce(vLocal[ix], recvbuf, nyLocal, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm); } if (opt_verbose) { @@ -406,11 +412,13 @@ ctrec_main (const int argc, char *const argv[]) #endif { raysum_close (rs_global); - strncpy (im_global->remark, remark, sizeof(im_global->remark)); - im_global->calctime = time_end - time_start; - image_save (im_global); + double calctime = time_end - time_start; + im_global->adf.arrayDataWrite (); + im_global->adf.labelAdd (Array2dFileLabel::L_HISTORY, rs_global->remark, rs_global->calctime); + im_global->adf.labelAdd (Array2dFileLabel::L_HISTORY, remark, calctime); + im_global->adf.fileClose (); if (opt_verbose) - fprintf (stdout, "Time active = %.2f\n", im_global->calctime); + cout << "Time active = " << calctime << " sec" << endl; } #ifdef MPI_CT