Skip to content

Commit 544081c

Browse files
committed
Orb fundamental group
1 parent 84783e7 commit 544081c

18 files changed

Lines changed: 9240 additions & 4047 deletions

File tree

src/snappy/extensions/Orb/cython_src/Orb.pxi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cdef extern from *:
1+
cdef extern from "SnapPea.h":
22

33
ctypedef enum c_SolutionType "SolutionType":
44
not_attempted
@@ -18,12 +18,17 @@ cdef extern from *:
1818
extern c_SolutionType find_structure(c_Triangulation *manifold, Boolean) except *
1919
extern Real my_volume(c_Triangulation *manifold, Boolean * ok) except *
2020

21+
extern int get_num_cusps(c_Triangulation *manifold) except *
22+
extern int get_num_or_cusps(c_Triangulation *manifold) except *
23+
extern int get_num_nonor_cusps(c_Triangulation *manifold) except *
24+
2125
cdef extern from "kernel_prototypes.h":
2226
extern void remove_finite_vertices(c_Triangulation *manifold)
2327

2428
cdef extern from "triangulation.h":
2529
ctypedef struct c_Triangulation "Triangulation":
2630
int num_tetrahedra
31+
2732

2833
cdef extern from "unix_file_io.h":
2934
extern c_Triangulation *read_triangulation(char *file_name)
@@ -52,3 +57,4 @@ cdef extern from "orb_io.h":
5257
char *file_data,
5358
c_Triangulation ** trig,
5459
c_Diagram ** diagram)
60+

src/snappy/extensions/Orb/cython_src/Orbcore.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ include "Orb.pxi"
44
include "../../shared/cython_src/basic_conversions.pyx"
55
include "../../shared/cython_src/number_conversions.pyx"
66
include "../../shared/cython_src/ui_functions.pyx"
7+
include "../../shared/cython_src/basic.pyx"
78
include "core/basic.pyx"
89
include "core/orb_triangulation.pyx"
910
include "core/orbifold.pyx"
11+
include "core/fundamental_group.pyx"

src/snappy/extensions/Orb/cython_src/core/basic.pyx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
# Python modules
2+
import os
3+
import sys
4+
import re
5+
import time
6+
7+
# Sage interaction
8+
from ..sage_helper import _within_sage, SageNotAvailable
9+
try:
10+
from sage.groups.free_group import FreeGroup
11+
except ImportError:
12+
pass
13+
14+
from ..matrix import matrix
115
from .. import number
216

3-
import os, sys, time
17+
# SnapPy components
18+
from .. import snap
419

520
SolutionType = [
621
'not attempted',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ctypedef OrbTriangulation Triangulation
2+
3+
include "../../../SnapPy/cython_src/core/fundamental_group.pyx"

src/snappy/extensions/Orb/cython_src/core/orb_triangulation.pyx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from ..cache import SnapPyCache
2+
13
cdef class OrbTriangulation:
24
"""
35
@@ -9,10 +11,12 @@ cdef class OrbTriangulation:
911

1012
cdef c_Triangulation* c_triangulation
1113
cdef c_Diagram* c_diagram
14+
cdef readonly _cache
1215

1316
def __cinit__(self, spec=None, remove_finite_vertices=True):
1417
self.c_triangulation = NULL
1518
self.c_diagram = NULL
19+
self._cache = SnapPyCache()
1620

1721
for attr in [
1822
'_to_orb_string',
@@ -162,3 +166,41 @@ cdef class OrbTriangulation:
162166
self.c_diagram, True)
163167

164168
return True
169+
170+
def fundamental_group(
171+
self,
172+
simplify_presentation : bool = True,
173+
fillings_may_affect_generators : bool = True,
174+
minimize_number_of_generators : bool = True,
175+
try_hard_to_shorten_relators : bool = True
176+
) -> FundamentalGroup:
177+
if self.c_triangulation is NULL:
178+
raise ValueError('The Triangulation is empty.')
179+
args = (simplify_presentation, fillings_may_affect_generators,
180+
minimize_number_of_generators, try_hard_to_shorten_relators)
181+
try:
182+
return self._cache.lookup('fundamental_group', *args)
183+
except KeyError:
184+
pass
185+
186+
return self._cache.save(FundamentalGroup(self, *args),
187+
'fundamental_group', *args)
188+
189+
def num_cusps(self, cusp_type='all') -> int:
190+
"""
191+
Return the total number of cusps. By giving the optional argument
192+
'orientable' or 'nonorientable' it will only count cusps of that type.
193+
194+
>>> M = Triangulation('m125')
195+
>>> M.num_cusps()
196+
2
197+
"""
198+
if cusp_type == 'all':
199+
return get_num_cusps(self.c_triangulation)
200+
elif cusp_type == 'orientable':
201+
return get_num_or_cusps(self.c_triangulation)
202+
elif cusp_type == 'nonorientable':
203+
return get_num_nonor_cusps(self.c_triangulation)
204+
else:
205+
raise ValueError("Acceptable cusp types are "
206+
"['all', 'orientable', 'nonorientable'].")

0 commit comments

Comments
 (0)