X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=genscad;h=62fb2ce4758699100f514356406d9fb64fbeaf1c;hb=29cb20f6187aeed6da1f1a7efa3473ee46015ece;hp=77d7135971b9d2386c80dbe4a222d9454b884ec1;hpb=693f2e8a09dff833452fd6b540b12a99cf827a86;p=moebius3.git diff --git a/genscad b/genscad index 77d7135..62fb2ce 100755 --- a/genscad +++ b/genscad @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 from __future__ import print_function @@ -6,9 +6,10 @@ import signal signal.signal(signal.SIGINT, signal.SIG_DFL) from moebius import * +from scad import * -nomsize = 20 -thick = 1.500; +nomsize = 30; +thick = 2.000; sliceat = 1.675; @@ -17,47 +18,6 @@ nw = 80 m = Moebius(nv, nw) - -class ScadObject: - def __init__(so): - so._points = [] - so._point_indices = {} - so._triangles = [] - - def writeout(so, objname, scalefactor=1): - print('module %s(){ scale(%s) polyhedron(points=[' % - (objname, scalefactor)) - for p in so._points: print(p, ',') - print('],faces=[') - for t in so._triangles: print(repr(t), ',') - print('],convexity=10); }') - so._points = None - - def _point(so, p): - l = list(p) - s = repr(l) - try: - ix = so._point_indices[s] - except KeyError: - ix = len(so._points) - so._points.append(s) - so._point_indices[s] = ix - return ix - - def triangle(so, a,b,c): - ''' a b c are clockwise from inside ''' - so._triangles.append([ so._point(p) for p in (a,b,c) ]) - - def quad(so, cnrs): - ''' cnrs[0] [1] [3] [2] are clockwise from inside ''' - so.triangle(cnrs[0], cnrs[1], cnrs[3]) - so.triangle(cnrs[0], cnrs[3], cnrs[2]) - - def rquad(so, cnrs): - ''' cnrs[0] [1] [3] [2] are anticlockwise from inside ''' - so.triangle(cnrs[0], cnrs[3], cnrs[1]) - so.triangle(cnrs[0], cnrs[2], cnrs[3]) - relthick = thick/(nomsize*2) def make_moebius(objname):