r310: plotfile updates
[ctsim.git] / libctsim / phantom.cpp
index 6058ce77e947c6789bb8919088d54b1b8d25474a..9125e36be718af7ea36959b42bf5461cd673f0ab 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phantom.cpp,v 1.20 2000/12/04 05:36:57 kevin Exp $
+**  $Id: phantom.cpp,v 1.23 2000/12/21 03:40:58 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
@@ -27,8 +27,8 @@
 
 #include "ct.h"
 
-const int Phantom::POINTS_PER_CIRCLE = 360;\r
-const double Phantom::SCALE_PELEM_EXTENT=0.005;  // increase pelem limits by 0.5% \r
+const int PhantomElement::POINTS_PER_CIRCLE = 360;\r
+const double PhantomElement::SCALE_PELEM_EXTENT=0.005;  // increase pelem limits by 0.5% \r
 
 const int Phantom::PHM_INVALID = -1;
 const int Phantom::PHM_HERMAN = 0;
@@ -311,7 +311,7 @@ Phantom::show () const
 
   show (sgp);
 
-  cout << "Press return to continue";
+  std::cout << "Press return to continue";
   cio_kb_getc();
 }
 
@@ -482,7 +482,7 @@ Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trac
     for (int iy = 0; iy < ny; iy++) {
       int iColStore = ix;
       if (bStoreAtColumnPos)
-       iColStore += colStart;
+               iColStore += colStart;
       v[iColStore][iy] = 0;
     }
 
@@ -499,7 +499,7 @@ Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trac
          for (kx = 0, xi = x + kxofs; kx < nsample; kx++, xi += kxinc) {
            for (ky = 0, yi = y + kyofs; ky < nsample; ky++, yi += kyinc)
              if (rPElem.isPointInside (xi, yi, PHM_COORD) == TRUE)
-               v[iColStore][iy] += rPElem.atten();
+                       v[iColStore][iy] += rPElem.atten();
              } // for kx
          } /* for iy */
       }  /* for ix */
@@ -507,11 +507,16 @@ Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trac
   
 
   if (nsample > 1) {
-    double factor = 1.0 / (nsample * nsample);
-
-    for (int ix = 0; ix < colCount; ix++)
-      for (int iy = 0; iy < ny; iy++)
-       v[ix][iy] *= factor;
+    double factor = 1.0 / static_cast<double>(nsample * nsample);
+
+\r
+    for (int ix = 0; ix < colCount; ix++) {
+               int iColStore = ix;\r
+               if (bStoreAtColumnPos)\r
+                       iColStore += colStart;\r
+               for (int iy = 0; iy < ny; iy++)
+                       v[iColStore][iy] *= factor;\r
+       }
   }
 }