-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelators_to_tri.py
More file actions
44 lines (32 loc) · 1019 Bytes
/
relators_to_tri.py
File metadata and controls
44 lines (32 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import snappy as sp
import diagram_data as dd
import extraction as ext
import os
def relators_to_tri(relators, heegaard_bin, name=None,
clean_up=False, verbose=False):
if not name:
name = '_'.join(relators)
datum, err = dd.get_diagram_data(relators, heegaard_bin)
if err:
datum, err = dd.get_diagram_data(relators, heegaard_bin, reduce=True)
if err:
print('Error getting diagram: {}\n {}'.format(err, datum))
sur_file = name + '.sur'
sur_string = ext.heegaard_to_twister(datum)
if sur_string is None:
return None
with open(sur_file, 'w') as fp:
fp.write(sur_string)
sur = sp.twister.Surface(sur_file)
rels = datum[0] #TODO fix this convertion
gens = list(set(''.join(rels).lower()))
handles = '*'.join(gens + rels)
manifold = sur.splitting('', handles)
if verbose:
print(manifold.identify())
tri_file = name + '.tri'
manifold.save(tri_file)
if clean_up:
os.remove(sur_file)
os.remove(tri_file)
return manifold