summaryrefslogtreecommitdiffstats
path: root/python/astra/data3d_c.pyx
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2015-04-14 14:54:38 +0200
committerWillem Jan Palenstijn <wjp@usecode.org>2015-04-14 14:54:38 +0200
commitd24877997bfe77e7177e3208328d99e1f99ac6b9 (patch)
tree58a86e22618775acfb5e761201727eec558c9200 /python/astra/data3d_c.pyx
parent306b3b5613ccb039122d38e8deb1e0ecc9e43403 (diff)
parent1b32573046f33050b9300324e6c74e10abb6caaf (diff)
downloadastra-d24877997bfe77e7177e3208328d99e1f99ac6b9.tar.gz
astra-d24877997bfe77e7177e3208328d99e1f99ac6b9.tar.bz2
astra-d24877997bfe77e7177e3208328d99e1f99ac6b9.tar.xz
astra-d24877997bfe77e7177e3208328d99e1f99ac6b9.zip
Merge pull request #51 from dmpelt/python-link
Add 'link' feature to Python (for 2D and 3D data)
Diffstat (limited to 'python/astra/data3d_c.pyx')
-rw-r--r--python/astra/data3d_c.pyx27
1 files changed, 22 insertions, 5 deletions
diff --git a/python/astra/data3d_c.pyx b/python/astra/data3d_c.pyx
index 4b069f7..f2c6e26 100644
--- a/python/astra/data3d_c.pyx
+++ b/python/astra/data3d_c.pyx
@@ -50,12 +50,17 @@ cdef CData3DManager * man3d = <CData3DManager * >PyData3DManager.getSingletonPtr
cdef extern from *:
CFloat32Data3DMemory * dynamic_cast_mem "dynamic_cast<astra::CFloat32Data3DMemory*>" (CFloat32Data3D * ) except NULL
-def create(datatype,geometry,data=None):
+cdef extern from "CFloat32CustomPython.h":
+ cdef cppclass CFloat32CustomPython:
+ CFloat32CustomPython(arrIn)
+
+def create(datatype,geometry,data=None, link=False):
cdef Config *cfg
cdef CVolumeGeometry3D * pGeometry
cdef CProjectionGeometry3D * ppGeometry
cdef CFloat32Data3DMemory * pDataObject3D
cdef CConeProjectionGeometry3D* pppGeometry
+ cdef CFloat32CustomMemory * pCustom
if datatype == '-vol':
cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry)
pGeometry = new CVolumeGeometry3D()
@@ -63,7 +68,11 @@ def create(datatype,geometry,data=None):
del cfg
del pGeometry
raise Exception('Geometry class not initialized.')
- pDataObject3D = <CFloat32Data3DMemory * > new CFloat32VolumeData3DMemory(pGeometry)
+ if link:
+ pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data)
+ pDataObject3D = <CFloat32Data3DMemory * > new CFloat32VolumeData3DMemory(pGeometry, pCustom)
+ else:
+ pDataObject3D = <CFloat32Data3DMemory * > new CFloat32VolumeData3DMemory(pGeometry)
del cfg
del pGeometry
elif datatype == '-sino' or datatype == '-proj3d':
@@ -84,7 +93,11 @@ def create(datatype,geometry,data=None):
del cfg
del ppGeometry
raise Exception('Geometry class not initialized.')
- pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(ppGeometry)
+ if link:
+ pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data)
+ pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(ppGeometry, pCustom)
+ else:
+ pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(ppGeometry)
del ppGeometry
del cfg
elif datatype == "-sinocone":
@@ -94,7 +107,11 @@ def create(datatype,geometry,data=None):
del cfg
del pppGeometry
raise Exception('Geometry class not initialized.')
- pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(pppGeometry)
+ if link:
+ pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data)
+ pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(pppGeometry, pCustom)
+ else:
+ pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(pppGeometry)
else:
raise Exception("Invalid datatype. Please specify '-vol' or '-proj3d'.")
@@ -102,7 +119,7 @@ def create(datatype,geometry,data=None):
del pDataObject3D
raise Exception("Couldn't initialize data object.")
- fillDataObject(pDataObject3D, data)
+ if not link: fillDataObject(pDataObject3D, data)
pDataObject3D.updateStatistics()