2 from __future__ import print_function
10 def writeout_core(so, scalefactor=1):
11 print('scale(%s) polyhedron(points=[' % scalefactor)
12 for p in so._points: print(p, ',')
14 for t in so._triangles: print(repr(t), ',')
16 print('],convexity=10);')
18 def writeout(so, objname, scalefactor=1):
19 print('module %s(){' % objname)
20 so.writeout_core(scalefactor)
27 ix = so._point_indices[s]
31 so._point_indices[s] = ix
34 def triangle(so, a,b,c):
35 ''' a b c are clockwise from inside '''
36 so._triangles.append([ so._point(p) for p in (a,b,c) ])
39 ''' cnrs[0] [1] [3] [2] are clockwise from inside '''
40 so.triangle(cnrs[0], cnrs[1], cnrs[3])
41 so.triangle(cnrs[0], cnrs[3], cnrs[2])
44 ''' cnrs[0] [1] [3] [2] are anticlockwise from inside '''
45 so.triangle(cnrs[0], cnrs[3], cnrs[1])
46 so.triangle(cnrs[0], cnrs[2], cnrs[3])