summaryrefslogtreecommitdiffstats
path: root/matlab/mex
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-11 14:48:22 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-11 14:56:58 +0200
commit9c7d0f544b7a4dec54e9a75ea45b985ad7fac756 (patch)
treee0d704dbc9472723cca97a11ca1d79de8ce9feb5 /matlab/mex
parent70151c3e497f42fbfd305124ca3e9f858f90c686 (diff)
downloadastra-9c7d0f544b7a4dec54e9a75ea45b985ad7fac756.tar.gz
astra-9c7d0f544b7a4dec54e9a75ea45b985ad7fac756.tar.bz2
astra-9c7d0f544b7a4dec54e9a75ea45b985ad7fac756.tar.xz
astra-9c7d0f544b7a4dec54e9a75ea45b985ad7fac756.zip
Improve object creation error messages
Diffstat (limited to 'matlab/mex')
-rw-r--r--matlab/mex/astra_mex_algorithm_c.cpp4
-rw-r--r--matlab/mex/astra_mex_projector3d_c.cpp12
-rw-r--r--matlab/mex/astra_mex_projector_c.cpp12
3 files changed, 22 insertions, 6 deletions
diff --git a/matlab/mex/astra_mex_algorithm_c.cpp b/matlab/mex/astra_mex_algorithm_c.cpp
index a9cd14b..f20f3a5 100644
--- a/matlab/mex/astra_mex_algorithm_c.cpp
+++ b/matlab/mex/astra_mex_algorithm_c.cpp
@@ -83,7 +83,7 @@ void astra_mex_algorithm_create(int nlhs, mxArray* plhs[], int nrhs, const mxArr
CAlgorithm* pAlg = CAlgorithmFactory::getSingleton().create(cfg->self.getAttribute("type"));
if (!pAlg) {
delete cfg;
- mexErrMsgTxt("Unknown algorithm. \n");
+ mexErrMsgTxt("Unknown Algorithm. \n");
return;
}
@@ -91,7 +91,7 @@ void astra_mex_algorithm_create(int nlhs, mxArray* plhs[], int nrhs, const mxArr
if (!pAlg->initialize(*cfg)) {
delete cfg;
delete pAlg;
- mexErrMsgTxt("Algorithm not initialized. \n");
+ mexErrMsgTxt("Unable to initialize Algorithm. \n");
return;
}
delete cfg;
diff --git a/matlab/mex/astra_mex_projector3d_c.cpp b/matlab/mex/astra_mex_projector3d_c.cpp
index 3135939..c5f2291 100644
--- a/matlab/mex/astra_mex_projector3d_c.cpp
+++ b/matlab/mex/astra_mex_projector3d_c.cpp
@@ -68,10 +68,18 @@ void astra_mex_projector3d_create(int nlhs, mxArray* plhs[], int nrhs, const mxA
Config* cfg = structToConfig("Projector3D", prhs[1]);
// create algorithm
- CProjector3D* pProj = CProjector3DFactory::getSingleton().create(*cfg);
+ CProjector3D* pProj = CProjector3DFactory::getSingleton().create(cfg->self.getAttribute("type"));
if (pProj == NULL) {
delete cfg;
- mexErrMsgTxt("Error creating Projector3D. \n");
+ mexErrMsgTxt("Unknown Projector3D. \n");
+ return;
+ }
+
+ // create algorithm
+ if (!pProj->initialize(*cfg)) {
+ delete cfg;
+ delete pProj;
+ mexErrMsgTxt("Unable to initialize Projector3D. \n");
return;
}
delete cfg;
diff --git a/matlab/mex/astra_mex_projector_c.cpp b/matlab/mex/astra_mex_projector_c.cpp
index 36a5704..5c2ba72 100644
--- a/matlab/mex/astra_mex_projector_c.cpp
+++ b/matlab/mex/astra_mex_projector_c.cpp
@@ -77,10 +77,18 @@ void astra_mex_projector_create(int nlhs, mxArray* plhs[], int nrhs, const mxArr
Config* cfg = structToConfig("Projector2D", prhs[1]);
// create algorithm
- CProjector2D* pProj = CProjector2DFactory::getSingleton().create(*cfg);
+ CProjector2D* pProj = CProjector2DFactory::getSingleton().create(cfg->self.getAttribute("type"));
if (pProj == NULL) {
delete cfg;
- mexErrMsgTxt("Error creating projector. \n");
+ mexErrMsgTxt("Unknown Projector2D. \n");
+ return;
+ }
+
+ // create algorithm
+ if (!pProj->initialize(*cfg)) {
+ delete cfg;
+ delete pProj;
+ mexErrMsgTxt("Unable to initialize Projector2D. \n");
return;
}
delete cfg;