r150: *** empty log message ***
[ctsim.git] / libctsim / phantom.cpp
index 7acfc3fc9ccba40168f889867ed5b404b04bd299..d07b6a32eae0035242d8c467b5838a55e066655f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phantom.cpp,v 1.7 2000/07/15 08:36:13 kevin Exp $
+**  $Id: phantom.cpp,v 1.8 2000/07/18 03:14:35 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
@@ -451,19 +451,24 @@ Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trac
 
   ImageFileArray v = im.getArray();
 
+  for (int ix = 0; ix < colCount; ix++)
+      for (int iy = 0; iy < ny; iy++)
+         v[ix][iy] = 0;
+
   double x_start = xmin + (colStart * xinc);
   for (PElemConstIterator pelem = m_listPElem.begin(); pelem != m_listPElem.end(); pelem++) {
-    double x, y, xi, yi;
-    int ix, iy, kx, ky;
-    for (ix = 0, x = x_start; ix < colCount; ix++, x += xinc) {
-      for (iy = 0, y = ymin; iy < ny; iy++, y += yinc) {
-       for (kx = 0, xi = x + kxofs; kx < nsample; kx++, xi += kxinc) {
-         for (ky = 0, yi = y + kyofs; ky < nsample; ky++, yi += kyinc)
-           if ((*pelem)->isPointInside (xi, yi, PHM_COORD) == TRUE)
-             v[ix][iy] += (*pelem)->atten();
-       } // for kx
-      } /* for iy */
-    }  /* for ix */
+      const PhantomElement& rPElem = **pelem;
+      double x, y, xi, yi;
+      int ix, iy, kx, ky;
+      for (ix = 0, x = x_start; ix < colCount; ix++, x += xinc) {
+         for (iy = 0, y = ymin; iy < ny; iy++, y += yinc) {
+             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[ix][iy] += rPElem.atten();
+             } // for kx
+         } /* for iy */
+      }  /* for ix */
   }  /* for pelem */
   
 
@@ -822,7 +827,7 @@ PhantomElement::clipLineNormalizedCoords (double& x1, double& y1, double& x2, do
 //    false if point lies outside of pelem
 
 bool
-PhantomElement::isPointInside (double x, double y, const CoordType coord_type)
+PhantomElement::isPointInside (double x, double y, const CoordType coord_type) const
 {
   if (coord_type == PHM_COORD) {
     xform_mtx2 (m_xformPhmToObj, x, y);