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/ConeVecProjectionGeometry3D.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/ConeVecProjectionGeometry3D.cpp') 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 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 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 data = node.getContentNumericalArrayDouble(); + vector 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; } //---------------------------------------------------------------------------------------- -- cgit v1.2.3