diff options
author | Wim van Aarle <wimvanaarle@gmail.com> | 2015-03-18 11:08:20 +0100 |
---|---|---|
committer | Wim van Aarle <wimvanaarle@gmail.com> | 2015-03-18 11:08:20 +0100 |
commit | fb01aaf4cd4e7f22308e07bd94dcfc97083e8ec8 (patch) | |
tree | f61cc9842bfc1875d9fc4fa37a697efb3bba8895 /python/astra/data3d_c.pyx | |
parent | c9730a84bd2be4fa2df2fd2ef947a624e9a09f02 (diff) | |
download | astra-fb01aaf4cd4e7f22308e07bd94dcfc97083e8ec8.tar.gz astra-fb01aaf4cd4e7f22308e07bd94dcfc97083e8ec8.tar.bz2 astra-fb01aaf4cd4e7f22308e07bd94dcfc97083e8ec8.tar.xz astra-fb01aaf4cd4e7f22308e07bd94dcfc97083e8ec8.zip |
updated python bindings
Diffstat (limited to 'python/astra/data3d_c.pyx')
-rw-r--r-- | python/astra/data3d_c.pyx | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/python/astra/data3d_c.pyx b/python/astra/data3d_c.pyx index f821aaf..4b069f7 100644 --- a/python/astra/data3d_c.pyx +++ b/python/astra/data3d_c.pyx @@ -51,26 +51,23 @@ cdef extern from *: CFloat32Data3DMemory * dynamic_cast_mem "dynamic_cast<astra::CFloat32Data3DMemory*>" (CFloat32Data3D * ) except NULL def create(datatype,geometry,data=None): - cdef XMLDocument * xml - cdef Config cfg + cdef Config *cfg cdef CVolumeGeometry3D * pGeometry cdef CProjectionGeometry3D * ppGeometry cdef CFloat32Data3DMemory * pDataObject3D cdef CConeProjectionGeometry3D* pppGeometry if datatype == '-vol': - xml = utils.dict2XML(six.b('VolumeGeometry'), geometry) - cfg.self = xml.getRootNode() + cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry) pGeometry = new CVolumeGeometry3D() - if not pGeometry.initialize(cfg): - del xml + if not pGeometry.initialize(cfg[0]): + del cfg del pGeometry raise Exception('Geometry class not initialized.') pDataObject3D = <CFloat32Data3DMemory * > new CFloat32VolumeData3DMemory(pGeometry) - del xml + del cfg del pGeometry elif datatype == '-sino' or datatype == '-proj3d': - xml = utils.dict2XML(six.b('ProjectionGeometry'), geometry) - cfg.self = xml.getRootNode() + cfg = utils.dictToConfig(six.b('ProjectionGeometry'), geometry) tpe = wrap_from_bytes(cfg.self.getAttribute(six.b('type'))) if (tpe == "parallel3d"): ppGeometry = <CProjectionGeometry3D*> new CParallelProjectionGeometry3D(); @@ -83,19 +80,18 @@ def create(datatype,geometry,data=None): else: raise Exception("Invalid geometry type.") - if not ppGeometry.initialize(cfg): - del xml + if not ppGeometry.initialize(cfg[0]): + del cfg del ppGeometry raise Exception('Geometry class not initialized.') pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(ppGeometry) del ppGeometry - del xml + del cfg elif datatype == "-sinocone": - xml = utils.dict2XML(six.b('ProjectionGeometry'), geometry) - cfg.self = xml.getRootNode() + cfg = utils.dictToConfig(six.b('ProjectionGeometry'), geometry) pppGeometry = new CConeProjectionGeometry3D() - if not pppGeometry.initialize(cfg): - del xml + if not pppGeometry.initialize(cfg[0]): + del cfg del pppGeometry raise Exception('Geometry class not initialized.') pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(pppGeometry) @@ -112,6 +108,19 @@ def create(datatype,geometry,data=None): return man3d.store(<CFloat32Data3D*>pDataObject3D) +def get_geometry(i): + cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem(getObject(i)) + cdef CFloat32ProjectionData3DMemory * pDataObject2 + cdef CFloat32VolumeData3DMemory * pDataObject3 + if pDataObject.getType() == THREEPROJECTION: + pDataObject2 = <CFloat32ProjectionData3DMemory * >pDataObject + geom = utils.configToDict(pDataObject2.getGeometry().getConfiguration()) + elif pDataObject.getType() == THREEVOLUME: + pDataObject3 = <CFloat32VolumeData3DMemory * >pDataObject + geom = utils.configToDict(pDataObject3.getGeometry().getConfiguration()) + else: + raise Exception("Not a known data object") + return geom cdef fillDataObject(CFloat32Data3DMemory * obj, data): if data is None: |