summaryrefslogtreecommitdiffstats
path: root/python/astra/data2d_c.pyx
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2015-12-04 12:05:38 +0100
committerWillem Jan Palenstijn <wjp@usecode.org>2015-12-04 12:05:38 +0100
commit7ba1ff9ff08daf043cc131434373cde38434f46b (patch)
tree99fc05d3d90a27d61eaf9d14602a30068cf55b83 /python/astra/data2d_c.pyx
parentc335c53178cf63374599682dfbd7e08d318a20f2 (diff)
parent4621453bb753f17614b8ac4b6314a142ecbe278c (diff)
downloadastra-7ba1ff9ff08daf043cc131434373cde38434f46b.tar.gz
astra-7ba1ff9ff08daf043cc131434373cde38434f46b.tar.bz2
astra-7ba1ff9ff08daf043cc131434373cde38434f46b.tar.xz
astra-7ba1ff9ff08daf043cc131434373cde38434f46b.zip
Merge pull request #73 from dmpelt/python-plugins
Add support for Python algorithm plugins
Diffstat (limited to 'python/astra/data2d_c.pyx')
-rw-r--r--python/astra/data2d_c.pyx27
1 files changed, 26 insertions, 1 deletions
diff --git a/python/astra/data2d_c.pyx b/python/astra/data2d_c.pyx
index 4919bf2..801fd8e 100644
--- a/python/astra/data2d_c.pyx
+++ b/python/astra/data2d_c.pyx
@@ -34,6 +34,9 @@ from cython cimport view
cimport PyData2DManager
from .PyData2DManager cimport CData2DManager
+cimport PyProjector2DManager
+from .PyProjector2DManager cimport CProjector2DManager
+
cimport PyXMLDocument
from .PyXMLDocument cimport XMLDocument
@@ -54,6 +57,8 @@ import operator
from six.moves import reduce
cdef CData2DManager * man2d = <CData2DManager * >PyData2DManager.getSingletonPtr()
+cdef CProjector2DManager * manProj = <CProjector2DManager * >PyProjector2DManager.getSingletonPtr()
+
cdef extern from "CFloat32CustomPython.h":
cdef cppclass CFloat32CustomPython:
@@ -164,7 +169,6 @@ def store(i, data):
cdef CFloat32Data2D * pDataObject = getObject(i)
fillDataObject(pDataObject, data)
-
def get_geometry(i):
cdef CFloat32Data2D * pDataObject = getObject(i)
cdef CFloat32ProjectionData2D * pDataObject2
@@ -179,6 +183,27 @@ def get_geometry(i):
raise Exception("Not a known data object")
return geom
+cdef CProjector2D * getProjector(i) except NULL:
+ cdef CProjector2D * proj = manProj.get(i)
+ if proj == NULL:
+ raise Exception("Projector not initialized.")
+ if not proj.isInitialized():
+ raise Exception("Projector not initialized.")
+ return proj
+
+def check_compatible(i, proj_id):
+ cdef CProjector2D * proj = getProjector(proj_id)
+ cdef CFloat32Data2D * pDataObject = getObject(i)
+ cdef CFloat32ProjectionData2D * pDataObject2
+ cdef CFloat32VolumeData2D * pDataObject3
+ if pDataObject.getType() == TWOPROJECTION:
+ pDataObject2 = <CFloat32ProjectionData2D * >pDataObject
+ return pDataObject2.getGeometry().isEqual(proj.getProjectionGeometry())
+ elif pDataObject.getType() == TWOVOLUME:
+ pDataObject3 = <CFloat32VolumeData2D * >pDataObject
+ return pDataObject3.getGeometry().isEqual(proj.getVolumeGeometry())
+ else:
+ raise Exception("Not a known data object")
def change_geometry(i, geom):
cdef Config *cfg