added last part

This commit is contained in:
josch 2013-07-17 19:45:56 +02:00
parent b326f8f344
commit a4dcde887a

View file

@ -87,7 +87,7 @@ parts = [
("99301", "Slope Brick 33 3 x 3 Double Concave"), ("99301", "Slope Brick 33 3 x 3 Double Concave"),
("3675", "Slope Brick 33 3 x 3 Double Convex"), ("3675", "Slope Brick 33 3 x 3 Double Convex"),
("3297", "Slope Brick 33 3 x 4"), ("3297", "Slope Brick 33 3 x 4"),
("3048", "Slope Brick 45 2 x 1 Triple"), ("3048", "Slope Brick 45 1 x 2 Triple"),
("3040b", "Slope Brick 45 2 x 1"), ("3040b", "Slope Brick 45 2 x 1"),
("3044b", "Slope Brick 45 2 x 1 Double"), ("3044b", "Slope Brick 45 2 x 1 Double"),
("3665", "Slope Brick 45 2 x 1 Inverted"), ("3665", "Slope Brick 45 2 x 1 Inverted"),
@ -131,8 +131,7 @@ def drawstud(studsx, studsz, x, z, lines, triangles, quads):
lines.append(((p1[0], -4, p1[1]), (p2[0], -4, p2[1]))) lines.append(((p1[0], -4, p1[1]), (p2[0], -4, p2[1])))
lines.append(((p1[0], 0, p1[1]), (p2[0], 0, p2[1]))) lines.append(((p1[0], 0, p1[1]), (p2[0], 0, p2[1])))
def render(): def render_part(part):
for part in parts:
partid, parttext = part[:2] partid, parttext = part[:2]
m = re.match(r"(?P<type>[A-Za-z0-9 ]+?) (?P<studsz>\d+)"+ m = re.match(r"(?P<type>[A-Za-z0-9 ]+?) (?P<studsz>\d+)"+
r" x (?P<studsx>\d+)(?: x (?P<height>\d+(?:/\d+)?))?"+ r" x (?P<studsx>\d+)(?: x (?P<height>\d+(?:/\d+)?))?"+
@ -171,6 +170,8 @@ def render():
height = 3 height = 3
else: else:
height = 1 height = 1
# convert plate height to LDraw units
height *= 8
if m.group('type') in ['Brick', 'Plate']: if m.group('type') in ['Brick', 'Plate']:
# draw studs # draw studs
for z in range(studsz): for z in range(studsz):
@ -184,10 +185,10 @@ def render():
else: else:
coords = [(1,1),(1,-1),(-1,-1),(-1,1)] coords = [(1,1),(1,-1),(-1,-1),(-1,1)]
outertopcoords = [(studsx*10*x, 0, studsz*10*z) for x,z in coords] outertopcoords = [(studsx*10*x, 0, studsz*10*z) for x,z in coords]
outerbottomcoords = [(x, height*8, z) for x,y,z in outertopcoords] outerbottomcoords = [(x, height, z) for x,y,z in outertopcoords]
# walls are 4 LDU thick, use sign() in case x or y are zero # walls are 4 LDU thick, use sign() in case x or y are zero
innertopcoords = [(studsx*10*x-sign(x)*4, 4, studsz*10*z-sign(z)*4) for x,z in coords] innertopcoords = [(studsx*10*x-sign(x)*4, 4, studsz*10*z-sign(z)*4) for x,z in coords]
innerbottomcoords = [(x, height*8, z) for x,y,z in innertopcoords] innerbottomcoords = [(x, height, z) for x,y,z in innertopcoords]
# write outer top plate and lines # write outer top plate and lines
# in case of a corner draw two trapezoids, otherwise draw a rectangle # in case of a corner draw two trapezoids, otherwise draw a rectangle
if m.group('corner'): if m.group('corner'):
@ -219,16 +220,173 @@ def render():
quads.append((p1, p2, p4, p3)) quads.append((p1, p2, p4, p3))
lines.append((p1, p2)) lines.append((p1, p2))
lines.append((p3, p4)) lines.append((p3, p4))
elif m.group('type') in ['Slope Brick 18', 'Slope Brick 31', elif m.group('type') == 'Slope Brick 31':
'Slope Brick 33', 'Slope Brick 45', 'Slope Brick 65', # create top, bottom, inner and outer rectangles
'Slope Brick 75']: coords = [(1,1),(1,-1),(-1,-1),(-1,1)]
outertopcoords = [(studsx*10*x, 0 if z == 1 else height-4, studsz*10*z) for x,z in coords]
outerbottomcoords = [(x, height, z) for x,y,z in outertopcoords]
# walls are 4 LDU thick, use sign() in case x or y are zero
innertopcoords = [(studsx*10*x-sign(x)*4, height-4, studsz*10*z-sign(z)*4) for x,z in coords]
innerbottomcoords = [(x, height, z) for x,y,z in innertopcoords]
# write outer top plate and lines
quads.append(outertopcoords)
for p1, p2 in wrap(outertopcoords):
lines.append((p1, p2))
# outer sides and lines
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords), wrap(outerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write inner top plate and lines
quads.append(innertopcoords)
for p1, p2 in wrap(innertopcoords):
lines.append((p1, p2))
# inner sides and lines
for (p1, p2), (p3, p4) in zip(wrap(innertopcoords), wrap(innerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write out bottom with trapezoids and lines
for (p1, p2), (p3, p4) in zip(wrap(innerbottomcoords), wrap(outerbottomcoords)):
quads.append((p1, p2, p4, p3))
lines.append((p1, p2))
lines.append((p3, p4))
elif m.group('type') in ['Slope Brick 18', 'Slope Brick 33',
'Slope Brick 45', 'Slope Brick 65', 'Slope Brick 75']:
# draw studs (draw an L if double concave) # draw studs (draw an L if double concave)
coordsL = [(0,0),(0,-1),(-1,-1),(-1,1),(1,1),(1,0)] coordsL = [(0,0),(0,-1),(-1,-1),(-1,1),(1,1),(1,0)]
coords = [(-1,-1),(-1,1),(1,1),(1,-1)] coords = [(-1,-1),(-1,1),(1,1),(1,-1)]
if m.group('type') != 'Slope Brick 31' \ if 'Double' == m.group('slope'):
and 'Double' != m.group('slope') \ # create top, bottom, inner and outer rectangles
and 'Triple' != m.group('slope') \ coords = [(1,1),(1,-1),(-1,-1),(-1,1)]
and 'Double Concave / Double Convex' != m.group('slope'): outertopcoords = [(studsx*10*x, 24-4, studsz*10*z) for x,z in coords]
outerbottomcoords = [(x, 24, z) for x,y,z in outertopcoords]
# walls are 4 LDU thick, use sign() in case x or y are zero
innertopcoords = [(studsx*10*x-sign(x)*4, 24-4, studsz*10*z-sign(z)*4) for x,z in coords]
innerbottomcoords = [(x, 24, z) for x,y,z in innertopcoords]
if m.group('type') == 'Slope Brick 45':
ridge = [(studsx*10,0,0),(-studsx*10,0,0)]
elif m.group('type') == 'Slope Brick 33':
ridge = [(studsx*10,24-14,0),(-studsx*10,24-14,0)]
else:
print "unsupported slope type for double"
exit(1)
# write outer top lines
lines.append(outertopcoords[1:3])
lines.append(outertopcoords[:1]+outertopcoords[-1:])
# outer sides and lines
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords), wrap(outerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write inner top plate and lines
quads.append(innertopcoords)
for p1, p2 in wrap(innertopcoords):
lines.append((p1, p2))
# inner sides and lines
for (p1, p2), (p3, p4) in zip(wrap(innertopcoords), wrap(innerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write out bottom with trapezoids and lines
for (p1, p2), (p3, p4) in zip(wrap(innerbottomcoords), wrap(outerbottomcoords)):
quads.append((p1, p2, p4, p3))
lines.append((p1, p2))
lines.append((p3, p4))
# draw gables
triangles.append(ridge[:1]+outertopcoords[:2])
triangles.append(ridge[-1:]+outertopcoords[2:])
# draw slopes
quads.append(ridge+outertopcoords[1:3])
quads.append(ridge+outertopcoords[-1:]+outertopcoords[:1])
# draw lines for ridge and rakes
lines.append(ridge)
lines.append(ridge[:1]+outertopcoords[:1])
lines.append(ridge[:1]+outertopcoords[1:2])
lines.append(ridge[-1:]+outertopcoords[-1:])
lines.append(ridge[-1:]+outertopcoords[2:3])
elif 'Triple' == m.group('slope'):
# create top, bottom, inner and outer rectangles
coords = [(1,1),(1,-1),(-1,-1),(-1,1)]
outertopcoords = [(studsx*10*x, 24-4, studsz*10*z) for x,z in coords]
outerbottomcoords = [(x, 24, z) for x,y,z in outertopcoords]
# walls are 4 LDU thick, use sign() in case x or y are zero
innertopcoords = [(studsx*10*x-sign(x)*4, 24-4, studsz*10*z-sign(z)*4) for x,z in coords]
innerbottomcoords = [(x, 24, z) for x,y,z in innertopcoords]
tip = (0,0,studsz*10)
# write outer top lines
for p1, p2 in wrap(outertopcoords)[:-1]:
lines.append((p1, p2))
# outer sides and lines
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords), wrap(outerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write inner top plate and lines
quads.append(innertopcoords)
for p1, p2 in wrap(innertopcoords):
lines.append((p1, p2))
# inner sides and lines
for (p1, p2), (p3, p4) in zip(wrap(innertopcoords), wrap(innerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write out bottom with trapezoids and lines
for (p1, p2), (p3, p4) in zip(wrap(innerbottomcoords), wrap(outerbottomcoords)):
quads.append((p1, p2, p4, p3))
lines.append((p1, p2))
lines.append((p3, p4))
# write out slopes and lines
for p1, p2 in wrap(outertopcoords):
triangles.append([p1,p2,tip])
lines.append((p1,tip))
elif 'Double Concave / Double Convex' == m.group('slope'):
# create top, bottom, inner and outer rectangles
coords = [(1,1),(1,-1),(-1,-1),(-1,1)]
outertopcoords = [(studsx*10*x, 24-4, studsz*10*z) for x,z in coords]
outerbottomcoords = [(x, 24, z) for x,y,z in outertopcoords]
# walls are 4 LDU thick, use sign() in case x or y are zero
innertopcoords = [(studsx*10*x-sign(x)*4, 24-4, studsz*10*z-sign(z)*4) for x,z in coords]
innerbottomcoords = [(x, 24, z) for x,y,z in innertopcoords]
if m.group('type') != 'Slope Brick 45':
print "unsupported slope type for double concave / double convex"
exit(1)
ridge1 = [(0,0,0),(-studsx*10,0,0)]
ridge2 = [(0,0,studsz*10),(0,0,0)]
# write outer top lines (eaves)
lines.append(outertopcoords[1:3])
lines.append(outertopcoords[:2])
# outer sides and lines
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords), wrap(outerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write inner top plate and lines
quads.append(innertopcoords)
for p1, p2 in wrap(innertopcoords):
lines.append((p1, p2))
# inner sides and lines
for (p1, p2), (p3, p4) in zip(wrap(innertopcoords), wrap(innerbottomcoords)):
quads.append((p1,p2,p4,p3))
lines.append((p1,p3))
# write out bottom with trapezoids and lines
for (p1, p2), (p3, p4) in zip(wrap(innerbottomcoords), wrap(outerbottomcoords)):
quads.append((p1, p2, p4, p3))
lines.append((p1, p2))
lines.append((p3, p4))
# draw gables
triangles.append(ridge1[-1:]+outertopcoords[2:])
triangles.append(ridge2[:1]+outertopcoords[:1]+outertopcoords[-1:])
# draw slopes
quads.append(ridge1+outertopcoords[1:3])
quads.append(ridge2+outertopcoords[:2])
triangles.append(ridge1+outertopcoords[-1:])
triangles.append(ridge2+outertopcoords[-1:])
# draw ridges
lines.append(ridge1)
lines.append(ridge2)
# draw rakes
lines.append(ridge1[-1:]+outertopcoords[2:3])
lines.append(ridge1[-1:]+outertopcoords[-1:])
lines.append(ridge2[:1]+outertopcoords[:1])
lines.append(ridge2[:1]+outertopcoords[-1:])
# draw valley and hip
lines.append(((0,0,0),outertopcoords[-1]))
lines.append(((0,0,0),outertopcoords[1]))
else:
if m.group('slope') in ['Inverted', 'Inverted Double Convex']: if m.group('slope') in ['Inverted', 'Inverted Double Convex']:
for z in range(studsz): for z in range(studsz):
for x in range(studsx): for x in range(studsx):
@ -244,80 +402,68 @@ def render():
for x in range(studsx): for x in range(studsx):
drawstud(studsx, studsz, x, 0, lines, triangles, quads) drawstud(studsx, studsz, x, 0, lines, triangles, quads)
# create top, bottom, inner and outer rectangles # create top, bottom, inner and outer rectangles
if m.group('slope') == 'Inverted Double Convex': if m.group('slope') in ['Double Convex', 'Inverted Double Convex']:
outertopcoords = [(studsx*10*x, 0, studsz*10*z) for x,z in coords]
outertopcoords2 = [((x-studsx+1)*10, 0, (z+studsz-1)*10) for x,z in coords] # small
outerbottomcoords = [((x-studsx+1)*10, height*8, (z+studsz-1)*10) for x,z in coords]
innertopcoords = [(6*x-(studsx-1)*10, 4, z*6+(studsz-1)*10) for x,z in coords]
innerbottomcoords = [(6*x-(studsx-1)*10, height*8, z*6+(studsz-1)*10) for x,z in coords]
noseup1 = outertopcoords[:1]+outertopcoords[-1:]
nosedown1 = [(x,4,z) for x,y,z in noseup1]
noseup2 = outertopcoords[-2:-1]+outertopcoords[-1:]
nosedown2 = [(x,4,z) for x,y,z in noseup2]
elif m.group('slope') == 'Double Convex':
outertopcoords = [((x-studsx+1)*10, 0, (z+studsz-1)*10) for x,z in coords] outertopcoords = [((x-studsx+1)*10, 0, (z+studsz-1)*10) for x,z in coords]
outerbottomcoords = [(studsx*10*x, height*8, studsz*10*z) for x,z in coords] # big outerbottomcoords = [(studsx*10*x, height, studsz*10*z) for x,z in coords] # big
outerbottomcoords2 = [((x-studsx+1)*10, height*8, (z+studsz-1)*10) for x,z in coords] # small helpercoords = [((x-studsx+1)*10, height, (z+studsz-1)*10) for x,z in coords] # small
innerbottomcoords = [(studsx*10*x-sign(x)*4, height*8, studsz*10*z-sign(z)*4) for x,z in coords] innerbottomcoords = [(studsx*10*x-sign(x)*4, height, studsz*10*z-sign(z)*4) for x,z in coords]
innertopcoords = [(6*x-(studsx-1)*10, 4, z*6+(studsz-1)*10) for x,z in coords] innertopcoords = [(6*x-(studsx-1)*10, 4, z*6+(studsz-1)*10) for x,z in coords]
nosedown1 = outerbottomcoords[:1]+outerbottomcoords[-1:] nosedown1 = outerbottomcoords[:1]+outerbottomcoords[-1:]
noseup1 = [(x,height*8-4,z) for x,y,z in nosedown1] noseup1 = [(x,height-4,z) for x,y,z in nosedown1]
nosedown2 = outerbottomcoords[-2:-1]+outerbottomcoords[-1:] nosedown2 = outerbottomcoords[-2:-1]+outerbottomcoords[-1:]
noseup2 = [(x,height*8-4,z) for x,y,z in nosedown2] noseup2 = [(x,height-4,z) for x,y,z in nosedown2]
elif m.group('slope') == 'Double Concave': # if an inverted piece is requested, switch coordinates around
outertopcoords = [(studsx*10*x+(abs(x)-1)*(10*studsx-20), 0, studsz*10*z+(1-abs(z))*(10*studsz-20)) for x,z in coordsL] if m.group('slope') == 'Inverted Double Convex':
outerbottomcoords = [(studsx*10*x, height*8, studsz*10*z) for x,z in coords] # big outerbottomcoords, helpercoords, outertopcoords = (
outerbottomcoords2 = [(studsx*10*x+(abs(x)-1)*(10*studsx-20), height*8, studsz*10*z+(1-abs(z))*(10*studsz-20)) for x,z in coordsL] # small
innertopcoords = [((studsx*10-4)*x+(abs(x)-1)*(10*studsx-20), 4, (studsz*10-4)*z+(1-abs(z))*(10*studsz-20)) for x,z in coordsL]
innerbottomcoords = [((studsx*10-4)*x, height*8, (studsz*10-4)*z) for x,z in coords]
tip = [(studsx*10,height*8,-studsz*10), (studsx*10,height*8-4,-studsz*10)]
else:
outertopcoords = [(studsx*10*x, 0, (z+studsz-1)*10) for x,z in coords]
outerbottomcoords2 = [(studsx*10*x, height*8, (z+studsz-1)*10) for x,z in coords] # small
outerbottomcoords = [(studsx*10*x, height*8, studsz*10*z) for x,z in coords] # big
innertopcoords = [((studsx*10-4)*x, 4, z*6+(studsz-1)*10) for x,z in coords]
innerbottomcoords = [(studsx*10*x-sign(x)*4, height*8, studsz*10*z-sign(z)*4) for x,z in coords]
nosedown = outerbottomcoords[:1]+outerbottomcoords[-1:]
noseup = [(x,height*8-4,z) for x,y,z in nosedown]
# invert all the coordinates along the y axis
if m.group('slope') == 'Inverted':
outertopcoords, outertopcoords2, outerbottomcoords = (
[(x,0,z) for x,y,z in outerbottomcoords], [(x,0,z) for x,y,z in outerbottomcoords],
[(x,0,z) for x,y,z in outerbottomcoords2], [(x,0,z) for x,y,z in helpercoords],
[(x,height*8,z) for x,y,z in outertopcoords]) [(x,height,z) for x,y,z in outertopcoords])
innertopcoords, innerbottomcoords = ( innertopcoords, innerbottomcoords = (
[(x,4,z) for x,y,z in innertopcoords], [(x,4,z) for x,y,z in innertopcoords],
[(x,height*8,z) for x,y,z in innertopcoords]) [(x,height,z) for x,y,z in innertopcoords])
noseup = outertopcoords[:1]+outertopcoords[-1:] noseup1, nosedown1 = [(x,0,z) for x,y,z in nosedown1], [(x,4,z) for x,y,z in noseup1]
nosedown = [(x,4,z) for x,y,z in noseup] noseup2, nosedown2 = [(x,0,z) for x,y,z in nosedown2], [(x,4,z) for x,y,z in noseup2]
# write outer top plate and lines elif m.group('slope') == 'Double Concave':
if m.group('slope') == 'Double Concave': outertopcoords = [(studsx*10*x+(abs(x)-1)*(10*studsx-20), 0, studsz*10*z+(1-abs(z))*(10*studsz-20)) for x,z in coordsL]
quads.append(outertopcoords[:4]) outerbottomcoords = [(studsx*10*x, height, studsz*10*z) for x,z in coords] # big
quads.append(outertopcoords[3:]+outertopcoords[:1]) helpercoords = [(studsx*10*x+(abs(x)-1)*(10*studsx-20), height, studsz*10*z+(1-abs(z))*(10*studsz-20)) for x,z in coordsL] # small
innertopcoords = [((studsx*10-4)*x+(abs(x)-1)*(10*studsx-20), 4, (studsz*10-4)*z+(1-abs(z))*(10*studsz-20)) for x,z in coordsL]
innerbottomcoords = [((studsx*10-4)*x, height, (studsz*10-4)*z) for x,z in coords]
tip = [(studsx*10,height,-studsz*10), (studsx*10,height-4,-studsz*10)]
# there is somehow no inverted double concave piece
else: else:
quads.append(outertopcoords) outertopcoords = [(studsx*10*x, 0, (z+studsz-1)*10) for x,z in coords]
for p1, p2 in wrap(outertopcoords): helpercoords = [(studsx*10*x, height, (z+studsz-1)*10) for x,z in coords] # small
lines.append((p1, p2)) outerbottomcoords = [(studsx*10*x, height, studsz*10*z) for x,z in coords] # big
innertopcoords = [((studsx*10-4)*x, 4, z*6+(studsz-1)*10) for x,z in coords]
innerbottomcoords = [(studsx*10*x-sign(x)*4, height, studsz*10*z-sign(z)*4) for x,z in coords]
nosedown = outerbottomcoords[:1]+outerbottomcoords[-1:]
noseup = [(x,height-4,z) for x,y,z in nosedown]
# if an inverted piece is requested, switch coordinates around
if m.group('slope') == 'Inverted':
outerbottomcoords, helpercoords, outertopcoords = (
[(x,0,z) for x,y,z in outerbottomcoords],
[(x,0,z) for x,y,z in helpercoords],
[(x,height,z) for x,y,z in outertopcoords])
innertopcoords, innerbottomcoords = (
[(x,4,z) for x,y,z in innertopcoords],
[(x,height,z) for x,y,z in innertopcoords])
noseup, nosedown = [(x,0,z) for x,y,z in nosedown], [(x,4,z) for x,y,z in noseup]
# outer sides and lines # outer sides and lines
if m.group('slope') == 'Inverted Double Convex': if m.group('slope') in ['Double Convex', 'Inverted Double Convex']:
for (p1, p2), (p3, p4) in zip(wrap(outerbottomcoords)[:2], wrap(outertopcoords2)[:2]): for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[:2], wrap(helpercoords)[:2]):
quads.append((p1,p2,p4,p3)) quads.append((p1,p2,p4,p3))
for (p1, p2), (p3, p4) in zip(wrap(outerbottomcoords)[1:2], wrap(outertopcoords2)[1:2]): for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[1:2], wrap(helpercoords)[1:2]):
lines.append((p1,p3))
elif m.group('slope') == 'Double Convex':
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[:2], wrap(outerbottomcoords2)[:2]):
quads.append((p1,p2,p4,p3))
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[1:2], wrap(outerbottomcoords2)[1:2]):
lines.append((p1,p3)) lines.append((p1,p3))
elif m.group('slope') == 'Double Concave': elif m.group('slope') == 'Double Concave':
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[1:5], wrap(outerbottomcoords2)[1:5]): for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[1:5], wrap(helpercoords)[1:5]):
quads.append((p1,p2,p4,p3)) quads.append((p1,p2,p4,p3))
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[2:5], wrap(outerbottomcoords2)[2:5]): for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[2:5], wrap(helpercoords)[2:5]):
lines.append((p1,p3)) lines.append((p1,p3))
else: else:
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[:3], wrap(outerbottomcoords2)[:3]): for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[:3], wrap(helpercoords)[:3]):
quads.append((p1,p2,p4,p3)) quads.append((p1,p2,p4,p3))
for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[1:3], wrap(outerbottomcoords2)[1:3]): for (p1, p2), (p3, p4) in zip(wrap(outertopcoords)[1:3], wrap(helpercoords)[1:3]):
lines.append((p1,p3)) lines.append((p1,p3))
# draw nose # draw nose
if m.group('slope') in ['Inverted Double Convex', 'Double Convex']: if m.group('slope') in ['Inverted Double Convex', 'Double Convex']:
@ -326,18 +472,15 @@ def render():
elif m.group('slope') != 'Double Concave': elif m.group('slope') != 'Double Concave':
quads.append(noseup+[nosedown[1]]+[nosedown[0]]) quads.append(noseup+[nosedown[1]]+[nosedown[0]])
# draw sides and lines to the nose # draw sides and lines to the nose
if m.group('slope') == 'Inverted Double Convex': if m.group('slope') in ['Double Convex', 'Inverted Double Convex']:
quads.append(outerbottomcoords[-2:-1]+outertopcoords2[-2:-1]+nosedown2[:1]+noseup2[:1]) quads.append(outertopcoords[-2:-1]+helpercoords[-2:-1]+noseup2[:1]+nosedown2[:1])
quads.append(outerbottomcoords[:1]+outertopcoords2[:1]+nosedown1[:1]+noseup1[:1]) quads.append(outertopcoords[:1]+helpercoords[:1]+noseup1[:1]+nosedown1[:1])
elif m.group('slope') == 'Double Convex':
quads.append(outertopcoords[-2:-1]+outerbottomcoords2[-2:-1]+noseup2[:1]+nosedown2[:1])
quads.append(outertopcoords[:1]+outerbottomcoords2[:1]+noseup1[:1]+nosedown1[:1])
elif m.group('slope') == 'Double Concave': elif m.group('slope') == 'Double Concave':
quads.append(outertopcoords[-1:]+outerbottomcoords2[-1:]+tip) quads.append(outertopcoords[-1:]+helpercoords[-1:]+tip)
quads.append(outertopcoords[1:2]+outerbottomcoords2[1:2]+tip) quads.append(outertopcoords[1:2]+helpercoords[1:2]+tip)
else: else:
quads.append(outertopcoords[-1:]+outerbottomcoords2[-1:]+nosedown[-1:]+noseup[-1:]) quads.append(outertopcoords[-1:]+helpercoords[-1:]+nosedown[-1:]+noseup[-1:])
quads.append(outertopcoords[:1]+outerbottomcoords2[:1]+nosedown[:1]+noseup[:1]) quads.append(outertopcoords[:1]+helpercoords[:1]+nosedown[:1]+noseup[:1])
if m.group('slope') in ['Inverted Double Convex', 'Double Convex']: if m.group('slope') in ['Inverted Double Convex', 'Double Convex']:
lines.append(noseup1[:1]+nosedown1[:1]) lines.append(noseup1[:1]+nosedown1[:1])
lines.append(noseup1[-1:]+nosedown1[-1:]) lines.append(noseup1[-1:]+nosedown1[-1:])
@ -348,39 +491,6 @@ def render():
else: else:
lines.append(noseup[:1]+nosedown[:1]) lines.append(noseup[:1]+nosedown[:1])
lines.append(noseup[-1:]+nosedown[-1:]) lines.append(noseup[-1:]+nosedown[-1:])
# draw slope and lines around it
if m.group('slope') == 'Inverted':
quads.append(outerbottomcoords[-1:]+outerbottomcoords[:1]+[nosedown[1]]+[nosedown[0]])
lines.append(nosedown[:1]+outerbottomcoords[:1])
lines.append(nosedown[-1:]+outerbottomcoords[-1:])
lines.append(nosedown[:1]+nosedown[-1:])
elif m.group('slope') == 'Inverted Double Convex':
quads.append(outerbottomcoords[-1:]+outerbottomcoords[:1]+[nosedown1[1]]+[nosedown1[0]])
quads.append(outerbottomcoords[2:3]+outerbottomcoords[3:4]+[nosedown2[1]]+[nosedown2[0]])
lines.append(nosedown1[:1]+outerbottomcoords[:1])
lines.append(nosedown1[-1:]+outerbottomcoords[-1:])
lines.append(nosedown2[-2:-1]+outerbottomcoords[-2:-1])
lines.append(nosedown1[:1]+nosedown1[-1:])
lines.append(nosedown2[:1]+nosedown2[-1:])
elif m.group('slope') == 'Double Convex':
quads.append(outertopcoords[-1:]+outertopcoords[:1]+[noseup1[1]]+[noseup1[0]])
quads.append(outertopcoords[2:3]+outertopcoords[3:4]+[noseup2[1]]+[noseup2[0]])
lines.append(noseup1[:1]+outertopcoords[:1])
lines.append(noseup1[-1:]+outertopcoords[-1:])
lines.append(noseup2[-2:-1]+outertopcoords[-2:-1])
lines.append(noseup1[:1]+noseup1[-1:])
lines.append(noseup2[:1]+noseup2[-1:])
elif m.group('slope') == 'Double Concave':
triangles.append(outertopcoords[-1:]+outertopcoords[:1]+[tip[1]])
triangles.append(outertopcoords[:1]+outertopcoords[1:2]+[tip[1]])
lines.append(outertopcoords[-1:]+[tip[1]])
lines.append(outertopcoords[:1]+[tip[1]])
lines.append(outertopcoords[1:2]+[tip[1]])
else:
quads.append(outertopcoords[-1:]+outertopcoords[:1]+[noseup[1]]+[noseup[0]])
lines.append(noseup[:1]+outertopcoords[:1])
lines.append(noseup[-1:]+outertopcoords[-1:])
lines.append(noseup[:1]+noseup[-1:])
# write inner top plate and lines # write inner top plate and lines
if m.group('slope') == 'Double Concave': if m.group('slope') == 'Double Concave':
quads.append(innertopcoords[:4]) quads.append(innertopcoords[:4])
@ -407,11 +517,46 @@ def render():
for (p1, p2), (p3, p4) in zip(wrap(innertopcoords), wrap(innerbottomcoords)): for (p1, p2), (p3, p4) in zip(wrap(innertopcoords), wrap(innerbottomcoords)):
quads.append((p1,p2,p4,p3)) quads.append((p1,p2,p4,p3))
lines.append((p1,p3)) lines.append((p1,p3))
# draw slope and lines around it
if m.group('slope') in ['Double Convex', 'Inverted Double Convex']:
if m.group('slope') == 'Inverted Double Convex':
noseup1, nosedown1, noseup2, nosedown2 = nosedown1, noseup1, nosedown2, noseup2
quads.append(outertopcoords[-1:]+outertopcoords[:1]+[noseup1[1]]+[noseup1[0]])
quads.append(outertopcoords[2:3]+outertopcoords[3:4]+[noseup2[1]]+[noseup2[0]])
lines.append(noseup1[:1]+outertopcoords[:1])
lines.append(noseup1[-1:]+outertopcoords[-1:])
lines.append(noseup2[-2:-1]+outertopcoords[-2:-1])
lines.append(noseup1[:1]+noseup1[-1:])
lines.append(noseup2[:1]+noseup2[-1:])
elif m.group('slope') == 'Double Concave':
triangles.append(outertopcoords[-1:]+outertopcoords[:1]+[tip[1]])
triangles.append(outertopcoords[:1]+outertopcoords[1:2]+[tip[1]])
lines.append(outertopcoords[-1:]+[tip[1]])
lines.append(outertopcoords[:1]+[tip[1]])
lines.append(outertopcoords[1:2]+[tip[1]])
else:
if m.group('slope') == 'Inverted':
noseup, nosedown = nosedown, noseup
quads.append(outertopcoords[-1:]+outertopcoords[:1]+[noseup[1]]+[noseup[0]])
lines.append(noseup[:1]+outertopcoords[:1])
lines.append(noseup[-1:]+outertopcoords[-1:])
lines.append(noseup[:1]+noseup[-1:])
# for drawing the top and bottom, switch the coords if necessary
if m.group('slope') in ['Inverted Double Convex', 'Inverted']:
outertopcoords, outerbottomcoords = outerbottomcoords, outertopcoords
# write out bottom with trapezoids and lines # write out bottom with trapezoids and lines
for (p1, p2), (p3, p4) in zip(wrap(innerbottomcoords), wrap(outerbottomcoords)): for (p1, p2), (p3, p4) in zip(wrap(innerbottomcoords), wrap(outerbottomcoords)):
quads.append((p1, p2, p4, p3)) quads.append((p1, p2, p4, p3))
lines.append((p1, p2)) lines.append((p1, p2))
lines.append((p3, p4)) lines.append((p3, p4))
# write outer top plate and lines
if m.group('slope') == 'Double Concave':
quads.append(outertopcoords[:4])
quads.append(outertopcoords[3:]+outertopcoords[:1])
else:
quads.append(outertopcoords)
for p1, p2 in wrap(outertopcoords):
lines.append((p1, p2))
else: else:
print "not supported part type: %s"%m.group('type') print "not supported part type: %s"%m.group('type')
exit(1) exit(1)
@ -428,4 +573,5 @@ def render():
outfile.close() outfile.close()
if __name__ == "__main__": if __name__ == "__main__":
render() for part in parts:
render_part(part)