r499: no message
[ctsim.git] / libctsim / phantom.cpp
index 0a9f53ecce76d2456079aeb9a100763894552ed0..fea8e6e55aa1b7790a8d4eb9ad9a2b0d9df2803b 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: phantom.cpp,v 1.27 2001/01/28 19:10:18 kevin Exp $
+**  $Id: phantom.cpp,v 1.28 2001/02/08 06:25:07 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
@@ -82,7 +82,6 @@ Phantom::init ()
   m_xmax = -1E30;
   m_ymin = 1E30;
   m_ymax = -1E30;
-  m_diameter = 0;
   m_composition = P_PELEMS;
   m_fail = false;
   m_id = PHM_INVALID;
@@ -261,11 +260,6 @@ Phantom::addPElem (const char *type, const double cx, const double cy, const dou
   if (m_ymin > pelem->ymin())    m_ymin = pelem->ymin();
   if (m_ymax < pelem->ymax())    m_ymax = pelem->ymax();
 
-  if (m_diameter < pelem->diameter())
-    m_diameter = pelem->diameter();
-
-  //  m_diameter = lineLength(m_xmin, m_ymin, m_xmax, m_ymax);
-
   m_nPElem++;
 }
 
@@ -472,13 +466,13 @@ Phantom::addStdHermanBordered ()
  */
 
 void
-Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trace) const
+Phantom::convertToImagefile (ImageFile& im, double dViewRatio, const int in_nsample, const int trace) const
 {
-  convertToImagefile (im, in_nsample, trace, 0, im.nx(), true);
+  convertToImagefile (im, dViewRatio, in_nsample, trace, 0, im.nx(), true);
 }
 
 void 
-Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trace, const int colStart, const int colCount, bool bStoreAtColumnPos) const
+Phantom::convertToImagefile (ImageFile& im, const double dViewRatio, const int in_nsample, const int trace, const int colStart, const int colCount, bool bStoreAtColumnPos) const
 {
   int nx = im.nx();
   int ny = im.ny();
@@ -493,14 +487,12 @@ Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trac
   double dy = m_ymax - m_ymin;
   double xcent = m_xmin + dx / 2;
   double ycent = m_ymin + dy / 2;
-  double phmlen = (dx > dy ? dx : dy);
-
-  double phmradius = phmlen / 2;
+  double dHalflen = dViewRatio * (getDiameterBoundaryCircle() / SQRT2 / 2);
 
-  double xmin = xcent - phmradius;
-  double xmax = xcent + phmradius;
-  double ymin = ycent - phmradius;
-  double ymax = ycent + phmradius;
+  double xmin = xcent - dHalflen;
+  double xmax = xcent + dHalflen;
+  double ymin = ycent - dHalflen;
+  double ymax = ycent + dHalflen;
 
   // Each pixel holds the average of the intensity of the cell with (ix,iy) at the center of the pixel
   // Set major increments so that the last cell v[nx-1][ny-1] will start at xmax - xinc, ymax - yinc).
@@ -581,15 +573,6 @@ PhantomElement::PhantomElement (const char *type, const double cx, const double
   makeTransformMatrices ();     // calc transform matrices between phantom and normalized phantomelement
   makeVectorOutline ();                // calculate vector outline of pelem 
 
-  // Find maximum diameter of Object
-  double r2Max = 0;
-  for (int i = 0; i < m_nPoints; i++) {
-    double r2 = (m_xOutline[i] * m_xOutline[i]) + (m_yOutline[i] * m_yOutline[i]);
-    if (r2 > r2Max)
-      r2Max = r2;
-  }
-  m_diameter = 2 * sqrt( r2Max );
-
   m_rectLimits[0] = m_xmin;   m_rectLimits[1] = m_ymin;
   m_rectLimits[2] = m_xmax;   m_rectLimits[3] = m_ymax;
 }