summaryrefslogtreecommitdiffstats
path: root/src/ConeVecProjectionGeometry3D.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-12-07 16:41:40 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-12-23 16:57:45 +0100
commit8220a50be6bcbddf179bb855b2f7d36436fcca6b (patch)
tree81986f22c74784ff02c88f1d071fae32186e5f89 /src/ConeVecProjectionGeometry3D.cpp
parentcbc2e1079cf40c6f0c08d2f9c54f7b41b678e567 (diff)
downloadastra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.tar.gz
astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.tar.bz2
astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.tar.xz
astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.zip
More gracefully handle config errors in geometries
Diffstat (limited to 'src/ConeVecProjectionGeometry3D.cpp')
-rw-r--r--src/ConeVecProjectionGeometry3D.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/ConeVecProjectionGeometry3D.cpp b/src/ConeVecProjectionGeometry3D.cpp
index 0e0f70b..177a0c7 100644
--- a/src/ConeVecProjectionGeometry3D.cpp
+++ b/src/ConeVecProjectionGeometry3D.cpp
@@ -72,29 +72,27 @@ bool CConeVecProjectionGeometry3D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CProjectionGeometry3D> CC("ConeVecProjectionGeometry3D", this, _cfg);
- XMLNode node;
-
- // TODO: Fix up class hierarchy... this class doesn't fit very well.
// initialization of parent class
- //CProjectionGeometry3D::initialize(_cfg);
+ CProjectionGeometry3D::initialize(_cfg);
- // Required: DetectorRowCount
- node = _cfg.self.getSingleNode("DetectorRowCount");
- ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = node.getContentInt();
- CC.markNodeParsed("DetectorRowCount");
+ // success
+ m_bInitialized = _check();
+ return m_bInitialized;
+}
- // Required: DetectorColCount
- node = _cfg.self.getSingleNode("DetectorColCount");
- ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorColCount tag specified.");
- m_iDetectorColCount = node.getContentInt();
- m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
- CC.markNodeParsed("DetectorColCount");
+bool CConeVecProjectionGeometry3D::initializeAngles(const Config& _cfg)
+{
+ ConfigStackCheck<CProjectionGeometry3D> CC("ConeVecProjectionGeometry3D", this, _cfg);
// Required: Vectors
- node = _cfg.self.getSingleNode("Vectors");
+ XMLNode node = _cfg.self.getSingleNode("Vectors");
ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No Vectors tag specified.");
- vector<double> data = node.getContentNumericalArrayDouble();
+ vector<double> data;
+ try {
+ data = node.getContentNumericalArrayDouble();
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "ConeVecProjectionGeometry3D", "Vectors must be a numerical matrix.");
+ }
CC.markNodeParsed("Vectors");
ASTRA_CONFIG_CHECK(data.size() % 12 == 0, "ConeVecProjectionGeometry3D", "Vectors doesn't consist of 12-tuples.");
m_iProjectionAngleCount = data.size() / 12;
@@ -119,9 +117,7 @@ bool CConeVecProjectionGeometry3D::initialize(const Config& _cfg)
p.fDetSZ = data[12*i + 5] - 0.5f * m_iDetectorRowCount * p.fDetVZ - 0.5f * m_iDetectorColCount * p.fDetUZ;
}
- // success
- m_bInitialized = _check();
- return m_bInitialized;
+ return true;
}
//----------------------------------------------------------------------------------------