From 8220a50be6bcbddf179bb855b2f7d36436fcca6b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 7 Dec 2018 16:41:40 +0100 Subject: More gracefully handle config errors in geometries --- src/ParallelVecProjectionGeometry3D.cpp | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/ParallelVecProjectionGeometry3D.cpp') 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 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 data = node.getContentNumericalArrayDouble(); + vector 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; } //---------------------------------------------------------------------------------------- -- cgit v1.2.3