r360: no message
[ctsim.git] / libctsim / projections.cpp
index 22171504420064543e7d958bb168e461f9f9f79c..846daf3f03ea8f9ef45f67acbe8bd2954f7376d0 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: projections.cpp,v 1.38 2001/01/06 15:33:15 kevin Exp $
+**  $Id: projections.cpp,v 1.41 2001/01/07 23:18:13 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
@@ -710,6 +710,9 @@ Projections::convertFFTPolar (ImageFile& rIF, int iInterpolationID, int iZeropad
   if (! v || nx == 0 || ny == 0)
     return false;
   
+#ifndef HAVE_FFT
+  return false;
+#else
   Array2d<double> adView (nx, ny);
   Array2d<double> adDet (nx, ny);
   double** ppdView = adView.getArray();
@@ -722,16 +725,16 @@ Projections::convertFFTPolar (ImageFile& rIF, int iInterpolationID, int iZeropad
   fftw_plan plan = fftw_create_plan (m_nDet, FFTW_FORWARD, FFTW_IN_PLACE);
 
   for (iView = 0; iView < m_nView; iView++) {
-    ppcDetValue[iView] = new std::complex<double> [m_nDet];
     unsigned int iDet;
     for (iDet = 0; iDet < m_nDet; iDet++) {
       pcIn[iDet].re = getDetectorArray(iView).detValues()[iDet];
       pcIn[iDet].im = 0;
     }
     fftw_one (plan, pcIn, NULL);
+    ppcDetValue[iView] = new std::complex<double> [m_nDet];
     for (iDet = 0; iDet < m_nDet; iDet++)
-      ppcDetValue[iView][iDet] = std::complex<double> (pcIn[iDet].re, pcIn[iDet].im);
-   Fourier::shuffleFourierToNaturalOrder (ppcDetValue[iView], m_nDet);
+      ppcDetValue[iView][iDet] = std::complex<double> (pcIn[iDet].re, pcIn[iDet].im); 
+    Fourier::shuffleFourierToNaturalOrder (ppcDetValue[iView], m_nDet);
   }
 
   fftw_destroy_plan (plan);  
@@ -746,8 +749,10 @@ Projections::convertFFTPolar (ImageFile& rIF, int iInterpolationID, int iZeropad
   delete [] ppcDetValue;
 
   return true;
+#endif
 }
 
+
 void
 Projections::calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double** ppdView, double** ppdDet)
 {
@@ -763,8 +768,10 @@ Projections::calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double
 
   if (m_geometry != Scanner::GEOMETRY_PARALLEL) {
     sys_error (ERR_WARNING, "convertPolar supports Parallel only");
+    return;
   }
   
+  // Calculates polar coordinates (view#, det#) for each point on phantom grid
   double x = xMin + xInc / 2;  // Rectang coords of center of pixel 
   for (unsigned int ix = 0; ix < nx; x += xInc, ix++) {
     double y = yMin + yInc / 2;
@@ -809,9 +816,9 @@ Projections::interpolatePolar (ImageFileArray& v, ImageFileArray& vImag,
           v[ix][iy] = 0;
         }
       } else if (iInterpolationID == POLAR_INTERP_BILINEAR) {
-        int iFloorView = ppdView[ix][iy];
+        int iFloorView = static_cast<int>(ppdView[ix][iy]);
         double dFracView = ppdView[ix][iy] - iFloorView;
-        int iFloorDet = ppdDet[ix][iy];
+        int iFloorDet = static_cast<int>(ppdDet[ix][iy]);
         double dFracDet = ppdDet[ix][iy] - iFloorDet;
 
         if (iFloorDet >= 0 && iFloorView >= 0) {