summaryrefslogtreecommitdiffstats
path: root/python/astra/astra_c.pyx
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-07-28 17:05:24 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-07-28 17:05:24 +0200
commitb2611a03577c285ddf48edab0d05dafa09ab362c (patch)
treec1d2f1b5166ba23f55e68e8faf0832f7c540f787 /python/astra/astra_c.pyx
parent1ff4a270a7df1edb54dd91fe653d6a936b959b3a (diff)
parent53249b3ad63f0d08b9862a75602acf263d230d77 (diff)
downloadastra-b2611a03577c285ddf48edab0d05dafa09ab362c.tar.gz
astra-b2611a03577c285ddf48edab0d05dafa09ab362c.tar.bz2
astra-b2611a03577c285ddf48edab0d05dafa09ab362c.tar.xz
astra-b2611a03577c285ddf48edab0d05dafa09ab362c.zip
Merge branch 'master' into parvec
Diffstat (limited to 'python/astra/astra_c.pyx')
-rw-r--r--python/astra/astra_c.pyx113
1 files changed, 77 insertions, 36 deletions
diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx
index 342a214..8e30e69 100644
--- a/python/astra/astra_c.pyx
+++ b/python/astra/astra_c.pyx
@@ -1,28 +1,28 @@
-#-----------------------------------------------------------------------
-#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam
+# -----------------------------------------------------------------------
+# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp
+# 2013-2016, CWI, Amsterdam
#
-#Author: Daniel M. Pelt
-#Contact: D.M.Pelt@cwi.nl
-#Website: http://dmpelt.github.io/pyastratoolbox/
+# Contact: astra@uantwerpen.be
+# Website: http://sf.net/projects/astra-toolbox
#
+# This file is part of the ASTRA Toolbox.
#
-#This file is part of the Python interface to the
-#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
#
-#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify
-#it under the terms of the GNU General Public License as published by
-#the Free Software Foundation, either version 3 of the License, or
-#(at your option) any later version.
+# The ASTRA Toolbox is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
#
-#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#GNU General Public License for more details.
+# The ASTRA Toolbox is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-#You should have received a copy of the GNU General Public License
-#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License
+# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+#
+# -----------------------------------------------------------------------
#
-#-----------------------------------------------------------------------
# distutils: language = c++
# distutils: libraries = astra
@@ -31,7 +31,11 @@ import six
from .utils import wrap_from_bytes
from libcpp.string cimport string
+from libcpp.vector cimport vector
from libcpp cimport bool
+cimport PyIndexManager
+from .PyIndexManager cimport CAstraObjectManagerBase
+
cdef extern from "astra/Globals.h" namespace "astra":
int getVersion()
string getVersionString()
@@ -43,23 +47,28 @@ IF HAVE_CUDA==True:
ELSE:
def setGPUIndex():
pass
+cdef extern from "astra/CompositeGeometryManager.h" namespace "astra":
+ cdef cppclass SGPUParams:
+ vector[int] GPUIndices
+ size_t memory
+cdef extern from "astra/CompositeGeometryManager.h" namespace "astra::CCompositeGeometryManager":
+ void setGlobalGPUParams(SGPUParams&)
-def credits():
- six.print_("""
-All Scale Tomographic Reconstruction Antwerp Toolbox (ASTRA-Toolbox)
-was developed at the University of Antwerp by
- * Prof. dr. Joost Batenburg
- * Andrei Dabravolski
- * Gert Merckx
- * Willem Jan Palenstijn
- * Tom Roelandts
- * Prof. dr. Jan Sijbers
- * dr. Wim van Aarle
- * Sander van der Maar
- * dr. Gert Van Gompel
-Python interface written by
- * Daniel M. Pelt (CWI, Amsterdam)""")
+def credits():
+ six.print_("""The ASTRA Toolbox has been developed at the University of Antwerp and CWI, Amsterdam by
+ * Prof. dr. Joost Batenburg
+ * Prof. dr. Jan Sijbers
+ * Dr. Jeroen Bedorf
+ * Dr. Folkert Bleichrodt
+ * Dr. Andrei Dabravolski
+ * Dr. Willem Jan Palenstijn
+ * Dr. Tom Roelandts
+ * Dr. Wim van Aarle
+ * Dr. Gert Van Gompel
+ * Sander van der Maar, MSc.
+ * Gert Merckx, MSc.
+ * Daan Pelt, MSc.""")
def use_cuda():
@@ -72,8 +81,40 @@ def version(printToScreen=False):
else:
return getVersion()
-def set_gpu_index(idx):
+IF HAVE_CUDA==True:
+ def set_gpu_index(idx, memory=0):
+ import collections
+ cdef SGPUParams params
if use_cuda()==True:
- ret = setGPUIndex(idx)
+ if not isinstance(idx, collections.Iterable) or isinstance(idx, six.string_types + (six.text_type,six.binary_type)):
+ idx = (idx,)
+ params.memory = memory
+ params.GPUIndices = idx
+ setGlobalGPUParams(params)
+ ret = setGPUIndex(params.GPUIndices[0])
if not ret:
- six.print_("Failed to set GPU " + str(idx))
+ six.print_("Failed to set GPU " + str(params.GPUIndices[0]))
+ELSE:
+ def set_gpu_index(idx, memory=0):
+ raise NotImplementedError("CUDA support is not enabled in ASTRA")
+
+def delete(ids):
+ import collections
+ cdef CAstraObjectManagerBase* ptr
+ if not isinstance(ids, collections.Iterable) or isinstance(ids, six.string_types + (six.text_type,six.binary_type)):
+ ids = (ids,)
+ for i in ids:
+ ptr = PyIndexManager.getSingletonPtr().get(i)
+ if ptr:
+ ptr.remove(i)
+
+def info(ids):
+ import collections
+ cdef CAstraObjectManagerBase* ptr
+ if not isinstance(ids, collections.Iterable) or isinstance(ids, six.string_types + (six.text_type,six.binary_type)):
+ ids = (ids,)
+ for i in ids:
+ ptr = PyIndexManager.getSingletonPtr().get(i)
+ if ptr:
+ s = ptr.getType() + six.b("\t") + ptr.getInfo(i)
+ six.print_(wrap_from_bytes(s))