X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fscanner.cpp;h=53588db67b9ff9d047d87c18ed2145a2a4449bb0;hp=1d7eaf71bb4110c0982b8c34e173addeb9a88c7e;hb=3fba6928127cd65870bdcd96c8114ad5894247ae;hpb=99dd1d6ed10db1f669a5fe6af71225a50fc0ddfb diff --git a/libctsim/scanner.cpp b/libctsim/scanner.cpp index 1d7eaf7..53588db 100644 --- a/libctsim/scanner.cpp +++ b/libctsim/scanner.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: scanner.cpp,v 1.1 2000/06/19 02:59:34 kevin Exp $ +** $Id: scanner.cpp,v 1.3 2000/07/13 07:03:21 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 @@ -60,10 +60,19 @@ DetectorArray::~DetectorArray (void) * int nSample Number of rays per detector */ -Scanner::Scanner (const Phantom& phm, const ScannerGeometry geometry, int nDet, int nView, int nSample, const double rot_anglen) +Scanner::Scanner (const Phantom& phm, const char* const geometryName, int nDet, int nView, int nSample, const double rot_anglen) { m_phmLen = phm.maxAxisLength(); // maximal length along an axis + m_fail = false; + m_idGeometry = convertGeometryNameToID (geometryName); + if (m_idGeometry == GEOMETRY_INVALID) { + m_fail = true; + m_failMessage = "Invalid geometry name "; + m_failMessage += geometryName; + return; + } + if (nView < 1) nView = 1; if (nSample < 1) @@ -73,7 +82,6 @@ Scanner::Scanner (const Phantom& phm, const ScannerGeometry geometry, int nDet, if ((nDet % 2) == 0) ++nDet; // ensure odd number of detectors - m_geometry = geometry; m_nDet = nDet; m_nView = nView; m_nSample = nSample; @@ -101,6 +109,22 @@ Scanner::~Scanner (void) } +Scanner::GeometryID +Scanner::convertGeometryNameToID (const char* const geometryName) +{ + GeometryID geometryID = GEOMETRY_INVALID; + + if (strcasecmp (geometryName, GEOMETRY_PARALLEL_STR) == 0) + geometryID = GEOMETRY_PARALLEL; + else if (strcasecmp (geometryName, GEOMETRY_EQUILINEAR_STR) == 0) + geometryID = GEOMETRY_EQUILINEAR; + else if (strcasecmp (geometryName, GEOMETRY_EQUIANGLE_STR) == 0) + geometryID = GEOMETRY_EQUIANGLE; + + return (geometryID); +} + + /* NAME * raysum_collect Calculate ray sums for a Phantom @@ -281,7 +305,7 @@ Scanner::projectSingleView (const Phantom& phm, DetectorArray& detArray, const d double xs = xs_maj; double ys = ys_maj; double sum = 0.0; - for (int i = 0; i < m_nSample; i++) { + for (unsigned int i = 0; i < m_nSample; i++) { #ifdef HAVE_SGP if (m_trace >= TRACE_RAYS) { sgp2_move_abs (xs, ys);