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/VolumeGeometry3D.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/VolumeGeometry3D.cpp')
-rw-r--r-- | src/VolumeGeometry3D.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/VolumeGeometry3D.cpp b/src/VolumeGeometry3D.cpp index b8c2409..eb8cc60 100644 --- a/src/VolumeGeometry3D.cpp +++ b/src/VolumeGeometry3D.cpp @@ -193,28 +193,44 @@ bool CVolumeGeometry3D::initialize(const Config& _cfg) // Required: GridColCount XMLNode node = _cfg.self.getSingleNode("GridColCount"); ASTRA_CONFIG_CHECK(node, "VolumeGeometry3D", "No GridColCount tag specified."); - m_iGridColCount = node.getContentInt(); + try { + m_iGridColCount = node.getContentInt(); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "VolumeGeometry3D", "GridColCount must be an integer."); + } CC.markNodeParsed("GridColCount"); // Required: GridRowCount node = _cfg.self.getSingleNode("GridRowCount"); ASTRA_CONFIG_CHECK(node, "VolumeGeometry3D", "No GridRowCount tag specified."); - m_iGridRowCount = node.getContentInt(); + try { + m_iGridRowCount = node.getContentInt(); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "VolumeGeometry3D", "GridRowCount must be an integer."); + } CC.markNodeParsed("GridRowCount"); // Required: GridRowCount node = _cfg.self.getSingleNode("GridSliceCount"); ASTRA_CONFIG_CHECK(node, "VolumeGeometry3D", "No GridSliceCount tag specified."); - m_iGridSliceCount = node.getContentInt(); + try { + m_iGridSliceCount = node.getContentInt(); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "VolumeGeometry3D", "GridSliceCount must be an integer."); + } CC.markNodeParsed("GridSliceCount"); // Optional: Window minima and maxima - m_fWindowMinX = _cfg.self.getOptionNumerical("WindowMinX", -m_iGridColCount/2.0f); - m_fWindowMaxX = _cfg.self.getOptionNumerical("WindowMaxX", m_iGridColCount/2.0f); - m_fWindowMinY = _cfg.self.getOptionNumerical("WindowMinY", -m_iGridRowCount/2.0f); - m_fWindowMaxY = _cfg.self.getOptionNumerical("WindowMaxY", m_iGridRowCount/2.0f); - m_fWindowMinZ = _cfg.self.getOptionNumerical("WindowMinZ", -m_iGridSliceCount/2.0f); - m_fWindowMaxZ = _cfg.self.getOptionNumerical("WindowMaxZ", m_iGridSliceCount/2.0f); + try { + m_fWindowMinX = _cfg.self.getOptionNumerical("WindowMinX", -m_iGridColCount/2.0f); + m_fWindowMaxX = _cfg.self.getOptionNumerical("WindowMaxX", m_iGridColCount/2.0f); + m_fWindowMinY = _cfg.self.getOptionNumerical("WindowMinY", -m_iGridRowCount/2.0f); + m_fWindowMaxY = _cfg.self.getOptionNumerical("WindowMaxY", m_iGridRowCount/2.0f); + m_fWindowMinZ = _cfg.self.getOptionNumerical("WindowMinZ", -m_iGridSliceCount/2.0f); + m_fWindowMaxZ = _cfg.self.getOptionNumerical("WindowMaxZ", m_iGridSliceCount/2.0f); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "VolumeGeometry3D", "Window extents must be numerical."); + } CC.markOptionParsed("WindowMinX"); CC.markOptionParsed("WindowMaxX"); CC.markOptionParsed("WindowMinY"); |