from compas.numerical import dr_numpy from compas_fofin.datastructures import Shell from compas_fofin.loads import SelfweightCalculator # ============================================================================== # Initialise # ============================================================================== HERE = os.path.dirname(__file__) DATA = os.path.join(HERE, '..', 'data') FILE_I = os.path.join(DATA, 'data-materialised-unloaded.json') FILE_O = os.path.join(DATA, 'data-materialised-loaded.json') shell = Shell.from_json(FILE_I) # ============================================================================== # Load # ============================================================================== key_index = shell.key_index() uv_index = {(u, v): index for index, (u, v) in enumerate(shell.edges_where({'is_edge': True}))} fixed = [key_index[key] for key in shell.vertices_where({'is_anchor': True})] xyz = array(shell.get_vertices_attributes('xyz'), dtype=float64) p = array(shell.get_vertices_attributes(('px', 'py', 'pz')), dtype=float64) edges = [(key_index[u], key_index[v])
from compas.utilities import pairwise from compas.datastructures import Mesh from compas.datastructures import mesh_quads_to_triangles from compas.geometry import oriented_bounding_box_xy_numpy from compas_plotters import MeshPlotter from compas_fofin.datastructures import Shell from compas_fofin.rhino import ShellHelper from compas_fofin.rhino import ShellArtist HERE = os.path.dirname(__file__) DATA = os.path.join(HERE, '..', '..', 'data') FILE_I = os.path.join(DATA, 'fabric-extended.json') FILE_O = os.path.join(DATA, 'fabric-extended.json') fabric = Shell.from_json(FILE_I) zones = { "SOUTH": [1448, 1447, 1446, 1445, 1444, 1443, 1442, 1441, 1440, 1439, 1438], "WEST": [1468, 1467, 1466, 1465, 1464, 1463, 1462, 1461], "NW": [1393, 1392, 1391, 1390, 1389, 1388, 1387], "NE": [1407, 1406, 1405, 1404, 1403, 1402, 1401], "EAST": [1426, 1425, 1419, 1418, 1417, 1416, 1415] } # ============================================================================== # Predicates # ==============================================================================
from openpyxl import Workbook from compas.geometry import add_vectors from compas_fofin.datastructures import Shell # ============================================================================== # Initialise # ============================================================================== HERE = os.path.dirname(__file__) DATA = os.path.abspath(os.path.join(HERE, '..', 'data')) FILE_I = os.path.join(DATA, 'data.json') FILE_O = os.path.join(DATA, 'data-fabrication-rings.xlsx') SHELL = Shell.from_json(FILE_I) # ============================================================================== # Select # ============================================================================== CABLES = [] for edge in [(136, 203), (45, 200), (103, 105), (156, 255)]: cable = [] edges = SHELL.get_continuous_edges(edge) for edge in edges: if edge not in cable: cable.append(edge) CABLES.append(cable)
attr['z'] = z unrolled.append(quadmesh) return unrolled # ============================================================================== # Initialise # ============================================================================== HERE = os.path.dirname(__file__) DATA = os.path.join(HERE, '..', 'data') FILE_I = os.path.join(DATA, 'fabric.json') BASE = Shell.from_json(FILE_I) mesh_flip_cycles(BASE) SIDE = 'edos' SEEM = -0.020 COLOR = (255, 0, 0) if SIDE == 'idos' else (0, 0, 255) THICKNESS = -0.020 if SIDE == 'idos' else +0.020 # ============================================================================== # Fabric layer from extended dual # ============================================================================== FABRIC = BASE.copy() mesh_flip_cycles(FABRIC)
from __future__ import print_function from __future__ import absolute_import from __future__ import division import os from compas_fofin.datastructures import Shell from compas_fofin.fofin import fofin_numpy from compas_plotters import MeshPlotter HERE = os.path.dirname(__file__) FILE = os.path.join(HERE, 'mesh.obj') shell = Shell.from_obj(FILE) anchors = list(shell.vertices_where({'vertex_degree': 2})) shell.set_vertices_attribute('is_anchor', True, keys=anchors) fofin_numpy(shell) plotter = MeshPlotter(shell, figsize=(10, 7)) plotter.draw_vertices(facecolor={key: (255, 0, 0) for key in anchors}) plotter.draw_edges() plotter.draw_faces() plotter.show()