summaryrefslogtreecommitdiffstats
path: root/src/CudaForwardProjectionAlgorithm.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-12-12 11:25:33 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-12-23 16:58:03 +0100
commit74feef4718770d20273aa97f9176484149f178ae (patch)
treed7c52cb57a60cc85d6326901cc71ff09986f11a4 /src/CudaForwardProjectionAlgorithm.cpp
parent8220a50be6bcbddf179bb855b2f7d36436fcca6b (diff)
downloadastra-74feef4718770d20273aa97f9176484149f178ae.tar.gz
astra-74feef4718770d20273aa97f9176484149f178ae.tar.bz2
astra-74feef4718770d20273aa97f9176484149f178ae.tar.xz
astra-74feef4718770d20273aa97f9176484149f178ae.zip
Improve config error handling
Diffstat (limited to 'src/CudaForwardProjectionAlgorithm.cpp')
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp
index 5fb58a3..24d9a46 100644
--- a/src/CudaForwardProjectionAlgorithm.cpp
+++ b/src/CudaForwardProjectionAlgorithm.cpp
@@ -94,7 +94,7 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
m_pProjector = 0;
XMLNode node = _cfg.self.getSingleNode("ProjectorId");
if (node) {
- int id = node.getContentInt();
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjector = CProjector2DManager::getSingleton().get(id);
}
CC.markNodeParsed("ProjectorId");
@@ -104,25 +104,33 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No ProjectionDataId tag specified.");
- int id = node.getContentInt();
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// volume data
node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No VolumeDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("VolumeDataId");
initializeFromProjector();
// Deprecated options
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ try {
+ m_iDetectorSuperSampling = _cfg.self.getOptionInt("DetectorSuperSampling", m_iDetectorSuperSampling);
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "FP_CUDA", "Supersampling options must be integers.");
+ }
CC.markOptionParsed("DetectorSuperSampling");
// 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, "FP_CUDA", "GPUIndex must be an integer.");
+ }
CC.markOptionParsed("GPUIndex");
if (!_cfg.self.hasOption("GPUIndex"))
CC.markOptionParsed("GPUindex");