-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenumerator.py
More file actions
34 lines (30 loc) · 1.09 KB
/
enumerator.py
File metadata and controls
34 lines (30 loc) · 1.09 KB
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
from shape import *
###############################################################################
class ShapeEnumerator:
def __init__(self, bond_count, allbonds, gauges, disregard = []):
self.shapes = []
self.gauges = gauges
self.disregard = disregard
self.bond_count = bond_count
self.bond_enumerate([], bond_count, allbonds)
print " " + str(len(self.shapes)) + " shapes"
def bond_enumerate(self, bonds, bond_count, bonds_left, intersect = False):
left_copy = list(bonds_left)
for bond in bonds_left:
left_copy.remove(bond)
bonds_copy = list(bonds)
bond_skip = False
for bond2 in bonds_copy:
if (bond2.intersects(bond) and (not intersect)):
bond_skip = True
break
if (bond_skip):
continue
bonds_copy.append(bond)
if (bond_count == 1):
new_shape = Shape(bonds = bonds_copy)
if ((new_shape not in self.gauges) and
(new_shape not in self.disregard)):
self.shapes.append(new_shape)
else:
self.bond_enumerate(bonds_copy, bond_count-1, left_copy)