X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fprojections.cpp;h=f6b8cb15a48fd3b3362d79b89505de4740b96271;hp=3c4f956e891c6f0ab2a644703df81a84e3f74a8d;hb=9f29c8b32c972db1178d6f8551d5cd57ceb67083;hpb=acd157c5e61e2eeba8308a49b4d7fc4a4aba9a84 diff --git a/libctsim/projections.cpp b/libctsim/projections.cpp index 3c4f956..f6b8cb1 100644 --- a/libctsim/projections.cpp +++ b/libctsim/projections.cpp @@ -6,9 +6,9 @@ ** Date Started: Aug 84 ** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg +** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: projections.cpp,v 1.39 2001/01/07 22:53:36 kevin Exp $ +** $Id: projections.cpp,v 1.46 2001/01/28 19:10:18 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 @@ -404,10 +404,16 @@ Projections::copyViewData (const std::string& filename, std::ostream& os, int st bool Projections::copyViewData (const char* const filename, std::ostream& os, int startView, int endView) { - frnetorderstream is (filename, ios::in | ios::binary); + frnetorderstream is (filename, std::ios::in | std::ios::binary); kuint16 sizeHeader, signature; kuint32 _nView, _nDet; + is.seekg (0); + if (is.fail()) { + sys_error (ERR_SEVERE, "Unable to read projection file %s", filename); + return false; + } + is.readInt16 (sizeHeader); is.readInt16 (signature); is.readInt32 (_nView); @@ -416,7 +422,7 @@ Projections::copyViewData (const char* const filename, std::ostream& os, int sta int nDet = _nDet; if (signature != m_signature) { - sys_error (ERR_FATAL, "Illegal signature in projection file %s", filename); + sys_error (ERR_SEVERE, "Illegal signature in projection file %s", filename); return false; } @@ -446,9 +452,9 @@ Projections::copyViewData (const char* const filename, std::ostream& os, int sta delete pViewData; if (is.fail()) - sys_error (ERR_FATAL, "Error reading projection file"); + sys_error (ERR_SEVERE, "Error reading projection file"); if (os.fail()) - sys_error (ERR_FATAL, "Error writing projection file"); + sys_error (ERR_SEVERE, "Error writing projection file"); return (! (is.fail() | os.fail())); } @@ -468,20 +474,20 @@ Projections::copyHeader (const char* const filename, std::ostream& os) is.readInt16 (signature); is.seekg (0); if (signature != m_signature) { - sys_error (ERR_FATAL, "Illegal signature in projection file %s", filename); + sys_error (ERR_SEVERE, "Illegal signature in projection file %s", filename); return false; } unsigned char* pHdrData = new unsigned char [sizeHeader]; is.read (reinterpret_cast(pHdrData), sizeHeader); if (is.fail()) { - sys_error (ERR_FATAL, "Error reading header"); + sys_error (ERR_SEVERE, "Error reading header"); return false; } os.write (reinterpret_cast(pHdrData), sizeHeader); if (os.fail()) { - sys_error (ERR_FATAL, "Error writing header"); + sys_error (ERR_SEVERE, "Error writing header"); return false; } @@ -631,6 +637,8 @@ Projections::printProjectionData (int startView, int endView) if (m_projData != NULL) { if (startView < 0) startView = 0; + if (endView < 0) + endView = m_nView - 1; if (startView > m_nView - 1) startView = m_nView - 1; if (endView > m_nView - 1) @@ -681,7 +689,8 @@ Projections::convertPolar (ImageFile& rIF, int iInterpolationID) calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet); std::complex** ppcDetValue = new std::complex* [m_nView]; - for (unsigned int iView = 0; iView < m_nView; iView++) { + unsigned int iView; + for (iView = 0; iView < m_nView; iView++) { ppcDetValue[iView] = new std::complex [m_nDet]; for (unsigned int iDet = 0; iDet < m_nDet; iDet++) ppcDetValue[iView][iDet] = std::complex(getDetectorArray (iView).detValues()[iDet], 0); @@ -710,6 +719,9 @@ Projections::convertFFTPolar (ImageFile& rIF, int iInterpolationID, int iZeropad if (! v || nx == 0 || ny == 0) return false; +#ifndef HAVE_FFT + return false; +#else Array2d adView (nx, ny); Array2d adDet (nx, ny); double** ppdView = adView.getArray(); @@ -746,6 +758,7 @@ Projections::convertFFTPolar (ImageFile& rIF, int iInterpolationID, int iZeropad delete [] ppcDetValue; return true; +#endif } @@ -812,9 +825,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(ppdView[ix][iy]); double dFracView = ppdView[ix][iy] - iFloorView; - int iFloorDet = ppdDet[ix][iy]; + int iFloorDet = static_cast(ppdDet[ix][iy]); double dFracDet = ppdDet[ix][iy] - iFloorDet; if (iFloorDet >= 0 && iFloorView >= 0) {