r158: *** empty log message ***
[ctsim.git] / libctsim / scanner.cpp
index 4f46d05161b7a9f6a51c5b259eafa93636bb1da9..ae665f207894f1e43e790c577969029a446b7443 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: scanner.cpp,v 1.4 2000/07/20 11:17:31 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 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";
+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
@@ -116,22 +131,42 @@ Scanner::~Scanner (void)
 }
 
 
-Scanner::GeometryID 
-Scanner::convertGeometryNameToID (const char* const geometryName)
+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)
 {
-  GeometryID geometryID = GEOMETRY_INVALID;
+  const char *title = "";
 
-  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;
+  if (geomID >= 0 && geomID < s_iGeometryCount)
+      return (s_aszGeometryName[geomID]);
 
-  return (geometryID);
+  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