r11859: Canonicalize whitespace
[ctsim.git] / tools / phm2if.cpp
index 98eb4aeadaa290ed57eb69d63cb188256a12f67e..ab3115107b8998ec4b235a91886bc9ff3291d233 100644 (file)
 #include "timer.h"
 
 
-enum { O_PHANTOM, O_DESC, O_NSAMPLE, O_FILTER, O_VIEW_RATIO, O_TRACE, O_VERBOSE, O_HELP, 
+enum { O_PHANTOM, O_DESC, O_NSAMPLE, O_FILTER, O_VIEW_RATIO, O_TRACE, O_VERBOSE, O_HELP,
 O_PHMFILE, O_FILTER_DOMAIN, O_FILTER_BW, O_FILTER_PARAM, O_DEBUG, O_VERSION };
 
-static struct option my_options[] = 
+static struct option my_options[] =
 {
   {"phantom", 1, 0, O_PHANTOM},
   {"phmfile", 1, 0, O_PHMFILE},
@@ -53,7 +53,7 @@ static struct option my_options[] =
 
 static const char* g_szIdStr = "$Id$";
 
-void 
+void
 phm2if_usage (const char *program)
 {
   std::cout << "phm2if_usage: " << fileBasename(program) << " outfile nx ny [--phantom phantom-name] [--phmfile filename] [--filter filter-name] [OPTIONS]\n";
@@ -99,7 +99,7 @@ phm2if_usage (const char *program)
 void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImLocal, const int optDebug);
 #endif
 
-int 
+int
 phm2if_main (int argc, char* const argv[])
 {
   ImageFile* pImGlobal = NULL;
@@ -122,7 +122,7 @@ phm2if_main (int argc, char* const argv[])
   char *endptr = NULL;
   char *endstr;
   Timer timerProgram;
-  
+
 #ifdef HAVE_MPI
   ImageFile* pImLocal = NULL;
   MPIWorld mpiWorld (argc, argv);
@@ -132,7 +132,7 @@ phm2if_main (int argc, char* const argv[])
       int c = getopt_long(argc, argv, "", my_options, NULL);
       if (c == -1)
         break;
-      
+
       switch (c) {
       case O_PHANTOM:
         optPhmName = optarg;
@@ -212,13 +212,13 @@ phm2if_main (int argc, char* const argv[])
         return (1);
       }
     }
-    
+
     if (optPhmName == "" && optFilterName == "" && optPhmFilename == "") {
       std::cerr << "No phantom defined\n" << std::endl;
       phm2if_usage(argv[0]);
       return (1);
     }
-    
+
     if (optind + 3 != argc) {
       phm2if_usage(argv[0]);
       return (1);
@@ -238,7 +238,7 @@ phm2if_main (int argc, char* const argv[])
       phm2if_usage(argv[0]);
       return (1);
     }
-    
+
     std::ostringstream oss;
     oss << "phm2if: nx=" << opt_nx << ", ny=" << opt_ny << ", viewRatio=" << optViewRatio << ", nsample=" << opt_nsample << ", ";
     if (optPhmFilename != "")
@@ -251,7 +251,7 @@ phm2if_main (int argc, char* const argv[])
     if (optDesc != "")
       oss << ": " << optDesc;
     optDesc = oss.str();
-    
+
     if (optPhmName != "") {
       phm.createFromPhantom (optPhmName.c_str());
       if (phm.fail()) {
@@ -260,22 +260,22 @@ phm2if_main (int argc, char* const argv[])
         return (1);
       }
     }
-    
+
     if (optPhmFilename != "") {
       phm.createFromFile(optPhmFilename.c_str());
 #ifdef HAVE_MPI
-      if (mpiWorld.getRank() == 0) 
+      if (mpiWorld.getRank() == 0)
         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);
@@ -288,18 +288,18 @@ phm2if_main (int argc, char* const argv[])
   mpiWorld.getComm().Bcast (&optViewRatio, 1, MPI::DOUBLE, 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());
-  
+
   if (mpiWorld.getRank() == 0) {
     pImGlobal = new ImageFile (opt_nx, opt_ny);
   }
@@ -307,12 +307,12 @@ phm2if_main (int argc, char* const 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.;
@@ -326,7 +326,7 @@ phm2if_main (int argc, char* const argv[])
     phm.convertToImagefile (*pImLocal, optViewRatio, 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)
@@ -342,9 +342,9 @@ phm2if_main (int argc, char* const argv[])
     phm.convertToImagefile (*pImGlobal, optViewRatio, opt_nsample, optTrace);
   }
 #endif
-  
+
 #ifdef HAVE_MPI
-  if (mpiWorld.getRank() == 0) 
+  if (mpiWorld.getRank() == 0)
 #endif
   {
     double calctime = timerProgram.timerEnd ();
@@ -353,12 +353,12 @@ phm2if_main (int argc, char* const argv[])
     if (optVerbose)
       std::cout << "Time to rasterize phantom: " << calctime << " seconds\n";
   }
-  
+
   delete pImGlobal;
 #ifdef HAVE_MPI
   delete pImLocal;
 #endif
-  
+
   return (0);
 }
 
@@ -370,13 +370,13 @@ 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++) {
@@ -385,16 +385,16 @@ void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImL
       }
     }
   }
-  
+
 }
 #endif
 
 #ifndef NO_MAIN
-int 
+int
 main (int argc, char* argv[])
 {
   int retval = 1;
-  
+
   try {
     retval = phm2if_main(argc, argv);
   } catch (exception e) {
@@ -402,7 +402,7 @@ main (int argc, char* argv[])
   } catch (...) {
     std::cerr << "Unknown exception\n";
   }
-  
+
   return (retval);
 }
 #endif