From 74feef4718770d20273aa97f9176484149f178ae Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 12 Dec 2018 11:25:33 +0100 Subject: Improve config error handling --- src/CudaReconstructionAlgorithm2D.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/CudaReconstructionAlgorithm2D.cpp') diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp index cf7cb6a..d584fc8 100644 --- a/src/CudaReconstructionAlgorithm2D.cpp +++ b/src/CudaReconstructionAlgorithm2D.cpp @@ -115,14 +115,22 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg) initializeFromProjector(); // Deprecated options - m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling); - m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", m_iPixelSuperSampling); + try { + m_iDetectorSuperSampling = _cfg.self.getOptionInt("DetectorSuperSampling", m_iDetectorSuperSampling); + m_iPixelSuperSampling = _cfg.self.getOptionInt("PixelSuperSampling", m_iPixelSuperSampling); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "CudaReconstructionAlgorithm2D", "Supersampling options must be integers."); + } CC.markOptionParsed("DetectorSuperSampling"); CC.markOptionParsed("PixelSuperSampling"); // GPU number - m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1); - m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex); + try { + m_iGPUIndex = _cfg.self.getOptionInt("GPUindex", -1); + m_iGPUIndex = _cfg.self.getOptionInt("GPUIndex", m_iGPUIndex); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "CudaReconstructionAlgorithm2D", "GPUIndex must be an integer."); + } CC.markOptionParsed("GPUIndex"); if (!_cfg.self.hasOption("GPUIndex")) CC.markOptionParsed("GPUindex"); -- cgit v1.2.3