r120: *** empty log message ***
[ctsim.git] / libctsim / phantom.cpp
index c0804932d1189f931b462b576fad3062357e298a..aff7b5d55d71f1ccd41f1f2633300d2e1c91dc77 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phantom.cpp,v 1.4 2000/06/22 10:17:28 kevin Exp $
+**  $Id: phantom.cpp,v 1.5 2000/06/25 17:32:24 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
@@ -88,7 +88,7 @@ Phantom::convertPhantomIDToName (const PhantomID phmID)
 Phantom::PhantomID
 Phantom::convertNameToPhantomID (const char* const phmName) 
 {
-  PhantomID id;
+  PhantomID id = PHM_INVALID;
 
   if (strcasecmp (phmName, PHM_HERMAN_STR) == 0)
     id = PHM_HERMAN;
@@ -100,8 +100,6 @@ Phantom::convertNameToPhantomID (const char* const phmName)
     id = PHM_BROWLAND;
   else if (strcasecmp (phmName, PHM_UNITPULSE_STR) == 0)
     id = PHM_UNITPULSE;
-  else
-    id = PHM_INVALID;
 
   return (id);
 }
@@ -111,8 +109,14 @@ bool
 Phantom::createFromPhantom (const char* const phmName)
 {
   PhantomID phmid = convertNameToPhantomID (phmName);
-  m_name = phmName;
+  if (phmid == PHM_INVALID) {
+    m_fail = true;
+    m_failMessage = "Invalid phantom name ";
+    m_failMessage += phmName;
+    return false;
+  }
 
+  m_name = phmName;
   createFromPhantom (phmid);
 }
 
@@ -139,11 +143,10 @@ Phantom::createFromPhantom (const PhantomID phmid)
       addPElem ("ellipse", 0., 0., 1., 1., 0., 1.);          // pulse 
       break;
     default:
-      sys_error (ERR_WARNING, "Illegal phantom id %d\n", phmid);
-      m_name += " -- INVALID";
       m_fail = true;
+      m_failMessage = "Illegal phantom id ";
+      m_failMessage += phmid;
       return false;
-      break;
     }
 
   m_id = phmid;