r7061: initial property settings
[ctsim.git] / libctsim / phantom.cpp
index dff1d0ee6bcc137ab1257d31d828921ffc937f96..1a8c6b174aab01003667fd01e187a8a7a81fd752 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: phantom.cpp,v 1.30 2001/02/27 03:59:30 kevin Exp $
+**  $Id$
 **
 **  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,7 +28,8 @@
 #include "ct.h"
 
 const int PhantomElement::POINTS_PER_CIRCLE = 360;
-const double PhantomElement::SCALE_PELEM_EXTENT=0.005;  // increase pelem limits by 0.5% 
+const double PhantomElement::SCALE_PELEM_EXTENT=0.000;  // increase pelem limits by 0.5% 
+//const double PhantomElement::SCALE_PELEM_EXTENT=0.005;  // increase pelem limits by 0.5% 
 
 const int Phantom::PHM_INVALID = -1;
 const int Phantom::PHM_HERMAN = 0;
@@ -37,16 +38,16 @@ const int Phantom::PHM_UNITPULSE = 2;
 
 const char* Phantom::s_aszPhantomName[] = 
 {
-  {"herman"},
-  {"shepp-logan"},
-  {"unit-pulse"},
+  "herman",
+  "shepp-logan",
+  "unit-pulse",
 };
 
 const char* Phantom::s_aszPhantomTitle[] = 
 {
-  {"Herman Head"},
-  {"Shepp-Logan"},
-  {"Unit Pulse"},
+  "Herman Head",
+  "Shepp-Logan",
+  "Unit Pulse",
 };
 
 const int Phantom::s_iPhantomCount = sizeof(s_aszPhantomName) / sizeof(const char*);
@@ -216,7 +217,7 @@ Phantom::createFromFile (const char* const fname)
 bool
 Phantom::fileWrite (const char* const fname)
 {
-  fstream file (fname, ios::out);
+  fstream file (fname, std::ios::out);
   
   if (! file.fail())
     printDefinitions (file);
@@ -238,8 +239,13 @@ Phantom::fileWrite (const char* const fname)
 void 
 Phantom::addPElem (const char *type, const double cx, const double cy, const double u, const double v, const double rot, const double atten)
 {
-  PhantomElement *pelem = new PhantomElement (type, cx, cy, u, v, rot, atten);
+  PhmElemType pe_type = PhantomElement::convertNameToType (type);
+  if (pe_type == PELEM_INVALID) {
+    sys_error (ERR_WARNING, "Unknown PhantomElement type %s [PhantomElement::PhantomElement]", type);
+    return;
+  }
   
+  PhantomElement *pelem = new PhantomElement (type, cx, cy, u, v, rot, atten);
   m_listPElem.push_front (pelem);
   
   // update phantom limits
@@ -598,8 +604,6 @@ PhantomElement::convertNameToType (const char* const typeName)
     type = PELEM_SECTOR;
   else if (strcasecmp (typeName, "segment") == 0)
     type = PELEM_SEGMENT;
-  else
-    sys_error (ERR_WARNING, "Unknown PhantomElement type %s [PhantomElement::PhantomElement]", type);
   
   return (type);
 }
@@ -731,7 +735,7 @@ PhantomElement::makeVectorOutline ()
     m_yOutline[cpts] = 0.0;
     break;
   default:
-    sys_error(ERR_WARNING, "illegal pelem type %d [makeVectorOutline]", m_type);
+    sys_error(ERR_WARNING, "Illegal phantom element type %d [makeVectorOutline]", m_type);
     return;
   }