Esempio n. 1
0
def calculate(FILE_IN, plot_flag):

    for file in FILE_IN:
        #print("Calculating",file)
        assembly = Assembly.from_json(file)

        # ==============================================================================
        # Identify interfaces
        # ==============================================================================
        assembly_interfaces_numpy(assembly, tmax=0.02)

        # ==============================================================================
        # Equilibrium
        # ==============================================================================
        compute_interface_forces_cvx(assembly, solver='CPLEX', verbose=False)
        #compute_interface_forces_cvx(assembly, solver='ECOS', verbose=True)

        # ==============================================================================
        # Export
        # ==============================================================================
        assembly.to_json(output_path(file))

        if plot_flag:
            R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2)
            assembly.transform(R)

            plotter = AssemblyPlotter(assembly, figsize=(16, 10), tight=True)
            plotter.draw_nodes(radius=0.05)
            plotter.draw_edges()
            plotter.draw_blocks(
                facecolor={
                    key: '#ff0000'
                    for key in assembly.nodes_where({'is_support': True})
                })
            plotter.show()
Esempio n. 2
0
DATA = os.path.join(HERE, '../../../data')
FILE_I = os.path.join(DATA, 'dome.json')
FILE_O = os.path.join(DATA, 'dome.json')


# ==============================================================================
# Load assembly from file
# ==============================================================================

assembly = Assembly.from_json(FILE_I)

# ==============================================================================
# Identify interfaces
# ==============================================================================

assembly_interfaces_numpy(assembly, tmax=0.05)

# ==============================================================================
# Export
# ==============================================================================

assembly.to_json(FILE_O)

# ==============================================================================
# Visualize
# ==============================================================================

R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2, [0, 0, 0])
assembly.transform(R)

plotter = AssemblyPlotter(assembly, figsize=(16, 10), tight=True)
assembly = Assembly()

# default block

box = Box.from_width_height_depth(W, H, D)
block = Block.from_vertices_and_faces(box.vertices, box.faces)

# make all blocks
# place each block on top of previous
# shift block randomly in XY plane

for i in range(N):
    b = block.copy()

    factor = choice([0.01, -0.01, 0.05, -0.05, 0.1, -0.1])
    axis = choice([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
    vector = scale_vector(axis, factor)

    T = Translation([vector[0], vector[1], i * H])
    mesh_transform(b, T)

    assembly.add_block(b, is_support=(i == 0))

# identify_interfaces

assembly_interfaces_numpy(assembly)

# compute interface forces

compute_interface_forces_cvx(assembly, solver='CPLEX', verbose=True)
Esempio n. 4
0
-----
Increasing ``NMAX`` is not necessary if the bottom blocks each have an individual support.

"""
import os

from compas_assembly.datastructures import Assembly
from compas_assembly.datastructures import assembly_interfaces_numpy

HERE = os.path.dirname(__file__)
DATA = os.path.join(HERE, '../data')
PATH_FROM = os.path.join(DATA, '07_wall_supported.json')
PATH_TO = os.path.join(DATA, '08_wall_interfaces.json')

# parameters

NMAX = 100
AMIN = 0.0001

# load assembly from JSON

assembly = Assembly.from_json(PATH_FROM)

# identify the interfaces

assembly_interfaces_numpy(assembly, nmax=100, amin=0.0001)

# serialise

assembly.to_json(PATH_TO)
Esempio n. 5
0
from compas_assembly.datastructures import assembly_interfaces_numpy

from compas_view2.app import App
from compas_view2.objects import Object, NetworkObject, MeshObject
from compas_view2.objects import Collection

Object.register(Assembly, NetworkObject)
Object.register(Block, MeshObject)


FILE_I = os.path.join(os.path.dirname(__file__), 'armadillo_assembly.json')
FILE_O = os.path.join(os.path.dirname(__file__), 'armadillo_interfaces.json')

assembly = compas.json_load(FILE_I)

assembly_interfaces_numpy(assembly, tmax=0.05, amin=0.0001)

# ==============================================================================
# Export
# ==============================================================================

compas.json_dump(assembly, FILE_O)

# ==============================================================================
# Viz
# ==============================================================================

viewer = App()

nodes = []
blocks = []