3 from __future__ import print_function
6 signal.signal(signal.SIGINT, signal.SIG_DFL)
21 ns = 4 # around tube, should be even
31 def dpr(v): return '%+3f %+3f %+3f' % tuple(v)
33 def points_round_wire(p, norm, acrs, sigmas):
35 delta = norm * sin(sigma) + acrs * cos(sigma)
36 r = p + wire/nomsize * delta
40 return [ (s + 0.5)/ns * tau for s in ss ]
42 def make_moebius(objname):
43 print('module %s(){' % objname)
45 extents = [ ScadObject() for w in range(0,nw) ] # along extents
46 travers = [ ScadObject() for v in range(0,nv) ] # along traverses
48 def qc(v, w, sigmas, is_trav):
49 #print(' QCv,w,T',v,w,is_trav, file=sys.stderr)
51 p, norm, extt, trav = m.details(v + ab*(not is_trav), w + ab*is_trav)
52 if is_trav: acrs = extt
54 #print(' RW,ab,sx',ab,sx,
60 # 'delta=',dpr(delta),
63 for r in points_round_wire(p, norm, acrs, sigmas):
66 for v in range(0, nv):
67 for w in range(0, nw+1):
69 if extw > nw/2: extw = nw-w
70 # each extent wire has to go round twice to meet itself
71 # (except the middle one, if there is one, where nw/2 = nw - nw/2
72 # and it gets to be by itself
73 for s in range(0, ns):
74 sigmas = calc_sigmas([s + sx for sx in (0,1)])
75 #print('VWS',v,w,s, sigmas, file=sys.stderr)
77 extents[extw].quad([ cnr for cnr in qc(v,w,sigmas,False) ])
78 if not v % each_v and w < nw:
79 travers[v].rquad([ cnr for cnr in qc(v,w,sigmas,True) ])
82 p, norm, extt, trav = m.details(v, w)
83 cnrs = points_round_wire(p, norm, extt, calc_sigmas(range(0,ns)))
86 for s in range(0, ns-1):
87 travers[v].triangle(cnrs[s],
91 for w in range(0, nw):
92 print('// extent w=', w)
93 extents[w].writeout_core(nomsize)
94 for v in range(0, nv):
95 print('// travers v=', v)
96 travers[v].writeout_core(nomsize)
99 make_moebius('MoebiusMesh')
100 print('moebiuscore_nomsize=%s;' % repr(nomsize))