X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=libctsim%2Fscanner.cpp;h=4f46d05161b7a9f6a51c5b259eafa93636bb1da9;hb=27a474e0622ebb7229fd5705552021f63d8f932d;hp=1d7eaf71bb4110c0982b8c34e173addeb9a88c7e;hpb=99dd1d6ed10db1f669a5fe6af71225a50fc0ddfb;p=ctsim.git diff --git a/libctsim/scanner.cpp b/libctsim/scanner.cpp index 1d7eaf7..4f46d05 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.4 2000/07/20 11:17:31 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 @@ -27,6 +27,13 @@ #include "ct.h" +const char Scanner::GEOMETRY_PARALLEL_STR[] = "parallel"; +const char Scanner::GEOMETRY_EQUILINEAR_STR[] = "equilinear"; +const char Scanner::GEOMETRY_EQUIANGULAR_STR[] = "equiangular"; + +const char Scanner::GEOMETRY_PARALLEL_TITLE_STR[] = "Parallel"; +const char Scanner::GEOMETRY_EQUILINEAR_TITLE_STR[] = "Equilinear"; +const char Scanner::GEOMETRY_EQUIANGULAR_TITLE_STR[] = "Equiangular"; // NAME // DetectorArray Construct a DetectorArray @@ -60,10 +67,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 +89,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 +116,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_EQUIANGULAR_STR) == 0) + geometryID = GEOMETRY_EQUIANGULAR; + + return (geometryID); +} + + /* NAME * raysum_collect Calculate ray sums for a Phantom @@ -281,7 +312,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);