-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlibrary_truss.py
102 lines (96 loc) · 6.09 KB
/
library_truss.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
This file creates and returns the nodes of a truss and defines the containing cells.
"""
from Class_Truss import Truss
from library_cell import generate_cell
def generate_truss(truss_name, affix, cell_size, strut_thicknesses, number_of_cells, cell_ratio):
# NODES: Describe the nodes and their affiliated cells in cartesian coordinates.
cells = list()
nodes = list()
if (truss_name == "cubes" or truss_name == "body_centered_cubes" or truss_name == "octahedrons" or
truss_name == "truncated_cubes" or truss_name == "diamonds" or truss_name == "varying_truncated_cubes" or
truss_name == "face_diagonal_cubes" or truss_name == "octetrahedrons" or truss_name == "void_octetrahedrons" or
truss_name == "templar_crosses" or truss_name == "templar_alt_crosses" or truss_name == "tetroctas" or
truss_name == "truncated_octahedrons"):
cells.append(generate_cell(cell_name=truss_name[:len(truss_name) - 1], affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
for x in range(0, number_of_cells):
for y in range(0, number_of_cells):
for z in range(0, number_of_cells):
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[0]])
elif truss_name == "face_diagonal_cubes_alt":
cells.append(generate_cell(cell_name="face_diagonal_cube", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
cells.append(generate_cell(cell_name="face_diagonal_cube_inv", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
for x in range(0, number_of_cells):
for y in range(0, number_of_cells):
for z in range(0, number_of_cells):
if (x + y + z) % 2 == 0:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[0]])
else:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[1]])
elif truss_name == "templar_alt2_crosses":
cells.append(generate_cell(cell_name="templar_alt2_cross", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
cells.append(generate_cell(cell_name="templar_alt2_cross_inv", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
for x in range(0, number_of_cells):
for y in range(0, number_of_cells):
for z in range(0, number_of_cells):
if (x + y + z) % 2 == 0:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[0]])
else:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[1]])
elif truss_name == "pyramids":
cells.append(generate_cell(cell_name="pyramid", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
cells.append(generate_cell(cell_name="pyramid_inv", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
cells.append(generate_cell(cell_name="pyramid_twist", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
cells.append(generate_cell(cell_name="pyramid_twist_inv", affix="",
strut_thicknesses=strut_thicknesses, cell_size=cell_size, ratio=cell_ratio))
for x in range(0, number_of_cells):
for y in range(0, number_of_cells):
for z in range(0, number_of_cells):
if z % 2 == 0:
if y % 2 == 0:
if x % 2 == 0:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[0]])
else:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[3]])
else:
if x % 2 == 0:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[2]])
else:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[1]])
else:
if y % 2 == 0:
if x % 2 == 0:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[1]])
else:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[2]])
else:
if x % 2 == 0:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[3]])
else:
nodes.append([x * cell_size, y * cell_size, z * cell_size, cells[0]])
elif truss_name == "file_super_truss":
cells.append(generate_cell(cell_name="file_super_truss", affix="",
strut_thicknesses=[1], cell_size=1, ratio=cell_ratio))
nodes.append([0, 0, 0, cells[0]])
else:
print("Possible Names are: \n"
"cubes\nbody_centered_cubes\noctahedrons\ntruncated_cubes\npyramids\ndiamonds\nvarying_truncated_cubes\n"
"face_diagonal_cubes\nface_diagonal_cubes_alt\noctetrahedrons\nvoid_octetrahedrons\ntemplar_crosses\n"
"templar_alt_crosses\nfile_super_truss")
nodes = None
cells = None
exit("ERROR: truss_name specified is not defined in the library")
truss = Truss(name=(truss_name + affix),
nodes=nodes,
cells=cells,
cell_size=cell_size,
number_of_cells=number_of_cells)
return truss