summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-23 12:14:28 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-23 12:14:28 +0200
commit71d27819b1b046109b5c70e3bd112f436e96a545 (patch)
treea9e5d954745c4055b9beacdd0605d703a7a6514c
parent521825da92af4d3a08609241353517b8ec7e780c (diff)
downloadastra-71d27819b1b046109b5c70e3bd112f436e96a545.tar.gz
astra-71d27819b1b046109b5c70e3bd112f436e96a545.tar.bz2
astra-71d27819b1b046109b5c70e3bd112f436e96a545.tar.xz
astra-71d27819b1b046109b5c70e3bd112f436e96a545.zip
Support 2d/3d in astra.algorithm.get_res_norm
-rw-r--r--python/astra/PyIncludes.pxd4
-rw-r--r--python/astra/algorithm_c.pyx17
2 files changed, 16 insertions, 5 deletions
diff --git a/python/astra/PyIncludes.pxd b/python/astra/PyIncludes.pxd
index c091963..512b82f 100644
--- a/python/astra/PyIncludes.pxd
+++ b/python/astra/PyIncludes.pxd
@@ -152,6 +152,10 @@ cdef extern from "astra/ReconstructionAlgorithm2D.h" namespace "astra":
cdef cppclass CReconstructionAlgorithm2D:
bool getResidualNorm(float32&)
+cdef extern from "astra/ReconstructionAlgorithm3D.h" namespace "astra":
+ cdef cppclass CReconstructionAlgorithm3D:
+ bool getResidualNorm(float32&)
+
cdef extern from "astra/Projector2D.h" namespace "astra":
cdef cppclass CProjector2D:
bool isInitialized()
diff --git a/python/astra/algorithm_c.pyx b/python/astra/algorithm_c.pyx
index 9ed0634..161fe98 100644
--- a/python/astra/algorithm_c.pyx
+++ b/python/astra/algorithm_c.pyx
@@ -44,7 +44,8 @@ from .utils import wrap_from_bytes
cdef CAlgorithmManager * manAlg = <CAlgorithmManager * >PyAlgorithmManager.getSingletonPtr()
cdef extern from *:
- CReconstructionAlgorithm2D * dynamic_cast_recAlg "dynamic_cast<astra::CReconstructionAlgorithm2D*>" (CAlgorithm * ) except NULL
+ CReconstructionAlgorithm2D * dynamic_cast_recAlg2D "dynamic_cast<astra::CReconstructionAlgorithm2D*>" (CAlgorithm * )
+ CReconstructionAlgorithm3D * dynamic_cast_recAlg3D "dynamic_cast<astra::CReconstructionAlgorithm3D*>" (CAlgorithm * )
def create(config):
@@ -79,12 +80,18 @@ def run(i, iterations=0):
def get_res_norm(i):
cdef CReconstructionAlgorithm2D * pAlg2D
+ cdef CReconstructionAlgorithm3D * pAlg3D
cdef CAlgorithm * alg = getAlg(i)
cdef float32 res = 0.0
- pAlg2D = dynamic_cast_recAlg(alg)
- if pAlg2D == NULL:
- raise Exception("Operation not supported.")
- if not pAlg2D.getResidualNorm(res):
+ pAlg2D = dynamic_cast_recAlg2D(alg)
+ pAlg3D = dynamic_cast_recAlg3D(alg)
+ if pAlg2D != NULL:
+ if not pAlg2D.getResidualNorm(res):
+ raise Exception("Operation not supported.")
+ elif pAlg3D != NULL:
+ if not pAlg3D.getResidualNorm(res):
+ raise Exception("Operation not supported.")
+ else:
raise Exception("Operation not supported.")
return res