# BIMR sample 
import random
random.seed(128)

# Control points
BASE = [(-1500,-300),(0,1000),(850,800),(300,0),(500,-800),(0,-1000),(-500,-800),(-300,0)]
N_LEVELS = 8
N_FRAMES = 40
FRAME_H  = 180
FRAME_D  = 35
FRAME_T  = 10
SLAB_T   = 150
LEVEL_H  = FRAME_H + 2 * SLAB_T

for lvl in range(N_LEVELS):
    z_bot  = lvl * LEVEL_H
    z_ceil = z_bot + FRAME_H + SLAB_T

    pts_xy = [(bx + int(random.uniform(-150, 150)),
               by + int(random.uniform(-150, 150)))
              for bx, by in BASE]

    c = Curve([Point(x, y, z_bot) for x, y in pts_xy])

    # Floor slab
    Slab(c, SLAB_T, z_bot)

    # Facade frames
    arc = CurveLen(c)
    fw  = max(50, min(300, int(arc / N_FRAMES)))
    div = list(Divide(c, N_FRAMES))
    for i, pt in enumerate(div):
        nxt = div[(i + 1) % N_FRAMES]
        Frame(pt, (nxt.x - pt.x, nxt.y - pt.y, 0), fw, FRAME_H, FRAME_D, FRAME_T)

    # Ceiling slab
    c_ceil = Curve([Point(x, y, z_ceil) for x, y in pts_xy])
    Slab(c_ceil, SLAB_T, z_ceil)
