diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2015-05-13 11:56:24 +0200 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2015-05-13 11:56:24 +0200 |
commit | de30f7538a865a2ee7acb7dd8294fb6cdc4f98be (patch) | |
tree | ba11189e6e83e83e73167518b45641fc287c8eda /python/astra/data2d_c.pyx | |
parent | 6504cffdbe74d9b671222a7ec24b26fbb4f871f0 (diff) | |
parent | 86ad56f005d9d3871f654390739459d5634dd5d5 (diff) | |
download | astra-de30f7538a865a2ee7acb7dd8294fb6cdc4f98be.tar.gz astra-de30f7538a865a2ee7acb7dd8294fb6cdc4f98be.tar.bz2 astra-de30f7538a865a2ee7acb7dd8294fb6cdc4f98be.tar.xz astra-de30f7538a865a2ee7acb7dd8294fb6cdc4f98be.zip |
Merge branch 'master'
Diffstat (limited to 'python/astra/data2d_c.pyx')
-rw-r--r-- | python/astra/data2d_c.pyx | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/python/astra/data2d_c.pyx b/python/astra/data2d_c.pyx index b9c105e..4919bf2 100644 --- a/python/astra/data2d_c.pyx +++ b/python/astra/data2d_c.pyx @@ -47,8 +47,18 @@ from .PyIncludes cimport * cimport utils from .utils import wrap_from_bytes +from .pythonutils import geom_size + +import operator + +from six.moves import reduce + cdef CData2DManager * man2d = <CData2DManager * >PyData2DManager.getSingletonPtr() +cdef extern from "CFloat32CustomPython.h": + cdef cppclass CFloat32CustomPython: + CFloat32CustomPython(arrIn) + def clear(): man2d.clear() @@ -61,11 +71,16 @@ 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 link and data.shape!=geom_size(geometry): + raise Exception("The dimensions of the data do not match those specified in the geometry.") + if datatype == '-vol': cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry) pGeometry = new CVolumeGeometry2D() @@ -73,7 +88,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 +110,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 +124,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) |