summaryrefslogtreecommitdiff
path: root/src/python/gudhi/alpha_complex.pyx
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-05-23 08:45:13 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-05-23 08:45:13 +0200
commit28a6889dc9865c75acc3d3be4edce01b3942e56f (patch)
tree9ae925c8b3c4fa43c796606357ab779fc368ada1 /src/python/gudhi/alpha_complex.pyx
parent4826b8bf49aafb23c57eb6983c886235e8f7c0b2 (diff)
First working version
Diffstat (limited to 'src/python/gudhi/alpha_complex.pyx')
-rw-r--r--src/python/gudhi/alpha_complex.pyx18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx
index dc2fcb01..e2d3db9c 100644
--- a/src/python/gudhi/alpha_complex.pyx
+++ b/src/python/gudhi/alpha_complex.pyx
@@ -63,7 +63,8 @@ cdef class AlphaComplex:
cdef Alpha_complex_exact_interface * exact_ptr
cdef Alpha_complex_inexact_interface * inexact_ptr
- complexity = 'safe'
+ cdef bool fast
+ cdef bool exact
# Fake constructor that does nothing but documenting the constructor
def __init__(self, points=None, off_file='', complexity='safe'):
@@ -84,12 +85,13 @@ cdef class AlphaComplex:
# The real cython constructor
def __cinit__(self, points = None, off_file = '', complexity = 'safe'):
assert complexity == 'fast' or complexity == 'safe' or complexity == 'exact', "Alpha complex complexity can be 'fast', 'safe' or 'exact'"
- self.complexity = complexity
+ self.fast = complexity == 'fast'
+ self.exact = complexity == 'safe'
cdef vector[vector[double]] pts
if off_file:
if os.path.isfile(off_file):
- if complexity == 'fast':
+ if self.fast:
self.inexact_ptr = new Alpha_complex_inexact_interface(off_file.encode('utf-8'), True)
else:
self.exact_ptr = new Alpha_complex_exact_interface(off_file.encode('utf-8'), True)
@@ -100,7 +102,7 @@ cdef class AlphaComplex:
# Empty Alpha construction
points=[]
pts = points
- if complexity == 'fast':
+ if self.fast:
with nogil:
self.inexact_ptr = new Alpha_complex_inexact_interface(pts)
else:
@@ -108,7 +110,7 @@ cdef class AlphaComplex:
self.exact_ptr = new Alpha_complex_exact_interface(pts)
def __dealloc__(self):
- if self.complexity == 'fast':
+ if self.fast:
if self.inexact_ptr != NULL:
del self.inexact_ptr
else:
@@ -118,7 +120,7 @@ cdef class AlphaComplex:
def __is_defined(self):
"""Returns true if AlphaComplex pointer is not NULL.
"""
- if self.complexity == 'fast':
+ if self.fast:
return self.inexact_ptr != NULL
else:
return self.exact_ptr != NULL
@@ -131,7 +133,7 @@ cdef class AlphaComplex:
:rtype: list of float
:returns: the point.
"""
- if self.complexity == 'fast':
+ if self.fast:
return self.inexact_ptr.get_point(vertex)
else:
return self.exact_ptr.get_point(vertex)
@@ -149,7 +151,7 @@ cdef class AlphaComplex:
stree = SimplexTree()
cdef double mas = max_alpha_square
cdef intptr_t stree_int_ptr=stree.thisptr
- if self.complexity == 'fast':
+ if self.fast:
with nogil:
self.inexact_ptr.create_simplex_tree(<Simplex_tree_interface_full_featured*>stree_int_ptr, mas)
else: