X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=libctsim%2Fscanner.cpp;h=ae665f207894f1e43e790c577969029a446b7443;hb=c4af77faf7f216b936f0782e918634d34980c63f;hp=6ebb04e65b5c14f5772e0daf924c7a9c61584dce;hpb=08f34bf3ba14d4f436f4d2ef0ee5af1d6eb266ac;p=ctsim.git diff --git a/libctsim/scanner.cpp b/libctsim/scanner.cpp index 6ebb04e..ae665f2 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.2 2000/06/25 17:32:24 kevin Exp $ +** $Id: scanner.cpp,v 1.5 2000/07/22 15:45:33 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 @@ -28,6 +28,28 @@ #include "ct.h" +const int Scanner::GEOMETRY_INVALID = -1; +const int Scanner::GEOMETRY_PARALLEL = 0; +const int Scanner::GEOMETRY_EQUILINEAR = 1; +const int Scanner::GEOMETRY_EQUIANGULAR = 2; + +const char* Scanner::s_aszGeometryName[] = +{ + {"parallel"}, + {"equilinear"}, + {"equiangular"}, +}; + +const char* Scanner::s_aszGeometryTitle[] = +{ + {"Parallel"}, + {"Equilinear"}, + {"Equiangular"}, +}; + +const int Scanner::s_iGeometryCount = sizeof(s_aszGeometryName) / sizeof(const char*); + + // NAME // DetectorArray Construct a DetectorArray @@ -109,22 +131,42 @@ Scanner::~Scanner (void) } -Scanner::GeometryID -Scanner::convertGeometryNameToID (const char* const geometryName) +const char* +Scanner::convertGeometryIDToName (const int geomID) { - GeometryID geometryID = GEOMETRY_INVALID; + const char *name = ""; - 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; + if (geomID >= 0 && geomID < s_iGeometryCount) + return (s_aszGeometryName[geomID]); - return (geometryID); + return (name); } +const char* +Scanner::convertGeometryIDToTitle (const int geomID) +{ + const char *title = ""; + + if (geomID >= 0 && geomID < s_iGeometryCount) + return (s_aszGeometryName[geomID]); + return (title); +} + +int +Scanner::convertGeometryNameToID (const char* const geomName) +{ + int id = GEOMETRY_INVALID; + + for (int i = 0; i < s_iGeometryCount; i++) + if (strcasecmp (geomName, s_aszGeometryName[i]) == 0) { + id = i; + break; + } + + return (id); +} + /* NAME * raysum_collect Calculate ray sums for a Phantom @@ -305,7 +347,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);