summaryrefslogtreecommitdiffstats
path: root/src/CudaDartMaskAlgorithm3D.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/CudaDartMaskAlgorithm3D.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/CudaDartMaskAlgorithm3D.cpp')
-rw-r--r--src/CudaDartMaskAlgorithm3D.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/CudaDartMaskAlgorithm3D.cpp b/src/CudaDartMaskAlgorithm3D.cpp
index 7d9aed2..99b0a8d 100644
--- a/src/CudaDartMaskAlgorithm3D.cpp
+++ b/src/CudaDartMaskAlgorithm3D.cpp
@@ -60,19 +60,19 @@ CCudaDartMaskAlgorithm3D::~CCudaDartMaskAlgorithm3D()
bool CCudaDartMaskAlgorithm3D::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
- ConfigStackCheck<CAlgorithm> CC("CudaDartMaskAlgorithm", this, _cfg);
+ ConfigStackCheck<CAlgorithm> CC("CudaDartMaskAlgorithm3D", this, _cfg);
// reconstruction data
XMLNode node = _cfg.self.getSingleNode("SegmentationDataId");
- ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No SegmentationDataId tag specified.");
- int id = node.getContentInt();
+ ASTRA_CONFIG_CHECK(node, "CudaDartMask3D", "No SegmentationDataId tag specified.");
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pSegmentation = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::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();
+ ASTRA_CONFIG_CHECK(node, "CudaDartMask3D", "No MaskDataId tag specified.");
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pMask = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("MaskDataId");
@@ -83,16 +83,28 @@ bool CCudaDartMaskAlgorithm3D::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, "CudaDartMask3D", "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, "CudaDartMask3D", "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, "CudaDartMask3D", "Radius must be an integer.");
+ }
CC.markOptionParsed("Radius");
_check();