r11859: Canonicalize whitespace
[ctsim.git] / tools / if2.cpp
index b2105e28dc26fe6a0af5bb348bfa84f177f32192..a9900b9d3fe21cba5dfdb72b84e957cf2eb5b336 100644 (file)
@@ -48,7 +48,7 @@ static struct option my_options[] =
 
 static const char* g_szIdStr = "$Id$";
 
-void 
+void
 if2_usage (const char *program)
 {
   std::cout << "usage: " << fileBasename(program) << " infile1 infile2 outfile [OPTIONS]\n";
@@ -68,7 +68,7 @@ if2_usage (const char *program)
   std::cout << "     --help             Print this help message\n";
 }
 
-int 
+int
 if2_main (int argc, char *const argv[])
 {
   ImageFile* pim_in1;
@@ -88,14 +88,14 @@ if2_main (int argc, char *const argv[])
   int opt_rowPlot = -1;
   int opt_columnPlot = -1;
   Timer timerProgram;
-  
+
   while (1) {
     char* endptr;
     int c = getopt_long (argc, argv, "", my_options, NULL);
-    
+
     if (c == -1)
       break;
-    
+
     switch (c) {
     case O_ADD:
       opt_add = 1;
@@ -149,7 +149,7 @@ if2_main (int argc, char *const argv[])
       return (1);
     }
   }
-  
+
   if ((opt_bImageOutputFile || opt_bPlotOutputFile) && (optind + 3 != argc)) {
     if2_usage(argv[0]);
     return (1);
@@ -158,22 +158,22 @@ if2_main (int argc, char *const argv[])
     if2_usage(argv[0]);
     return (1);
   }
-  
+
   in_file1 = argv[optind];
   in_file2 = argv[optind + 1];
   if (opt_bImageOutputFile || opt_bPlotOutputFile)
     strOutFile = argv[optind + 2];
-  
+
   pim_in1 = new ImageFile ();
   pim_in2 = new ImageFile ();
   ImageFile& im_in1 = *pim_in1;
   ImageFile& im_in2 = *pim_in2;
-  
+
   if (! im_in1.fileRead(in_file1) || ! im_in2.fileRead(in_file2)) {
     sys_error (ERR_WARNING, "Error reading an image");
     return (1);
   }
-  
+
   if (im_in1.nx() != im_in2.nx() || im_in1.ny() != im_in2.ny()) {
     sys_error (ERR_SEVERE, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match",
       im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
@@ -183,11 +183,11 @@ if2_main (int argc, char *const argv[])
     sys_error (ERR_SEVERE, "Error: Size of image < 0");
     return(1);
   }
-  
+
   ImageFileArray v1 = im_in1.getArray();
   ImageFileArray v2 = im_in2.getArray();
   ImageFileArray vout = NULL;
-  
+
   if (opt_bImageOutputFile && opt_bPlotOutputFile) {
     sys_error (ERR_SEVERE, "Both Image and Plot output files can not be selected simultaneously");
     return (1);
@@ -196,13 +196,13 @@ if2_main (int argc, char *const argv[])
     pim_out = new ImageFile (im_in1.nx(), im_in1.ny());
     vout = pim_out->getArray();
   }
-  
+
   std::string strOperation;
   int nx = im_in1.nx();
   int ny = im_in1.ny();
   int nx2 = im_in2.nx();
   int ny2 = im_in2.ny();
-  
+
   if (opt_add) {
     strOperation = "Add Images";
     im_in1.addImages (im_in2, *pim_out);
@@ -221,7 +221,7 @@ if2_main (int argc, char *const argv[])
     im_in1.comparativeStatistics (im_in2, d, r, e);
     std::cout << "d=" << d << ", r=" << r << ", e=" << e << std::endl;
   }
-  
+
   int i;
   if (opt_columnPlot > 0) {
     if (opt_columnPlot >= nx || opt_columnPlot >= nx2) {
@@ -231,9 +231,9 @@ if2_main (int argc, char *const argv[])
     double* plot_xaxis = new double [nx];
     for (i = 0; i < nx; i++)
       plot_xaxis[i] = i;
-    
+
     PlotFile plotFile (3, nx);
-    
+
     plotFile.addColumn (0, plot_xaxis);
     plotFile.addColumn (1, v1[opt_columnPlot]);
     plotFile.addColumn (2, v2[opt_columnPlot]);
@@ -250,10 +250,10 @@ if2_main (int argc, char *const argv[])
     plotFile.addEzsetCommand ("xticks major 5");
 
     plotFile.fileWrite (strOutFile.c_str());
-    
+
     delete plot_xaxis;
   }
-  
+
   if (opt_rowPlot > 0) {
     if (opt_rowPlot >= ny || opt_rowPlot >= ny2) {
       sys_error (ERR_SEVERE, "row_plot > ny");
@@ -262,16 +262,16 @@ if2_main (int argc, char *const argv[])
     double* plot_xaxis = new double [ny];
     double* v1Row = new double [ny];
     double* v2Row = new double [ny2];
-    
+
     for (i = 0; i < ny; i++)
       plot_xaxis[i] = i;
     for (i = 0; i < ny; i++)
       v1Row[i] = v1[i][opt_rowPlot];
     for (i = 0; i < ny2; i++)
       v2Row[i] = v2[i][opt_rowPlot];
-    
+
     PlotFile plotFile (3, ny);
-    
+
     plotFile.addColumn (0, plot_xaxis);
     plotFile.addColumn (1, v1Row);
     plotFile.addColumn (2, v2Row);
@@ -286,30 +286,30 @@ if2_main (int argc, char *const argv[])
     plotFile.addEzsetCommand ("box");
     plotFile.addEzsetCommand ("grid");
     plotFile.addEzsetCommand ("xticks major 5");
-    
+
     plotFile.fileWrite (strOutFile.c_str());
-    
+
     delete plot_xaxis;
     delete v1Row;
     delete v2Row;
   }
-  
+
   if (opt_bImageOutputFile) {
     pim_out->labelsCopy (im_in1, "if2 file 1: ");
     pim_out->labelsCopy (im_in2, "if2 file 2: ");
     pim_out->labelAdd (Array2dFileLabel::L_HISTORY, strOperation.c_str(), timerProgram.timerEnd());
     pim_out->fileWrite (strOutFile);
   }
-  
+
   return (0);
 }
 
 #ifndef NO_MAIN
-int 
+int
 main (int argc, char *const argv[])
 {
   int retval = 1;
-  
+
   try {
     retval = if2_main(argc, argv);
   } catch (exception e) {
@@ -317,7 +317,7 @@ main (int argc, char *const argv[])
   } catch (...) {
     std::cerr << "Unknown exception\n";
   }
-  
+
   return (retval);
 }
 #endif