BrickBench-Runs / opus5 /set /set-005 /structures.py
kulits's picture
Initial commit
c7f9487
Raw History Blame Contribute Delete
3.67 kB
"""Broken stone arch and the castle facade."""
from brickagent import (Assembly, UP, check, view, measure, spin, parts,
connections, clashes)
from lib import Build, BRICKS, BRICKS1, PLATES
STONE = 'dark bluish gray'; STONE2 = 'light bluish gray'; STONE3 = 'dark tan'
def broken_arch():
"""A ruined arch 10 studs wide, 2 deep, on y=0; both piers carry the arch,
the wall above it has crumbled away to the right."""
a = Assembly('broken arch'); b = Build(a)
for n, y in enumerate((-24, -48, -72, -96, -120, -144)):
c = STONE if n % 2 else STONE2
b.slab(0, 3, 0, 2, y, c, shift=(1 if n % 2 else 0)) # left pier
b.slab(7, 3, 0, 2, y, c, shift=(1 if n % 2 else 0)) # right pier
for k in (0, 1): # arch over the opening
b.putb('6183', 2, k, -144, 6, 1, color=STONE2)
b.slab(0, 2, 0, 2, -168, STONE, stagger=True) # haunches beside the arch
b.slab(8, 2, 0, 2, -168, STONE, stagger=True)
b.slab(0, 2, 0, 2, -192, STONE2)
b.put('3005', 8, 0, -192, 1, 1, color=STONE2) # jagged right stub
b.put('3005', 9, 1, -192, 1, 1, color=STONE3)
b.slab(0, 6, 0, 2, -216, STONE, stagger=True) # course over the arch
b.slab(0, 4, 0, 2, -240, STONE2)
b.put('3004', 0, 0, -264, 2, 1, color=STONE)
b.put('3005', 0, 1, -264, 1, 1, color=STONE3)
b.put('3005', 2, 0, -264, 1, 1, color=STONE2)
b.putb('3040b', 1, 1, -240, 2, 1, rot=90, color=STONE2)
return a, b
def castle(n=14):
"""Castle facade n studs long, 2 deep, facing +Z; doorway at studs 3..10."""
a = Assembly('castle'); b = Build(a)
b.slab(0, n, 0, 2, -24, STONE)
for k in (0, 1):
b.putb('30528', 3, k, -24, 8, 1, color=STONE2) # arch 1x8x6
for m, y in enumerate((-48, -72, -96, -120, -144, -168)):
c = STONE if m % 2 else STONE2
b.slab(0, 3, 0, 2, y, c, shift=(1 if m % 2 else 0))
b.slab(11, 3, 0, 2, y, c, shift=(1 if m % 2 else 0))
b.slab(0, n, 0, 2, -192, STONE2, shift=2) # lintel courses
b.slab(0, n, 0, 2, -216, STONE, shift=0)
for i in range(4, 10, 2): # battlements
b.put('3005', i, 0, -240, 1, 1, color=STONE2)
b.put('3005', i, 1, -240, 1, 1, color=STONE2)
for i in (0, 11): # flanking towers
for m, y in enumerate((-240, -264, -288)):
b.slab(i, 3, 0, 2, y, STONE if m % 2 else STONE2)
for j in (i, i + 2):
b.put('3005', j, 0, -312, 1, 1, color=STONE2)
b.put('3005', j, 1, -312, 1, 1, color=STONE2)
return a, b
if __name__ == '__main__':
for name, fn in (('arch', broken_arch), ('castle', castle)):
d, b = fn()
ps = parts(d)
print(name, 'parts', len(ps), [tuple(round(v) for v in p) for p in measure(d)])
try:
check(d, stability=False); print(' CHECK ok')
except Exception as e:
print(' CHECK', str(e)[:200])
print(' components', [len(c) for c in connections(d).components])
for c in sorted(connections(d).components, key=len, reverse=True)[:4]:
xs=[ps[i].pos for i in c]
print(' comp', len(c), 'x', round(min(p[0] for p in xs)), round(max(p[0] for p in xs)),
'y', round(min(p[1] for p in xs)), round(max(p[1] for p in xs)))
for pair in clashes(d)[:6]:
print(' clash', [(ps[i].stem, tuple(round(v) for v in ps[i].pos)) for i in pair])
view(d, f'{name}.png', az=25, el=12)