summaryrefslogtreecommitdiffstats
path: root/python/astra/data2d_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/data2d_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/data2d_c.pyx')
-rw-r--r--python/astra/data2d_c.pyx21
1 files changed, 17 insertions, 4 deletions
diff --git a/python/astra/data2d_c.pyx b/python/astra/data2d_c.pyx
index b9c105e..ac54898 100644
--- a/python/astra/data2d_c.pyx
+++ b/python/astra/data2d_c.pyx
@@ -49,6 +49,10 @@ from .utils import wrap_from_bytes
cdef CData2DManager * man2d = <CData2DManager * >PyData2DManager.getSingletonPtr()
+cdef extern from "CFloat32CustomPython.h":
+ cdef cppclass CFloat32CustomPython:
+ CFloat32CustomPython(arrIn)
+
def clear():
man2d.clear()
@@ -61,11 +65,12 @@ def delete(ids):
man2d.remove(ids)
-def create(datatype, geometry, data=None):
+def create(datatype, geometry, data=None, link=False):
cdef Config *cfg
cdef CVolumeGeometry2D * pGeometry
cdef CProjectionGeometry2D * ppGeometry
cdef CFloat32Data2D * pDataObject2D
+ cdef CFloat32CustomMemory * pCustom
if datatype == '-vol':
cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry)
pGeometry = new CVolumeGeometry2D()
@@ -73,7 +78,11 @@ def create(datatype, geometry, data=None):
del cfg
del pGeometry
raise Exception('Geometry class not initialized.')
- pDataObject2D = <CFloat32Data2D * > new CFloat32VolumeData2D(pGeometry)
+ if link:
+ pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data)
+ pDataObject2D = <CFloat32Data2D * > new CFloat32VolumeData2D(pGeometry, pCustom)
+ else:
+ pDataObject2D = <CFloat32Data2D * > new CFloat32VolumeData2D(pGeometry)
del cfg
del pGeometry
elif datatype == '-sino':
@@ -91,7 +100,11 @@ def create(datatype, geometry, data=None):
del cfg
del ppGeometry
raise Exception('Geometry class not initialized.')
- pDataObject2D = <CFloat32Data2D * > new CFloat32ProjectionData2D(ppGeometry)
+ if link:
+ pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data)
+ pDataObject2D = <CFloat32Data2D * > new CFloat32ProjectionData2D(ppGeometry, pCustom)
+ else:
+ pDataObject2D = <CFloat32Data2D * > new CFloat32ProjectionData2D(ppGeometry)
del ppGeometry
del cfg
else:
@@ -101,7 +114,7 @@ def create(datatype, geometry, data=None):
del pDataObject2D
raise Exception("Couldn't initialize data object.")
- fillDataObject(pDataObject2D, data)
+ if not link: fillDataObject(pDataObject2D, data)
return man2d.store(pDataObject2D)