r343: no message
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 2 Jan 2001 13:57:52 +0000 (13:57 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 2 Jan 2001 13:57:52 +0000 (13:57 +0000)
tools/phm2if.cpp

index 80dc0d121e32e12aac046e4c6cc6ca19f956bcf8..f7f9551d62505bc5f7447df0b8f69cc5492a5d7d 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.18 2001/01/02 07:24:26 kevin Exp $
+**  $Id: phm2if.cpp,v 1.19 2001/01/02 13:57:52 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
@@ -30,7 +30,7 @@
 
 
 enum { O_PHANTOM, O_DESC, O_NSAMPLE, O_FILTER, O_TRACE, O_VERBOSE, O_HELP, 
-       O_PHMFILE, O_FILTER_DOMAIN, O_FILTER_BW, O_FILTER_PARAM, O_DEBUG, O_VERSION };
+O_PHMFILE, O_FILTER_DOMAIN, O_FILTER_BW, O_FILTER_PARAM, O_DEBUG, O_VERSION };
 
 static struct option my_options[] = 
 {
@@ -50,7 +50,7 @@ static struct option my_options[] =
   {0, 0, 0, 0}
 };
 
-static const char* g_szIdStr = "$Id: phm2if.cpp,v 1.18 2001/01/02 07:24:26 kevin Exp $";
+static const char* g_szIdStr = "$Id: phm2if.cpp,v 1.19 2001/01/02 13:57:52 kevin Exp $";
 
 void 
 phm2if_usage (const char *program)
@@ -125,7 +125,7 @@ phm2if_main (int argc, char* argv[])
   char *endptr = NULL;
   char *endstr;
   Timer timerProgram;
-
+  
 #ifdef HAVE_MPI
   ImageFile* pImLocal = NULL;
   MPIWorld mpiWorld (argc, argv);
@@ -134,76 +134,76 @@ phm2if_main (int argc, char* argv[])
     while (1) {
       int c = getopt_long(argc, argv, "", my_options, NULL);
       if (c == -1)
-       break;
+        break;
       
       switch (c) {
       case O_PHANTOM:
-       optPhmName = optarg;
-       break;
+        optPhmName = optarg;
+        break;
       case O_PHMFILE:
-       optPhmFilename = optarg;
-       break;
+        optPhmFilename = optarg;
+        break;
       case O_VERBOSE:
-       optVerbose = true;
-       break;
+        optVerbose = true;
+        break;
       case O_DEBUG:
-       optDebug = true;
-       break;
+        optDebug = true;
+        break;
       case O_TRACE:
-       if ((optTrace = Trace::convertTraceNameToID(optarg)) == Trace::TRACE_INVALID) {
-         phm2if_usage(argv[0]);
-         return (1);
-       }
-       break;
+        if ((optTrace = Trace::convertTraceNameToID(optarg)) == Trace::TRACE_INVALID) {
+          phm2if_usage(argv[0]);
+          return (1);
+        }
+        break;
       case O_FILTER:
-       optFilterName = optarg;
-       break;
+        optFilterName = optarg;
+        break;
       case O_FILTER_DOMAIN:
-       optDomainName = optarg;
-       break;
+        optDomainName = optarg;
+        break;
       case O_DESC:
-       optDesc =  optarg;
-       break;
+        optDesc =  optarg;
+        break;
       case O_FILTER_BW:
-       optFilterBW = strtod(optarg, &endptr);
-       endstr = optarg + strlen(optarg);
-       if (endptr != endstr) {
-         sys_error(ERR_SEVERE,"Error setting --filter-bw to %s\n", optarg);
-         phm2if_usage(argv[0]);
-         return (1);
-       }
-       break;
+        optFilterBW = strtod(optarg, &endptr);
+        endstr = optarg + strlen(optarg);
+        if (endptr != endstr) {
+          sys_error(ERR_SEVERE,"Error setting --filter-bw to %s\n", optarg);
+          phm2if_usage(argv[0]);
+          return (1);
+        }
+        break;
       case O_FILTER_PARAM:
-       optFilterParam = strtod(optarg, &endptr);
-       endstr = optarg + strlen(optarg);
-       if (endptr != endstr) {
-         sys_error(ERR_SEVERE,"Error setting --filter-param to %s\n", optarg);
-         phm2if_usage(argv[0]);
-         return (1);
-       }
-       break;
+        optFilterParam = strtod(optarg, &endptr);
+        endstr = optarg + strlen(optarg);
+        if (endptr != endstr) {
+          sys_error(ERR_SEVERE,"Error setting --filter-param to %s\n", optarg);
+          phm2if_usage(argv[0]);
+          return (1);
+        }
+        break;
       case O_NSAMPLE:
-       opt_nsample = strtol(optarg, &endptr, 10);
-       endstr = optarg + strlen(optarg);
-       if (endptr != endstr) {
-         sys_error(ERR_SEVERE,"Error setting --nsample to %s\n", optarg);
-         phm2if_usage(argv[0]);
-         return (1);
-       }
-       break;
-        case O_VERSION:
+        opt_nsample = strtol(optarg, &endptr, 10);
+        endstr = optarg + strlen(optarg);
+        if (endptr != endstr) {
+          sys_error(ERR_SEVERE,"Error setting --nsample to %s\n", optarg);
+          phm2if_usage(argv[0]);
+          return (1);
+        }
+        break;
+      case O_VERSION:
 #ifdef VERSION
-         std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
+        std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
 #else
-          std::cerr << "Unknown version number\n";
+        std::cerr << "Unknown version number\n";
 #endif
       case O_HELP:
       case '?':
-       phm2if_usage(argv[0]);
-       return (0);
+        phm2if_usage(argv[0]);
+        return (0);
       default:
-       phm2if_usage(argv[0]);
-       return (1);
+        phm2if_usage(argv[0]);
+        return (1);
       }
     }
     
@@ -212,7 +212,7 @@ phm2if_main (int argc, char* argv[])
       phm2if_usage(argv[0]);
       return (1);
     }
-
+    
     if (optind + 3 != argc) {
       phm2if_usage(argv[0]);
       return (1);
@@ -249,27 +249,27 @@ phm2if_main (int argc, char* argv[])
     if (optPhmName != "") {
       phm.createFromPhantom (optPhmName.c_str());
       if (phm.fail()) {
-       std::cout << phm.failMessage() << std::endl << std::endl;
-       phm2if_usage(argv[0]);
-       return (1);
+        std::cout << phm.failMessage() << std::endl << std::endl;
+        phm2if_usage(argv[0]);
+        return (1);
       }
     }
-
+    
     if (optPhmFilename != "") {
       phm.createFromFile(optPhmFilename.c_str());
 #ifdef HAVE_MPI
       if (mpiWorld.getRank() == 0) 
-       std::cerr << "Can't use phantom from file in MPI mode\n";
+        std::cerr << "Can't use phantom from file in MPI mode\n";
       return (1);
 #endif
     }
-
+    
     if (optVerbose)
       std::cout << "Rasterize Phantom to Image\n" << std::endl;
 #ifdef HAVE_MPI
   }
 #endif
-
+  
 #ifdef HAVE_MPI
   TimerCollectiveMPI timerBcast (mpiWorld.getComm());
   mpiWorld.BcastString (optPhmName);
@@ -281,18 +281,18 @@ phm2if_main (int argc, char* argv[])
   mpiWorld.getComm().Bcast (&opt_nsample, 1, MPI::INT, 0);
   mpiWorld.getComm().Bcast (&optFilterParam, 1, MPI::DOUBLE, 0);
   mpiWorld.getComm().Bcast (&optFilterBW, 1, MPI::DOUBLE, 0);
-
+  
   mpiWorld.BcastString (optFilterName);
   mpiWorld.BcastString (optDomainName);
-
+  
   if (optVerbose)
     timerBcast.timerEndAndReport ("Time to broadcast variables");
-
+  
   mpiWorld.setTotalWorkUnits (opt_nx);
-
+  
   if (mpiWorld.getRank() > 0 && optPhmName != "")
-      phm.createFromPhantom (optPhmName.c_str());
-
+    phm.createFromPhantom (optPhmName.c_str());
+  
   if (mpiWorld.getRank() == 0) {
     pImGlobal = new ImageFile (opt_nx, opt_ny);
   }
@@ -300,12 +300,12 @@ phm2if_main (int argc, char* argv[])
 #else
   pImGlobal = new ImageFile (opt_nx, opt_ny);
 #endif
-
+  
   ImageFileArray v = NULL;
 #ifdef HAVE_MPI
   if (mpiWorld.getRank() == 0)
     v = pImGlobal->getArray ();
-
+  
   if (phm.getComposition() == P_UNIT_PULSE) {
     if (mpiWorld.getRank() == 0) {
       v[opt_nx/2][opt_ny/2] = 1.;
@@ -319,7 +319,7 @@ phm2if_main (int argc, char* argv[])
     phm.convertToImagefile (*pImLocal, opt_nsample, optTrace, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits(), false);
     if (optVerbose)
       timerRasterize.timerEndAndReport ("Time to rasterize phantom");
-
+    
     TimerCollectiveMPI timerGather (mpiWorld.getComm());
     mpi_gather_image (mpiWorld, pImGlobal, pImLocal, optDebug);
     if (optVerbose)
@@ -333,13 +333,13 @@ phm2if_main (int argc, char* argv[])
     pImGlobal->filterResponse (optDomainName.c_str(), optFilterBW, optFilterName.c_str(), optFilterParam);
   } else {
 #if HAVE_SGP
-      if (optTrace >= Trace::TRACE_PHANTOM)
-       phm.show();
+    if (optTrace >= Trace::TRACE_PHANTOM)
+      phm.show();
 #endif
-      phm.convertToImagefile (*pImGlobal, opt_nsample, optTrace);
+    phm.convertToImagefile (*pImGlobal, opt_nsample, optTrace);
   }
 #endif
-
+  
 #ifdef HAVE_MPI
   if (mpiWorld.getRank() == 0) 
 #endif
@@ -348,8 +348,8 @@ phm2if_main (int argc, char* argv[])
     pImGlobal->labelAdd (Array2dFileLabel::L_HISTORY, optDesc.c_str(), calctime);
     pImGlobal->fileWrite (optOutFilename.c_str());
     if (optVerbose)
-      std::cout << "Time to rasterized phantom: " << calctime << " seconds\n";
-
+      std::cout << "Time to rasterize phantom: " << calctime << " seconds\n";
+    
     if (optTrace >= Trace::TRACE_PHANTOM) {
       double dmin, dmax;
       int nscale;
@@ -357,17 +357,18 @@ phm2if_main (int argc, char* argv[])
       std::cout << "Enter display size scale (nominal = 1): ";
       std::cin >> nscale;
       std::cout << "Enter minimum and maximum densities (min, max): ";
-      std::cin >> dmin;\r
+      std::cin >> dmin;
+      
       std::cin >> dmax;
       pImGlobal->displayScaling (nscale, dmin, dmax);
     }
   }
-
+  
   delete pImGlobal;
 #ifdef HAVE_MPI
   delete pImLocal;
 #endif
-
+  
   return (0);
 }
 
@@ -379,22 +380,22 @@ void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImL
   ImageFileArray vLocal = pImLocal->getArray();
   ImageFileArray vGlobal = NULL;
   int nyLocal = pImLocal->ny();
-
+  
   if (mpiWorld.getRank() == 0)
     vGlobal = pImGlobal->getArray();
   
   for (int iw = 0; iw < mpiWorld.getMyLocalWorkUnits(); iw++)
     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, pImLocal->getMPIDataType(), iProc, 0, status);
+        MPI::Status status;
+        mpiWorld.getComm().Recv(vGlobal[iw], nyLocal, pImLocal->getMPIDataType(), iProc, 0, status);
       }
     }
   }
-
+  
 }
 #endif
 
@@ -403,7 +404,7 @@ int
 main (int argc, char* argv[])
 {
   int retval = 1;
-
+  
   try {
     retval = phm2if_main(argc, argv);
   } catch (exception e) {
@@ -411,7 +412,7 @@ main (int argc, char* argv[])
   } catch (...) {
     std::cerr << "Unknown exception\n";
   }
-
+  
   return (retval);
 }
 #endif