1212from compas .colors import Color
1313from compas .geometry import Cylinder
1414
15- # ----------------------------------------
16- # 0. Vizualization function
17- # ----------------------------------------
18-
19- def visualization (vault , form ):
20- viewer = Viewer ()
21-
22- # viewer.scene.add(vault.middle, show_lines=False, name="Middle")
23- viewer .scene .add (vault .intrados , show_lines = False , name = "Intrados" , opacity = 0.5 )
24- viewer .scene .add (vault .extrados , show_lines = False , name = "Extrados" , opacity = 0.5 )
25-
26- edges = list (form .edges_where ({"_is_edge" : True }))
27-
28- max_thick = 0.1
29- forces = [form .edge_attribute (edge , "q" ) * form .edge_length (edge ) for edge in edges ]
30- fmax = math .sqrt (max (abs (max (forces )), abs (min (forces ))))
15+ from compas_tno .viewer import TNOViewer
3116
32- pipes = []
33- for edge in edges :
34- qi = form .edge_attribute (edge , "q" )
35- line = form .edge_line (edge )
36- length = line .length
37- force = math .sqrt (abs (qi * length ))
38- radius = force / fmax * max_thick
39- pipe = Cylinder .from_line_and_radius (line , radius )
40- if force > 1e-3 :
41- pipes .append (pipe )
42- viewer .scene .add (pipe , color = Color .red ())
43-
44- # viewer.scene.add(pipes, name="Pipes", color=Color.red())
45-
46- viewer .show ()
4717
4818# ----------------------------------------
4919# 1. Shape geometric definition
@@ -60,7 +30,7 @@ def visualization(vault, form):
6030discretisation = 8
6131form = FormDiagram .create_cross_form (xy_span = xy_span , discretisation = discretisation )
6232
63- load_pos = 3
33+ load_pos = 2
6434xc = yc = L / 2
6535yp = 2.5
6636yp = yc - load_pos / (discretisation / 2 ) * yc
@@ -76,14 +46,15 @@ def visualization(vault, form):
7646 if y < yc :
7747 supports .append (key )
7848
79- print (loaded_node , supports )
49+ if load_pos != 0 :
50+ print (loaded_node , supports )
51+ form , loaded_node = form_add_lines_support (form , loaded_node = loaded_node , supports = supports )
8052
81- form , loaded_node = form_add_lines_support ( form , loaded_node = loaded_node , supports = supports )
53+ # visualization(None, form )
8254
83- # plotter = TNOPlotter(form)
84- # plotter.draw_form(scale_width=False, color=Color.black())
85- # plotter.draw_supports(color=Color.red())
86- # plotter.show()
55+ viewer = Viewer ()
56+ viewer .scene .add (form , name = "Form" , color = Color .black ())
57+ viewer .show ()
8758
8859# ------------------------------------------------------------------------
8960# 4. Define applied load case
@@ -99,26 +70,11 @@ def visualization(vault, form):
9970# --------------------------------------------
10071analysis = Analysis .create_max_load_analysis (form , vault ,
10172 load_direction = load_direction ,
102- max_lambd = 300 ,
73+ max_lambd = 10000 ,
10374 printout = True )
10475analysis .apply_selfweight ()
10576analysis .apply_envelope ()
10677analysis .set_up_optimiser ()
10778analysis .run ()
10879
109- visualization (vault , form )
110-
111- # viewer = Viewer(form)
112- # viewer.settings["scale.reactions"] = 0.004
113- # viewer.draw_thrust()
114- # viewer.draw_cracks()
115- # viewer.draw_shape()
116- # viewer.draw_reactions()
117-
118- # length = 2.0
119- # x, y, z = form.vertex_coordinates(loaded_node)
120- # z += length + 0.1
121- # arrow = Arrow([x, y, z], [0, 0, -length])
122- # viewer.app.add(arrow, linecolor=(0, 0, 0), facecolor=(0, 0, 0))
123-
124- # viewer.show()
80+ TNOViewer (form , vault ).show ()
0 commit comments