dual_network = volmesh_dual_network(volmesh, cls=FormNetwork) dual_network.layer = dual_layer dual_network.attributes['name'] = dual_layer # move dual_network offset = 3 x_move = dual_network.bounding_box()[0] * offset for vkey in dual_network.vertex: dual_network.vertex[vkey]['x'] += x_move # ------------------------------------------------------------------------------ # 3. visualise diagrams # ------------------------------------------------------------------------------ # draw directed volmesh halffaces and directed dual_volmesh edges uv_c_dict = get_index_colordict(list(dual_network.edges())) face_normal_scale = 1.0 volmesh.draw_edges() draw_directed_hf_and_uv(volmesh, dual_network, uv_color=uv_c_dict, scale=face_normal_scale) # draw volmesh cell labels and dual network vertex labels cell_c_dict = get_index_colordict(list(volmesh.cell.keys())) draw_cell_labels(volmesh, color=cell_c_dict) dual_network.draw_vertex_labels(color=cell_c_dict)
from __future__ import absolute_import
with conduit.enabled(): cell_planarise(cell, kmax=2000, target_areas=target_areas, target_normals=target_normals, collapse_edge_length=collapse_edge_length, callback=callback, print_result_info=True) # ------------------------------------------------------------------------------ # 5. draw results # ------------------------------------------------------------------------------ rs.HideObjects(lines) # get index colors colordict = get_index_colordict(vectors.keys()) # draw initial vectors and target areas input_vector_labels = [] input_vectors = [] for i in vectors: label = 'target : ' + str(round(target_areas[i], 5)) input_vector_labels.append({ 'pos': midpts[i], 'text': label, 'color': colordict[i] }) input_vectors.append({ 'start': list(origin), 'end': add_vectors(origin, vectors[i]), 'color': colordict[i],
formdiagram.vertex[vkey]['x'] += x_move # ------------------------------------------------------------------------------ # 3. reciprocate # ------------------------------------------------------------------------------ volmesh_reciprocate(forcediagram, formdiagram, kmax=1000, weight=1, edge_min=0.5, edge_max=20, tolerance=0.01) # ------------------------------------------------------------------------------ # 4. visualisation - color id # ------------------------------------------------------------------------------ uv_c_dict = get_index_colordict(list(formdiagram.edges())) hf_c_dict = get_force_colors_hf(forcediagram, formdiagram, uv_c_dict=uv_c_dict) faces_to_draw = [ fkey for fkey in forcediagram.faces() if fkey in forcediagram.halffaces_interior() ] forcediagram.clear() forcediagram.draw_edges() forcediagram.draw_faces(keys=faces_to_draw, color=hf_c_dict) formdiagram.clear() formdiagram.draw_edges(color=uv_c_dict)
# move dual_network offset = 3 width = dual_volmesh.bounding_box()[1][0] - dual_volmesh.bounding_box()[0][0] for vkey in dual_volmesh.vertices(): x = dual_volmesh.vertex_attribute(vkey, 'x') dual_volmesh.vertex_attribute(vkey, 'x', x + width * offset) # ------------------------------------------------------------------------------ # 3. visualise diagrams # ------------------------------------------------------------------------------ force_artist = VolMeshArtist(volmesh) form_artist = VolMeshArtist(dual_volmesh) # draw volmesh cell labels and dual_volmesh vertex labels cell_c_dict = get_index_colordict(list(volmesh.cells())) # draw volmesh force_artist.draw_edges() force_artist.draw_celllabels(color=cell_c_dict) # draw dual volmesh form_artist.draw_faces() form_artist.draw_vertexlabels(color=cell_c_dict) # draw directed volmesh halffaces and directed dual_volmesh edges uv_c_dict = get_index_colordict(list(dual_volmesh.edges())) face_normal_scale = 1.0 draw_directed_hf_and_uv(volmesh, dual_volmesh,