summaryrefslogtreecommitdiffstats
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
parent8220a50be6bcbddf179bb855b2f7d36436fcca6b (diff)
downloadastra-74feef4718770d20273aa97f9176484149f178ae.tar.gz
astra-74feef4718770d20273aa97f9176484149f178ae.tar.bz2
astra-74feef4718770d20273aa97f9176484149f178ae.tar.xz
astra-74feef4718770d20273aa97f9176484149f178ae.zip
Improve config error handling
-rw-r--r--src/ConeProjectionGeometry3D.cpp3
-rw-r--r--src/ConeVecProjectionGeometry3D.cpp3
-rw-r--r--src/CudaDartMaskAlgorithm.cpp24
-rw-r--r--src/CudaDartMaskAlgorithm3D.cpp30
-rw-r--r--src/CudaDartSmoothingAlgorithm.cpp20
-rw-r--r--src/CudaDartSmoothingAlgorithm3D.cpp22
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp20
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp29
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp16
-rw-r--r--src/CudaRoiSelectAlgorithm.cpp10
-rw-r--r--src/FanFlatProjectionGeometry2D.cpp3
-rw-r--r--src/FanFlatVecProjectionGeometry2D.cpp3
-rw-r--r--src/FilteredBackProjectionAlgorithm.cpp14
-rw-r--r--src/Filters.cpp52
-rw-r--r--src/ForwardProjectionAlgorithm.cpp11
-rw-r--r--src/ParallelProjectionGeometry2D.cpp3
-rw-r--r--src/ParallelProjectionGeometry3D.cpp3
-rw-r--r--src/ParallelVecProjectionGeometry2D.cpp3
-rw-r--r--src/ParallelVecProjectionGeometry3D.cpp3
-rw-r--r--src/ProjectionGeometry2D.cpp3
-rw-r--r--src/ProjectionGeometry3D.cpp7
-rw-r--r--src/ReconstructionAlgorithm2D.cpp50
-rw-r--r--src/ReconstructionAlgorithm3D.cpp45
-rw-r--r--src/SparseMatrixProjectionGeometry2D.cpp5
24 files changed, 264 insertions, 118 deletions
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index 8022591..1223564 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -83,7 +83,8 @@ bool CConeProjectionGeometry3D::initialize(const Config& _cfg)
ConfigStackCheck<CProjectionGeometry3D> CC("ConeProjectionGeometry3D", this, _cfg);
// initialization of parent class
- CProjectionGeometry3D::initialize(_cfg);
+ if (!CProjectionGeometry3D::initialize(_cfg))
+ return false;
// Required: DistanceOriginDetector
XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector");
diff --git a/src/ConeVecProjectionGeometry3D.cpp b/src/ConeVecProjectionGeometry3D.cpp
index 177a0c7..b6a55c5 100644
--- a/src/ConeVecProjectionGeometry3D.cpp
+++ b/src/ConeVecProjectionGeometry3D.cpp
@@ -73,7 +73,8 @@ bool CConeVecProjectionGeometry3D::initialize(const Config& _cfg)
ConfigStackCheck<CProjectionGeometry3D> CC("ConeVecProjectionGeometry3D", this, _cfg);
// initialization of parent class
- CProjectionGeometry3D::initialize(_cfg);
+ if (!CProjectionGeometry3D::initialize(_cfg))
+ return false;
// success
m_bInitialized = _check();
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();
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();
diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp
index 437680a..3f81b91 100644
--- a/src/CudaDartSmoothingAlgorithm.cpp
+++ b/src/CudaDartSmoothingAlgorithm.cpp
@@ -65,15 +65,15 @@ bool CCudaDartSmoothingAlgorithm::initialize(const Config& _cfg)
// reconstruction data
XMLNode node = _cfg.self.getSingleNode("InDataId");
- ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No InDataId tag specified.");
- int id = node.getContentInt();
+ ASTRA_CONFIG_CHECK(node, "CudaDartSmoothing", "No InDataId tag specified.");
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pIn = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("InDataId");
// reconstruction data
node = _cfg.self.getSingleNode("OutDataId");
- ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No OutDataId tag specified.");
- id = node.getContentInt();
+ ASTRA_CONFIG_CHECK(node, "CudaDartSmoothing", "No OutDataId tag specified.");
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pOut = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("OutDataId");
@@ -85,11 +85,19 @@ bool CCudaDartSmoothingAlgorithm::initialize(const Config& _cfg)
CC.markOptionParsed("GPUIndex");
// Option: Radius
- m_fB = (float)_cfg.self.getOptionNumerical("Intensity", 0.3f);
+ try {
+ m_fB = (float)_cfg.self.getOptionNumerical("Intensity", 0.3f);
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "CudaDartSmoothing", "Intensity must be numerical");
+ }
CC.markOptionParsed("Intensity");
// 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, "CudaDartSmoothing", "Radius must be an integer.");
+ }
CC.markOptionParsed("Radius");
diff --git a/src/CudaDartSmoothingAlgorithm3D.cpp b/src/CudaDartSmoothingAlgorithm3D.cpp
index 5903d3c..0dc0631 100644
--- a/src/CudaDartSmoothingAlgorithm3D.cpp
+++ b/src/CudaDartSmoothingAlgorithm3D.cpp
@@ -60,19 +60,19 @@ CCudaDartSmoothingAlgorithm3D::~CCudaDartSmoothingAlgorithm3D()
bool CCudaDartSmoothingAlgorithm3D::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
- ConfigStackCheck<CAlgorithm> CC("CudaDartSmoothingAlgorithm", this, _cfg);
+ ConfigStackCheck<CAlgorithm> CC("CudaDartSmoothingAlgorithm3D", this, _cfg);
// reconstruction data
XMLNode node = _cfg.self.getSingleNode("InDataId");
- ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No InDataId tag specified.");
- int id = node.getContentInt();
+ ASTRA_CONFIG_CHECK(node, "CudaDartSmoothing3D", "No InDataId tag specified.");
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pIn = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("InDataId");
// reconstruction data
node = _cfg.self.getSingleNode("OutDataId");
- ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No OutDataId tag specified.");
- id = node.getContentInt();
+ ASTRA_CONFIG_CHECK(node, "CudaDartSmoothing3D", "No OutDataId tag specified.");
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pOut = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("OutDataId");
@@ -84,11 +84,19 @@ bool CCudaDartSmoothingAlgorithm3D::initialize(const Config& _cfg)
CC.markOptionParsed("GPUIndex");
// Option: Intensity
- m_fB = (float)_cfg.self.getOptionNumerical("Intensity", 0.3f);
+ try {
+ m_fB = (float)_cfg.self.getOptionNumerical("Intensity", 0.3f);
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "CudaDartSmoothing3D", "Intensity must be numerical");
+ }
CC.markOptionParsed("Intensity");
// 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, "CudaDartSmoothing3D", "Radius must be an integer.");
+ }
CC.markOptionParsed("Radius");
_check();
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");
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index c70291e..2ec1fe2 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -100,14 +100,14 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaForwardProjection3D", "No ProjectionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjections = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "CudaForwardProjection3D", "No VolumeDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pVolume = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("VolumeDataId");
@@ -115,19 +115,34 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
node = _cfg.self.getSingleNode("ProjectorId");
m_pProjector = 0;
if (node) {
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjector = CProjector3DManager::getSingleton().get(id);
+ if (!m_pProjector) {
+ // Report this explicitly since projector is optional
+ ASTRA_ERROR("ProjectorId is not a valid id");
+ }
}
CC.markNodeParsed("ProjectorId");
initializeFromProjector();
// Deprecated options
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
- m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex);
+ try {
+ m_iDetectorSuperSampling = _cfg.self.getOptionInt("DetectorSuperSampling", m_iDetectorSuperSampling);
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "CudaForwardProjection3D", "Supersampling options must be integers.");
+ }
CC.markOptionParsed("DetectorSuperSampling");
- CC.markOptionParsed("GPUindex");
-
+ // GPU number
+ 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, "CudaForwardProjection3D", "GPUIndex must be an integer.");
+ }
+ CC.markOptionParsed("GPUIndex");
+ if (!_cfg.self.hasOption("GPUIndex"))
+ CC.markOptionParsed("GPUindex");
// success
m_bIsInitialized = check();
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");
diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp
index cccbbe7..efeb04c 100644
--- a/src/CudaRoiSelectAlgorithm.cpp
+++ b/src/CudaRoiSelectAlgorithm.cpp
@@ -62,12 +62,12 @@ CCudaRoiSelectAlgorithm::~CCudaRoiSelectAlgorithm()
bool CCudaRoiSelectAlgorithm::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
- ConfigStackCheck<CAlgorithm> CC("CudaDartMaskAlgorithm", this, _cfg);
+ ConfigStackCheck<CAlgorithm> CC("CudaDartRoiSelectAlgorithm", this, _cfg);
// reconstruction data
XMLNode node = _cfg.self.getSingleNode("DataId");
ASTRA_CONFIG_CHECK(node, "CudaRoiSelect", "No DataId tag specified.");
- int id = node.getContentInt();
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pData = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("DataId");
@@ -79,7 +79,11 @@ bool CCudaRoiSelectAlgorithm::initialize(const Config& _cfg)
CC.markOptionParsed("GPUIndex");
// Option: Radius
- m_fRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 0.0f);
+ try {
+ m_fRadius = _cfg.self.getOptionNumerical("Radius", 0.0f);
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "CudaDartRoiSelect", "Radius must be numerical.");
+ }
CC.markOptionParsed("Radius");
_check();
diff --git a/src/FanFlatProjectionGeometry2D.cpp b/src/FanFlatProjectionGeometry2D.cpp
index 901cd7c..734b4c5 100644
--- a/src/FanFlatProjectionGeometry2D.cpp
+++ b/src/FanFlatProjectionGeometry2D.cpp
@@ -131,7 +131,8 @@ bool CFanFlatProjectionGeometry2D::initialize(const Config& _cfg)
ConfigStackCheck<CProjectionGeometry2D> CC("FanFlatProjectionGeometry2D", this, _cfg);
// initialization of parent class
- CProjectionGeometry2D::initialize(_cfg);
+ if (!CProjectionGeometry2D::initialize(_cfg))
+ return false;
// Required: DistanceOriginDetector
XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector");
diff --git a/src/FanFlatVecProjectionGeometry2D.cpp b/src/FanFlatVecProjectionGeometry2D.cpp
index 074194b..ce4e220 100644
--- a/src/FanFlatVecProjectionGeometry2D.cpp
+++ b/src/FanFlatVecProjectionGeometry2D.cpp
@@ -117,7 +117,8 @@ bool CFanFlatVecProjectionGeometry2D::initialize(const Config& _cfg)
XMLNode node;
// initialization of parent class
- CProjectionGeometry2D::initialize(_cfg);
+ if (!CProjectionGeometry2D::initialize(_cfg))
+ return false;
// success
diff --git a/src/FilteredBackProjectionAlgorithm.cpp b/src/FilteredBackProjectionAlgorithm.cpp
index ea606f7..423dc6c 100644
--- a/src/FilteredBackProjectionAlgorithm.cpp
+++ b/src/FilteredBackProjectionAlgorithm.cpp
@@ -93,32 +93,38 @@ bool CFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CAlgorithm> CC("FilteredBackProjectionAlgorithm", this, _cfg);
+ int id = -1;
// projector
XMLNode node = _cfg.self.getSingleNode("ProjectorId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ProjectorId tag specified.");
- int id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjector = CProjector2DManager::getSingleton().get(id);
CC.markNodeParsed("ProjectorId");
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ProjectionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// volume data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ReconstructionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ReconstructionDataId");
node = _cfg.self.getSingleNode("ProjectionIndex");
if (node)
{
- vector<float32> projectionIndex = node.getContentNumericalArray();
+ vector<float32> projectionIndex;
+ try {
+ projectionIndex = node.getContentNumericalArray();
+ } catch (const StringUtil::bad_cast &e) {
+ ASTRA_CONFIG_CHECK(false, "FilteredBackProjection", "ProjectionIndex must be a numerical vector.");
+ }
int angleCount = projectionIndex.size();
int detectorCount = m_pProjector->getProjectionGeometry()->getDetectorCount();
diff --git a/src/Filters.cpp b/src/Filters.cpp
index 8f68202..234829c 100644
--- a/src/Filters.cpp
+++ b/src/Filters.cpp
@@ -514,12 +514,16 @@ SFilterConfig getFilterConfigForAlgorithm(const Config& _cfg, CAlgorithm *_alg)
case FILTER_RPROJECTION:
case FILTER_RSINOGRAM:
node = _cfg.self.getSingleNode(nodeName);
- if (_cfg.self.hasOption(nodeName)) {
- id = _cfg.self.getOptionInt(nodeName);
- CC.markOptionParsed(nodeName);
- } else if (node) {
- id = node.getContentInt();
- CC.markNodeParsed(nodeName);
+ try {
+ if (_cfg.self.hasOption(nodeName)) {
+ id = _cfg.self.getOptionInt(nodeName);
+ CC.markOptionParsed(nodeName);
+ } else if (node) {
+ id = node.getContentInt();
+ CC.markNodeParsed(nodeName);
+ }
+ } catch (const astra::StringUtil::bad_cast &e) {
+ ASTRA_ERROR("%s is not a valid id", nodeName);
}
break;
default:
@@ -547,13 +551,17 @@ SFilterConfig getFilterConfigForAlgorithm(const Config& _cfg, CAlgorithm *_alg)
case FILTER_GAUSSIAN:
case FILTER_BLACKMAN:
case FILTER_KAISER:
- node = _cfg.self.getSingleNode(nodeName);
- if (_cfg.self.hasOption(nodeName)) {
- c.m_fParameter = _cfg.self.getOptionNumerical(nodeName);
- CC.markOptionParsed(nodeName);
- } else if (node) {
- c.m_fParameter = node.getContentNumerical();
- CC.markNodeParsed(nodeName);
+ try {
+ node = _cfg.self.getSingleNode(nodeName);
+ if (_cfg.self.hasOption(nodeName)) {
+ c.m_fParameter = _cfg.self.getOptionNumerical(nodeName);
+ CC.markOptionParsed(nodeName);
+ } else if (node) {
+ c.m_fParameter = node.getContentNumerical();
+ CC.markNodeParsed(nodeName);
+ }
+ } catch (const astra::StringUtil::bad_cast &e) {
+ ASTRA_ERROR("%s must be numerical", nodeName);
}
break;
default:
@@ -573,13 +581,17 @@ SFilterConfig getFilterConfigForAlgorithm(const Config& _cfg, CAlgorithm *_alg)
case FILTER_ERROR:
break;
default:
- node = _cfg.self.getSingleNode(nodeName);
- if (_cfg.self.hasOption(nodeName)) {
- c.m_fD = _cfg.self.getOptionNumerical(nodeName);
- CC.markOptionParsed(nodeName);
- } else if (node) {
- c.m_fD = node.getContentNumerical();
- CC.markNodeParsed(nodeName);
+ try {
+ node = _cfg.self.getSingleNode(nodeName);
+ if (_cfg.self.hasOption(nodeName)) {
+ c.m_fD = _cfg.self.getOptionNumerical(nodeName);
+ CC.markOptionParsed(nodeName);
+ } else if (node) {
+ c.m_fD = node.getContentNumerical();
+ CC.markNodeParsed(nodeName);
+ }
+ } catch (const astra::StringUtil::bad_cast &e) {
+ ASTRA_ERROR("%s must be numerical", nodeName);
}
break;
}
diff --git a/src/ForwardProjectionAlgorithm.cpp b/src/ForwardProjectionAlgorithm.cpp
index d7b664d..732f38c 100644
--- a/src/ForwardProjectionAlgorithm.cpp
+++ b/src/ForwardProjectionAlgorithm.cpp
@@ -125,32 +125,33 @@ bool CForwardProjectionAlgorithm::initialize(const Config& _cfg)
// projector
XMLNode node = _cfg.self.getSingleNode("ProjectorId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No ProjectorId tag specified.");
- int id = node.getContentInt();
+ int id;
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjector = CProjector2DManager::getSingleton().get(id);
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No ProjectionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
// volume data
node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No VolumeDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
// volume mask
if (_cfg.self.hasOption("VolumeMaskId")) {
m_bUseVolumeMask = true;
- id = _cfg.self.getOptionInt("VolumeMaskId");
+ id = StringUtil::stringToInt(_cfg.self.getOption("VolumeMaskId"), -1);
m_pVolumeMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
// sino mask
if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = _cfg.self.getOptionInt("SinogramMaskId");
+ id = StringUtil::stringToInt(_cfg.self.getOption("SinogramMaskId"), -1);
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
}
diff --git a/src/ParallelProjectionGeometry2D.cpp b/src/ParallelProjectionGeometry2D.cpp
index 74a8b34..0622795 100644
--- a/src/ParallelProjectionGeometry2D.cpp
+++ b/src/ParallelProjectionGeometry2D.cpp
@@ -102,7 +102,8 @@ bool CParallelProjectionGeometry2D::initialize(const Config& _cfg)
// initialization of parent class
- CProjectionGeometry2D::initialize(_cfg);
+ if (!CProjectionGeometry2D::initialize(_cfg))
+ return false;
// success
m_bInitialized = _check();
diff --git a/src/ParallelProjectionGeometry3D.cpp b/src/ParallelProjectionGeometry3D.cpp
index 15fe7b5..8b0585c 100644
--- a/src/ParallelProjectionGeometry3D.cpp
+++ b/src/ParallelProjectionGeometry3D.cpp
@@ -78,7 +78,8 @@ bool CParallelProjectionGeometry3D::initialize(const Config& _cfg)
// initialization of parent class
- CProjectionGeometry3D::initialize(_cfg);
+ if (!CProjectionGeometry3D::initialize(_cfg))
+ return false;
// success
m_bInitialized = _check();
diff --git a/src/ParallelVecProjectionGeometry2D.cpp b/src/ParallelVecProjectionGeometry2D.cpp
index 30682c5..0994b55 100644
--- a/src/ParallelVecProjectionGeometry2D.cpp
+++ b/src/ParallelVecProjectionGeometry2D.cpp
@@ -100,7 +100,8 @@ bool CParallelVecProjectionGeometry2D::initialize(const Config& _cfg)
ConfigStackCheck<CProjectionGeometry2D> CC("ParallelVecProjectionGeometry2D", this, _cfg);
// initialization of parent class
- CProjectionGeometry2D::initialize(_cfg);
+ if (!CProjectionGeometry2D::initialize(_cfg))
+ return false;
// success
diff --git a/src/ParallelVecProjectionGeometry3D.cpp b/src/ParallelVecProjectionGeometry3D.cpp
index ed15b68..5dc3df8 100644
--- a/src/ParallelVecProjectionGeometry3D.cpp
+++ b/src/ParallelVecProjectionGeometry3D.cpp
@@ -75,7 +75,8 @@ bool CParallelVecProjectionGeometry3D::initialize(const Config& _cfg)
XMLNode node;
// initialization of parent class
- CProjectionGeometry3D::initialize(_cfg);
+ if (!CProjectionGeometry3D::initialize(_cfg))
+ return false;
// success
m_bInitialized = _check();
diff --git a/src/ProjectionGeometry2D.cpp b/src/ProjectionGeometry2D.cpp
index 15be1d5..93dd5c6 100644
--- a/src/ProjectionGeometry2D.cpp
+++ b/src/ProjectionGeometry2D.cpp
@@ -132,8 +132,7 @@ bool CProjectionGeometry2D::initialize(const Config& _cfg)
// some checks
ASTRA_CONFIG_CHECK(m_iDetectorCount > 0, "ProjectionGeometry2D", "DetectorCount should be positive.");
- // Interface class, so don't return true
- return false;
+ return true;
}
bool CProjectionGeometry2D::initializeAngles(const Config& _cfg)
diff --git a/src/ProjectionGeometry3D.cpp b/src/ProjectionGeometry3D.cpp
index 92de247..8d2dc76 100644
--- a/src/ProjectionGeometry3D.cpp
+++ b/src/ProjectionGeometry3D.cpp
@@ -171,9 +171,7 @@ bool CProjectionGeometry3D::initialize(const Config& _cfg)
if (!initializeAngles(_cfg))
return false;
-
- // Interface class, so don't return true
- return false;
+ return true;
}
bool CProjectionGeometry3D::initializeAngles(const Config& _cfg)
@@ -248,8 +246,7 @@ bool CProjectionGeometry3D::_initialize(int _iProjectionAngleCount,
m_iDetectorTotCount = m_iProjectionAngleCount * m_iDetectorRowCount * m_iDetectorColCount;
- // Interface class, so don't return true
- return false;
+ return true;
}
} // namespace astra
diff --git a/src/ReconstructionAlgorithm2D.cpp b/src/ReconstructionAlgorithm2D.cpp
index 9d1aa1d..781b391 100644
--- a/src/ReconstructionAlgorithm2D.cpp
+++ b/src/ReconstructionAlgorithm2D.cpp
@@ -28,6 +28,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include "astra/ReconstructionAlgorithm2D.h"
#include "astra/AstraObjectManager.h"
+#include "astra/Logging.h"
using namespace std;
@@ -85,33 +86,36 @@ bool CReconstructionAlgorithm2D::initialize(const Config& _cfg)
if (requiresProjector()) {
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ProjectorId tag specified.");
}
- int id;
+ m_pProjector = 0;
+ int id = -1;
if (node) {
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjector = CProjector2DManager::getSingleton().get(id);
- } else {
- m_pProjector = 0;
+ if (!m_pProjector) {
+ // Report this explicitly since projector is optional
+ ASTRA_ERROR("ProjectorId is not a valid id");
+ }
}
CC.markNodeParsed("ProjectorId");
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ProjectionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ReconstructionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = _cfg.self.getOptionInt("ReconstructionMaskId");
+ id = StringUtil::stringToInt(_cfg.self.getOption("ReconstructionMaskId"), -1);
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pReconstructionMask, "Reconstruction2D", "Invalid ReconstructionMaskId.");
}
@@ -120,36 +124,56 @@ bool CReconstructionAlgorithm2D::initialize(const Config& _cfg)
// fixed mask
if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = _cfg.self.getOptionInt("SinogramMaskId");
+ id = StringUtil::stringToInt(_cfg.self.getOption("SinogramMaskId"), -1);
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_CONFIG_CHECK(m_pSinogramMask, "Reconstruction2D", "Invalid SinogramMaskId.");
+ ASTRA_CONFIG_CHECK(m_pSinogramMask, "ReconstructionAlgorithm2D", "Invalid SinogramMaskId.");
}
CC.markOptionParsed("SinogramMaskId");
// Constraints - NEW
if (_cfg.self.hasOption("MinConstraint")) {
m_bUseMinConstraint = true;
- m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
+ try {
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMinValue = 0.0f;
+ ASTRA_ERROR("MinConstraint must be numerical");
+ }
CC.markOptionParsed("MinConstraint");
} else {
// Constraint - OLD
m_bUseMinConstraint = _cfg.self.getOptionBool("UseMinConstraint", false);
CC.markOptionParsed("UseMinConstraint");
if (m_bUseMinConstraint) {
- m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
+ try {
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMinValue = 0.0f;
+ ASTRA_ERROR("MinConstraintValue must be numerical");
+ }
CC.markOptionParsed("MinConstraintValue");
}
}
if (_cfg.self.hasOption("MaxConstraint")) {
m_bUseMaxConstraint = true;
- m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
+ try {
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMinValue = 255.0f;
+ ASTRA_ERROR("MaxConstraint must be numerical");
+ }
CC.markOptionParsed("MaxConstraint");
} else {
// Constraint - OLD
m_bUseMaxConstraint = _cfg.self.getOptionBool("UseMaxConstraint", false);
CC.markOptionParsed("UseMaxConstraint");
if (m_bUseMaxConstraint) {
- m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 0.0f);
+ try {
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 255.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMaxValue = 255.0f;
+ ASTRA_ERROR("MaxConstraintValue must be numerical");
+ }
CC.markOptionParsed("MaxConstraintValue");
}
}
diff --git a/src/ReconstructionAlgorithm3D.cpp b/src/ReconstructionAlgorithm3D.cpp
index 20bc34e..86be290 100644
--- a/src/ReconstructionAlgorithm3D.cpp
+++ b/src/ReconstructionAlgorithm3D.cpp
@@ -28,6 +28,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include "astra/ReconstructionAlgorithm3D.h"
#include "astra/AstraObjectManager.h"
+#include "astra/Logging.h"
using namespace std;
@@ -102,16 +103,17 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("ReconstructionAlgorithm3D", this, _cfg);
XMLNode node;
- int id;
// projector
node = _cfg.self.getSingleNode("ProjectorId");
m_pProjector = 0;
+ int id = -1;
if (node) {
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pProjector = CProjector3DManager::getSingleton().get(id);
if (!m_pProjector) {
- // TODO: Report
+ // Report this explicitly since projector is optional
+ ASTRA_ERROR("ProjectorId is not a valid id");
}
}
CC.markNodeParsed("ProjectorId");
@@ -119,21 +121,22 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ProjectionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
m_pSinogram = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ReconstructionDataId tag specified.");
- id = node.getContentInt();
+ id = StringUtil::stringToInt(node.getContent(), -1);
+
m_pReconstruction = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = _cfg.self.getOptionInt("ReconstructionMaskId");
+ id = StringUtil::stringToInt(_cfg.self.getOption("ReconstructionMaskId"), -1);
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
}
CC.markOptionParsed("ReconstructionMaskId");
@@ -141,7 +144,7 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
// fixed mask
if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = _cfg.self.getOptionInt("SinogramMaskId");
+ id = StringUtil::stringToInt(_cfg.self.getOption("SinogramMaskId"), -1);
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
}
CC.markOptionParsed("SinogramMaskId");
@@ -149,27 +152,47 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
// Constraints - NEW
if (_cfg.self.hasOption("MinConstraint")) {
m_bUseMinConstraint = true;
- m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
+ try {
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMinValue = 0.0f;
+ ASTRA_ERROR("MinConstraint must be numerical");
+ }
CC.markOptionParsed("MinConstraint");
} else {
// Constraint - OLD
m_bUseMinConstraint = _cfg.self.getOptionBool("UseMinConstraint", false);
CC.markOptionParsed("UseMinConstraint");
if (m_bUseMinConstraint) {
- m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
+ try {
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMinValue = 0.0f;
+ ASTRA_ERROR("MinConstraintValue must be numerical");
+ }
CC.markOptionParsed("MinConstraintValue");
}
}
if (_cfg.self.hasOption("MaxConstraint")) {
m_bUseMaxConstraint = true;
- m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
+ try {
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMinValue = 255.0f;
+ ASTRA_ERROR("MaxConstraint must be numerical");
+ }
CC.markOptionParsed("MaxConstraint");
} else {
// Constraint - OLD
m_bUseMaxConstraint = _cfg.self.getOptionBool("UseMaxConstraint", false);
CC.markOptionParsed("UseMaxConstraint");
if (m_bUseMaxConstraint) {
- m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 0.0f);
+ try {
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 255.0f);
+ } catch (const astra::StringUtil::bad_cast &e) {
+ m_fMaxValue = 255.0f;
+ ASTRA_ERROR("MaxConstraintValue must be numerical");
+ }
CC.markOptionParsed("MaxConstraintValue");
}
}
diff --git a/src/SparseMatrixProjectionGeometry2D.cpp b/src/SparseMatrixProjectionGeometry2D.cpp
index b55a282..e8165a3 100644
--- a/src/SparseMatrixProjectionGeometry2D.cpp
+++ b/src/SparseMatrixProjectionGeometry2D.cpp
@@ -93,12 +93,13 @@ bool CSparseMatrixProjectionGeometry2D::initialize(const Config& _cfg)
ConfigStackCheck<CProjectionGeometry2D> CC("SparseMatrixProjectionGeometry2D", this, _cfg);
// initialization of parent class
- CProjectionGeometry2D::initialize(_cfg);
+ if (!CProjectionGeometry2D::initialize(_cfg))
+ return false;
// get matrix
XMLNode node = _cfg.self.getSingleNode("MatrixID");
ASTRA_CONFIG_CHECK(node, "SparseMatrixProjectionGeometry2D", "No MatrixID tag specified.");
- int id = node.getContentInt();
+ int id = StringUtil::stringToInt(node.getContent(), -1);
m_pMatrix = CMatrixManager::getSingleton().get(id);
CC.markNodeParsed("MatrixID");