X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fphm2rs.c;h=cf47837ef61df46947ba3c1189ce098f3ebd3ab6;hp=8c9d450378f2b4ab9336f0b6b463d2142f44b000;hb=249f195fc5ec53e539dd91397a1adafb2f8b5cfb;hpb=34a2efcc5686600698897d2a5908acc061b0ff9f diff --git a/src/phm2rs.c b/src/phm2rs.c index 8c9d450..cf47837 100644 --- a/src/phm2rs.c +++ b/src/phm2rs.c @@ -2,8 +2,26 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phm2rs.c,v 1.4 2000/04/30 04:06:13 kevin Exp $ +** $Id: phm2rs.c,v 1.10 2000/05/11 14:07:55 kevin Exp $ ** $Log: phm2rs.c,v $ +** Revision 1.10 2000/05/11 14:07:55 kevin +** *** empty log message *** +** +** Revision 1.9 2000/05/08 20:02:32 kevin +** ANSI C changes +** +** Revision 1.8 2000/05/04 18:16:34 kevin +** renamed filter definitions +** +** Revision 1.7 2000/05/03 08:49:50 kevin +** Code cleanup +** +** Revision 1.6 2000/04/30 18:23:53 kevin +** Code cleaning +** +** Revision 1.5 2000/04/30 10:13:27 kevin +** Fixed MPI bugs +** ** Revision 1.4 2000/04/30 04:06:13 kevin ** Update Raysum i/o routines ** Fix MPI bug in ctrec (scatter_raysum) that referenced rs_global @@ -42,21 +60,12 @@ #include "ct.h" -#define O_PHANTOM 1 -#define O_DESC 2 -#define O_NRAY 3 -#define O_ROTANGLE 4 -#define O_TRACE 5 -#define O_VERBOSE 6 -#define O_HELP 7 -#define O_PICFILE 8 -#define O_DEBUG 10 -#define O_VERSION 11 +enum { O_PHANTOM, O_DESC, O_NRAY, O_ROTANGLE, O_TRACE, O_VERBOSE, O_HELP, O_PHMFILE, O_DEBUG, O_VERSION }; static struct option my_options[] = { {"phantom", 1, 0, O_PHANTOM}, - {"picfile", 1, 0, O_PICFILE}, + {"phmfile", 1, 0, O_PHMFILE}, {"desc", 1, 0, O_DESC}, {"nray", 1, 0, O_NRAY}, {"rotangle", 1, 0, O_ROTANGLE}, @@ -75,9 +84,9 @@ usage (const char *program) if (mpi_ct.my_rank == 0) { #endif - fprintf(stdout,"usage: %s outfile ndet nview [--phantom phantom-name] [--picfile filename] [OPTIONS]\n", kbasename(program)); + fprintf(stdout,"usage: %s outfile ndet nview [--phantom phantom-name] [--phmfile filename] [OPTIONS]\n", kbasename(program)); fprintf(stdout,"Calculate raysums (projections) through phantom object, either\n"); - fprintf(stdout,"a predefined --phantom or a --picfile\n"); + fprintf(stdout,"a predefined --phantom or a --phmfile\n"); fprintf(stdout,"\n"); fprintf(stdout," outfile Name of output file for raysums\n"); fprintf(stdout," ndet Number of detectors\n"); @@ -87,14 +96,14 @@ if (mpi_ct.my_rank == 0) fprintf(stdout," rowland Rowland head phantom\n"); fprintf(stdout," browland Bordered Rowland head phantom\n"); fprintf(stdout," unitpulse Unit pulse phantom\n"); - fprintf(stdout," --picfile Get Phantom from picture file\n"); + fprintf(stdout," --phmfile Get Phantom from phantom file\n"); fprintf(stdout," --desc Description of raysum\n"); fprintf(stdout," --nray Number of rays per detector (default = 1)\n"); fprintf(stdout," --rotangle Degrees to rotate view through, multiple of PI (default = 1)\n"); fprintf(stdout," --trace Trace level to use\n"); fprintf(stdout," none No tracing (default)\n"); fprintf(stdout," text Trace text level\n"); - fprintf(stdout," pic Trace picture\n"); + fprintf(stdout," phm Trace PHANTOM\n"); fprintf(stdout," rays Trace rays\n"); fprintf(stdout," plot Trace plot\n"); fprintf(stdout," clipping Trace clipping\n"); @@ -116,23 +125,23 @@ int main (const int argc, char *const argv[]) { DETECTOR *det; - PICTURE *pic = NULL; - RAYSUM *rs_global; - char str[256], *opt_outfile, opt_desc[MAXREMARK+1]; - char opt_picfilename[256]; + PHANTOM *phm = NULL; + RAYSUM *rs_global = NULL; + char str[256], *opt_outfile = NULL, opt_desc[MAXREMARK+1]; + char opt_phmfilename[256]; char *endptr, *endstr; int opt_ndet, opt_nview; int opt_nray = 1; - int opt_trace = 0, opt_picnum = -1; + int opt_trace = 0, opt_phmnum = -1; int opt_verbose = 0; int opt_debug = 0; double opt_rotangle = 1; - double time_start, time_end; + double time_start = 0, time_end = 0; #ifdef MPI_CT RAYSUM *rs_local; int mpi_argc = argc; char **mpi_argv = (char **) argv; - double mpi_t1, mpi_t2, mpi_t, mpi_t_g; + double mpi_t1 = 0, mpi_t2 = 0, mpi_t, mpi_t_g; MPI_Init(&mpi_argc, &mpi_argv); MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm); @@ -153,7 +162,7 @@ main (const int argc, char *const argv[]) if (mpi_ct.my_rank == 0) { #endif strcpy(opt_desc, ""); - strcpy(opt_picfilename, ""); + strcpy(opt_phmfilename, ""); while (1) { int c = getopt_long(argc, argv, "", my_options, NULL); char *endptr = NULL; @@ -164,17 +173,17 @@ main (const int argc, char *const argv[]) switch (c) { case O_PHANTOM: - opt_picnum = opt_set_picture(optarg, argv[0]); - pic = create_pic(opt_picnum); + opt_phmnum = opt_set_phantom (optarg, argv[0]); + phm = phm_create (opt_phmnum); break; - case O_PICFILE: + case O_PHMFILE: #ifdef MPI_CT if (mpi_ct.my_rank == 0) - fprintf(stderr, "Can not read picture from file in MPI mode\n"); + fprintf(stderr, "Can not read phantom from file in MPI mode\n"); exit(1); #endif - strncpy(opt_picfilename, optarg, sizeof(opt_picfilename)); - pic = create_pic_from_file(opt_picfilename); + strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename)); + phm = phm_create_from_file(opt_phmfilename); break; case O_VERBOSE: opt_verbose = 1; @@ -224,7 +233,7 @@ main (const int argc, char *const argv[]) } } - if (pic == NULL) { + if (phm == NULL) { fprintf(stderr, "No phantom defined\n"); usage(argv[0]); exit(1); @@ -252,12 +261,12 @@ main (const int argc, char *const argv[]) snprintf(str, sizeof(str), "Raysum_Collect: NDet=%d, Nview=%d, NRay=%d, RotAngle=%.2f, ", opt_ndet, opt_nview, opt_nray, opt_rotangle); - if (opt_picfilename[0]) { + if (opt_phmfilename[0]) { strncat(str, "Phantom=", sizeof(str)); - strncat(str, opt_picfilename, sizeof(str)); - } else if (opt_picnum != -1) { + strncat(str, opt_phmfilename, sizeof(str)); + } else if (opt_phmnum != -1) { strncat(str, "Phantom=", sizeof(str)); - strncat(str, name_of_picture(opt_picnum), sizeof(str)); + strncat(str, name_of_phantom(opt_phmnum), sizeof(str)); } if (opt_desc[0]) { strncat(str, ": ", sizeof(str)); @@ -274,22 +283,23 @@ main (const int argc, char *const argv[]) MPI_Bcast(&opt_nview, 1, MPI_INT, 0, mpi_ct.comm); MPI_Bcast(&opt_ndet, 1, MPI_INT, 0, mpi_ct.comm); MPI_Bcast(&opt_nray, 1, MPI_INT, 0, mpi_ct.comm); - MPI_Bcast(&opt_picnum, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm); MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm); MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm); MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm); - if (mpi_ct.my_rank > 0 && opt_picnum > 0) - pic = create_pic(opt_picnum); + if (mpi_ct.my_rank > 0 && opt_phmnum >= 0) + phm = phm_create (opt_phmnum); #endif opt_rotangle *= PI; - det = detect_create (pic, opt_ndet, opt_nview, opt_nray, opt_rotangle); + det = detector_create (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle); #ifdef MPI_CT mpi_ct_calc_work_units(opt_nview); if (mpi_ct.my_rank == 0) { rs_global = raysum_create_from_det (opt_outfile, det); + raysum_alloc_views(rs_global); } rs_local = raysum_create_from_det (NULL, det); @@ -299,7 +309,7 @@ main (const int argc, char *const argv[]) if (opt_verbose) mpi_t1 = MPI_Wtime(); - raysum_collect (rs_local, det, pic, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE); + raysum_collect (rs_local, det, phm, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE); if (opt_verbose) { mpi_t2 = MPI_Wtime(); mpi_t = mpi_t2 - mpi_t1; @@ -320,7 +330,7 @@ main (const int argc, char *const argv[]) } #else rs_global = raysum_create_from_det (opt_outfile, det); - raysum_collect (rs_global, det, pic, 0, opt_trace, FALSE); + raysum_collect (rs_global, det, phm, 0, opt_trace, FALSE); #endif #ifdef MPI_CT @@ -353,13 +363,7 @@ main (const int argc, char *const argv[]) raysum_close (rs_global); #endif - detect_free (det); - - if (opt_trace >= TRACE_PIC) - { - crt_set_cpos (1, 1); - printf("Finished\n"); - } + detector_free (det); return (0); }