diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-12 11:25:33 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-23 16:58:03 +0100 |
commit | 74feef4718770d20273aa97f9176484149f178ae (patch) | |
tree | d7c52cb57a60cc85d6326901cc71ff09986f11a4 /src/CudaDartMaskAlgorithm.cpp | |
parent | 8220a50be6bcbddf179bb855b2f7d36436fcca6b (diff) | |
download | astra-74feef4718770d20273aa97f9176484149f178ae.tar.gz astra-74feef4718770d20273aa97f9176484149f178ae.tar.bz2 astra-74feef4718770d20273aa97f9176484149f178ae.tar.xz astra-74feef4718770d20273aa97f9176484149f178ae.zip |
Improve config error handling
Diffstat (limited to 'src/CudaDartMaskAlgorithm.cpp')
-rw-r--r-- | src/CudaDartMaskAlgorithm.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp index 3c5519c..bd9f59f 100644 --- a/src/CudaDartMaskAlgorithm.cpp +++ b/src/CudaDartMaskAlgorithm.cpp @@ -66,14 +66,14 @@ bool CCudaDartMaskAlgorithm::initialize(const Config& _cfg) // reconstruction data XMLNode node = _cfg.self.getSingleNode("SegmentationDataId"); ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No SegmentationDataId tag specified."); - int id = node.getContentInt(); + int id = StringUtil::stringToInt(node.getContent(), -1); m_pSegmentation = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id)); CC.markNodeParsed("SegmentationDataId"); // reconstruction data node = _cfg.self.getSingleNode("MaskDataId"); ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No MaskDataId tag specified."); - id = node.getContentInt(); + id = StringUtil::stringToInt(node.getContent(), -1); m_pMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id)); CC.markNodeParsed("MaskDataId"); @@ -84,16 +84,28 @@ bool CCudaDartMaskAlgorithm::initialize(const Config& _cfg) if (!_cfg.self.hasOption("GPUindex")) CC.markOptionParsed("GPUIndex"); - // Option: Connectivity - m_iConn = (unsigned int)_cfg.self.getOptionNumerical("Connectivity", 8); + // Option: Connectivity + try { + m_iConn = _cfg.self.getOptionInt("Connectivity", 8); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "CudaDartMask", "Connectivity must be an integer."); + } CC.markOptionParsed("Connectivity"); // Option: Threshold - m_iThreshold = (unsigned int)_cfg.self.getOptionNumerical("Threshold", 1); + try { + m_iThreshold = _cfg.self.getOptionInt("Threshold", 1); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "CudaDartMask", "Threshold must be an integer."); + } CC.markOptionParsed("Threshold"); // Option: Radius - m_iRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 1); + try { + m_iRadius = _cfg.self.getOptionInt("Radius", 1); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "CudaDartMask", "Radius must be an integer."); + } CC.markOptionParsed("Radius"); _check(); |