def mesh_scale(mesh, scale=1.0): points = [mesh.vertex_coordinates(key) for key in mesh.vertices()] points = scale_points(points, scale) for index, (key, attr) in enumerate(mesh.vertices(True)): x, y, z = points[index] attr['x'] = x attr['y'] = y attr['z'] = z
def constant_stress_fields(self): """ plots and calculates constant stress fields """ new_edg_f_dic = self.dic_attr['new_edg_f_dic'] map_edg_dic = self.dic_attr['map_edg_dic'] form_net = self.dic_attr['form_net'] force_90_net = self.dic_attr['force_90_net'] form_leaves = form_net.leaves() TH = 1.0 # [m] thickness of the coneret element SC = 1.0 / (self.sig_c * TH) # [m], [(kN/100)/m^2] # find convex hulls, anchor lines and memeber CLs for stress field hull_lis = [] ten_lines_dic = { } # {index:[[(pt1_line1),(pt2_line1)],[(pt1_line2),(pt2_line2)]]} ten_ind = 0 for edg, dual_edg in map_edg_dic.items(): if edg[0] in form_leaves: # to avoid producing extra anchor points at leaves CONST = 0 elif edg[1] in form_leaves: CONST = 1 else: CONST = 2 coor1 = form_net.node_coordinates(edg[0]) coor2 = form_net.node_coordinates(edg[1]) dual_coor1 = force_90_net.node_coordinates(dual_edg[0]) dual_coor2 = force_90_net.node_coordinates(dual_edg[1]) sc_pts_lis = scale_points([dual_coor1, dual_coor2], SC) if new_edg_f_dic[edg] > self.den_tol: # tension line_pts_lis = hf.sf_cl_anchor_lines(sc_pts_lis, [coor1, coor2], CONST) ten_lines_dic[ten_ind] = line_pts_lis ten_ind += 1 elif new_edg_f_dic[edg] < -self.den_tol: # compression hull = hf.minkowski_sum(sc_pts_lis, [coor1, coor2]) hull_lis.append(hull) hf.plot_stress_fields(hull_lis, ten_lines_dic) hf.sf_rhino_inputs(hull_lis, ten_lines_dic)
def test_scale_points(): assert scale_points([[0, 1, 2]], 5) == [[0, 5, 10]]
from compas.datastructures import Mesh from compas.datastructures import mesh_quads_to_triangles from compas.datastructures import mesh_flip_cycles from compas.plotters import MeshPlotter from compas.utilities import i_to_blue from compas.geometry import scale_points # mesh = Mesh.from_obj(compas.get('models/head-poses/head-reference.obj')) mesh = Mesh.from_obj(compas.get('models/camel-poses/camel-reference.obj')) mesh_flip_cycles(mesh) vertices = scale_points(mesh.get_vertices_attributes('xyz'), 10.0) for key, attr in mesh.vertices(True): x, y, z = vertices[key] attr['x'] = x attr['y'] = y attr['z'] = z # mesh = Mesh.from_obj(compas.get('faces.obj')) # mesh_quads_to_triangles(mesh) # mesh = Mesh.from_polyhedron(12) # mesh_quads_to_triangles(mesh) index_key = mesh.index_key()