** 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.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
#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
* 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)
if ((nDet % 2) == 0)
++nDet; // ensure odd number of detectors
- m_geometry = geometry;
m_nDet = nDet;
m_nView = nView;
m_nSample = nSample;
}
+const char*
+Scanner::convertGeometryIDToName (const int geomID)
+{
+ const char *name = "";
+
+ if (geomID >= 0 && geomID < s_iGeometryCount)
+ return (s_aszGeometryName[geomID]);
+
+ 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
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);