diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-07 16:41:40 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-23 16:57:45 +0100 |
commit | 8220a50be6bcbddf179bb855b2f7d36436fcca6b (patch) | |
tree | 81986f22c74784ff02c88f1d071fae32186e5f89 /src/ParallelVecProjectionGeometry3D.cpp | |
parent | cbc2e1079cf40c6f0c08d2f9c54f7b41b678e567 (diff) | |
download | astra-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/ParallelVecProjectionGeometry3D.cpp')
-rw-r--r-- | src/ParallelVecProjectionGeometry3D.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/ParallelVecProjectionGeometry3D.cpp b/src/ParallelVecProjectionGeometry3D.cpp index 58fc986..ed15b68 100644 --- a/src/ParallelVecProjectionGeometry3D.cpp +++ b/src/ParallelVecProjectionGeometry3D.cpp @@ -74,27 +74,27 @@ bool CParallelVecProjectionGeometry3D::initialize(const Config& _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, "ParallelVecProjectionGeometry3D", "No DetectorRowCount tag specified."); - m_iDetectorRowCount = node.getContentInt(); - CC.markNodeParsed("DetectorRowCount"); + // success + m_bInitialized = _check(); + return m_bInitialized; +} - // Required: DetectorCount - node = _cfg.self.getSingleNode("DetectorColCount"); - ASTRA_CONFIG_CHECK(node, "", "No DetectorColCount tag specified."); - m_iDetectorColCount = node.getContentInt(); - m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount; - CC.markNodeParsed("DetectorColCount"); +bool CParallelVecProjectionGeometry3D::initializeAngles(const Config& _cfg) +{ + ConfigStackCheck<CProjectionGeometry3D> CC("ParallelVecProjectionGeometry3D", this, _cfg); // Required: Vectors - node = _cfg.self.getSingleNode("Vectors"); + XMLNode node = _cfg.self.getSingleNode("Vectors"); ASTRA_CONFIG_CHECK(node, "ParallelVecProjectionGeometry3D", "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, "ParallelVecProjectionGeometry3D", "Vectors must be a numerical matrix."); + } CC.markNodeParsed("Vectors"); ASTRA_CONFIG_CHECK(data.size() % 12 == 0, "ParallelVecProjectionGeometry3D", "Vectors doesn't consist of 12-tuples."); m_iProjectionAngleCount = data.size() / 12; @@ -119,9 +119,7 @@ bool CParallelVecProjectionGeometry3D::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; } //---------------------------------------------------------------------------------------- |