summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-11 15:04:23 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-11 15:04:23 +0200
commit5ad3d86b6e2c39de7465186ec8702053a82b6152 (patch)
tree260caa74def1712bf1d0811789a2205e8c55e2fc
parent90a0bd4962ae21413456b27e55382ba5223e1c10 (diff)
parent9c7d0f544b7a4dec54e9a75ea45b985ad7fac756 (diff)
downloadastra-5ad3d86b6e2c39de7465186ec8702053a82b6152.tar.gz
astra-5ad3d86b6e2c39de7465186ec8702053a82b6152.tar.bz2
astra-5ad3d86b6e2c39de7465186ec8702053a82b6152.tar.xz
astra-5ad3d86b6e2c39de7465186ec8702053a82b6152.zip
Merge branch 'master' into parallel_vec
-rw-r--r--.travis.yml8
-rw-r--r--include/astra/AstraObjectFactory.h15
-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
-rw-r--r--matlab/tools/opTomo.m7
-rw-r--r--python/astra/PyIncludes.pxd2
-rw-r--r--python/astra/PyProjector2DFactory.pxd2
-rw-r--r--python/astra/PyProjector3DFactory.pxd2
-rw-r--r--python/astra/algorithm_c.pyx4
-rw-r--r--python/astra/projector3d_c.pyx8
-rw-r--r--python/astra/projector_c.pyx8
-rw-r--r--src/AsyncAlgorithm.cpp12
13 files changed, 56 insertions, 40 deletions
diff --git a/.travis.yml b/.travis.yml
index 6d0a3ea..1cd7420 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,10 +27,10 @@ matrix:
apt:
packages:
- libboost-all-dev
- - nvidia-common
- - nvidia-current
- nvidia-cuda-toolkit
- nvidia-cuda-dev
+ - nvidia-profiler
+ - libcuinj64-5.5
- env: CUDA=yes
python: "3.6"
@@ -38,10 +38,10 @@ matrix:
apt:
packages:
- libboost-all-dev
- - nvidia-common
- - nvidia-current
- nvidia-cuda-toolkit
- nvidia-cuda-dev
+ - nvidia-profiler
+ - libcuinj64-5.5
exclude:
- os: linux
diff --git a/include/astra/AstraObjectFactory.h b/include/astra/AstraObjectFactory.h
index 746e27a..5db9167 100644
--- a/include/astra/AstraObjectFactory.h
+++ b/include/astra/AstraObjectFactory.h
@@ -126,21 +126,6 @@ T* CAstraObjectFactory<T, TypeList>::create(std::string _sType)
return finder.res;
}
-//----------------------------------------------------------------------------------------
-// Create with XML
-template <typename T, typename TypeList>
-T* CAstraObjectFactory<T, TypeList>::create(const Config& _cfg)
-{
- T* object = create(_cfg.self.getAttribute("type"));
- if (object == NULL) return NULL;
- if (object->initialize(_cfg))
- return object;
- delete object;
- return NULL;
-}
-//----------------------------------------------------------------------------------------
-
-
//----------------------------------------------------------------------------------------
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;
diff --git a/matlab/tools/opTomo.m b/matlab/tools/opTomo.m
index 81de534..3ae1163 100644
--- a/matlab/tools/opTomo.m
+++ b/matlab/tools/opTomo.m
@@ -51,6 +51,8 @@ classdef opTomo < opSpot
properties ( SetAccess = private, GetAccess = public )
proj_size
vol_size
+ proj_geom
+ vol_geom
end % properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -92,11 +94,9 @@ classdef opTomo < opSpot
if gpuEnabled
fp_alg = 'FP_CUDA';
bp_alg = 'BP_CUDA';
- proj_id = [];
else
fp_alg = 'FP';
bp_alg = 'BP';
- proj_id = astra_create_projector(type, proj_geom, vol_geom);
end
% configuration for ASTRA fp algorithm
@@ -129,6 +129,7 @@ classdef opTomo < opSpot
op.bp_alg_id = bp_alg_id;
op.sino_id = sino_id;
op.vol_id = vol_id;
+
else
% 3D
% only gpu/cuda code for 3D
@@ -158,6 +159,8 @@ classdef opTomo < opSpot
op.vol_size = vol_size;
op.cflag = false;
op.sweepflag = false;
+ op.proj_geom = proj_geom;
+ op.vol_geom = vol_geom;
end % opTomo - constructor
diff --git a/python/astra/PyIncludes.pxd b/python/astra/PyIncludes.pxd
index cf3f902..bba47f3 100644
--- a/python/astra/PyIncludes.pxd
+++ b/python/astra/PyIncludes.pxd
@@ -159,6 +159,7 @@ cdef extern from "astra/ReconstructionAlgorithm2D.h" namespace "astra":
cdef extern from "astra/Projector2D.h" namespace "astra":
cdef cppclass CProjector2D:
bool isInitialized()
+ bool initialize(Config)
CProjectionGeometry2D* getProjectionGeometry()
CVolumeGeometry2D* getVolumeGeometry()
CSparseMatrix* getMatrix()
@@ -166,6 +167,7 @@ cdef extern from "astra/Projector2D.h" namespace "astra":
cdef extern from "astra/Projector3D.h" namespace "astra":
cdef cppclass CProjector3D:
bool isInitialized()
+ bool initialize(Config)
CProjectionGeometry3D* getProjectionGeometry()
CVolumeGeometry3D* getVolumeGeometry()
diff --git a/python/astra/PyProjector2DFactory.pxd b/python/astra/PyProjector2DFactory.pxd
index 8c751fc..b70bf79 100644
--- a/python/astra/PyProjector2DFactory.pxd
+++ b/python/astra/PyProjector2DFactory.pxd
@@ -29,7 +29,7 @@ from .PyIncludes cimport *
cdef extern from "astra/AstraObjectFactory.h" namespace "astra":
cdef cppclass CProjector2DFactory:
- CProjector2D *create(Config)
+ CProjector2D *create(string)
cdef extern from "astra/AstraObjectFactory.h" namespace "astra::CProjector2DFactory":
cdef CProjector2DFactory* getSingletonPtr()
diff --git a/python/astra/PyProjector3DFactory.pxd b/python/astra/PyProjector3DFactory.pxd
index 345678b..ae0cc1d 100644
--- a/python/astra/PyProjector3DFactory.pxd
+++ b/python/astra/PyProjector3DFactory.pxd
@@ -29,7 +29,7 @@ from .PyIncludes cimport *
cdef extern from "astra/AstraObjectFactory.h" namespace "astra":
cdef cppclass CProjector3DFactory:
- CProjector3D *create(Config)
+ CProjector3D *create(string)
cdef extern from "astra/AstraObjectFactory.h" namespace "astra::CProjector3DFactory":
cdef CProjector3DFactory* getSingletonPtr()
diff --git a/python/astra/algorithm_c.pyx b/python/astra/algorithm_c.pyx
index 0a48de8..9ed0634 100644
--- a/python/astra/algorithm_c.pyx
+++ b/python/astra/algorithm_c.pyx
@@ -53,11 +53,11 @@ def create(config):
alg = PyAlgorithmFactory.getSingletonPtr().create(cfg.self.getAttribute(six.b('type')))
if alg == NULL:
del cfg
- raise Exception("Unknown algorithm.")
+ raise Exception("Unknown Algorithm.")
if not alg.initialize(cfg[0]):
del cfg
del alg
- raise Exception("Algorithm not initialized.")
+ raise Exception("Unable to initialize Algorithm.")
del cfg
return manAlg.store(alg)
diff --git a/python/astra/projector3d_c.pyx b/python/astra/projector3d_c.pyx
index 98eccc1..7184535 100644
--- a/python/astra/projector3d_c.pyx
+++ b/python/astra/projector3d_c.pyx
@@ -53,10 +53,14 @@ IF HAVE_CUDA:
def create(config):
cdef Config * cfg = utils.dictToConfig(six.b('Projector3D'), config)
cdef CProjector3D * proj
- proj = PyProjector3DFactory.getSingletonPtr().create(cfg[0])
+ proj = PyProjector3DFactory.getSingletonPtr().create(cfg.self.getAttribute(six.b('type')))
if proj == NULL:
del cfg
- raise Exception("Error creating Projector3D.")
+ raise Exception("Unknown Projector3D type.")
+ if not proj.initialize(cfg[0]):
+ del cfg
+ del proj
+ raise Exception("Unable to initialize Projector3D.")
del cfg
return manProj.store(proj)
diff --git a/python/astra/projector_c.pyx b/python/astra/projector_c.pyx
index be529da..ddd59a5 100644
--- a/python/astra/projector_c.pyx
+++ b/python/astra/projector_c.pyx
@@ -57,10 +57,14 @@ IF HAVE_CUDA:
def create(config):
cdef Config * cfg = utils.dictToConfig(six.b('Projector2D'), config)
cdef CProjector2D * proj
- proj = PyProjector2DFactory.getSingletonPtr().create(cfg[0])
+ proj = PyProjector2DFactory.getSingletonPtr().create(cfg.self.getAttribute(six.b('type')))
if proj == NULL:
del cfg
- raise Exception("Error creating projector.")
+ raise Exception("Unknown Projector2D.")
+ if not proj.initialize(cfg[0]):
+ del cfg
+ del proj
+ raise Exception("Unable to initialize Projector2D.")
del cfg
return manProj.store(proj)
diff --git a/src/AsyncAlgorithm.cpp b/src/AsyncAlgorithm.cpp
index 54083a3..a53fb00 100644
--- a/src/AsyncAlgorithm.cpp
+++ b/src/AsyncAlgorithm.cpp
@@ -72,11 +72,13 @@ bool CAsyncAlgorithm::initialize(const Config& _cfg)
m_pAlg = 0;
m_bDone = false;
- m_pAlg = CAlgorithmFactory::getSingleton().create(_cfg);
- if (m_pAlg && !m_pAlg->isInitialized()) {
- if (m_bAutoFree)
- delete m_pAlg;
- m_pAlg = 0;
+ m_pAlg = CAlgorithmFactory::getSingleton().create(_cfg.self.getAttribute("type"));
+ if (m_pAlg) {
+ if (!m_pAlg->initialize(_cfg)) {
+ if (m_bAutoFree)
+ delete m_pAlg;
+ m_pAlg = 0;
+ }
}
m_bInitialized = (m_pAlg != 0);
m_bAutoFree = true;