#!/usr/bin/python from __future__ import print_function import signal signal.signal(signal.SIGINT, signal.SIG_DFL) from moebius import * from scad import * nomsize = 50; wire = 3.0; # number of wires kv = 10 kw = 10 # resolution nv = 40 nw = 40 ns = 10 # around tube nv += -nv % kv nw += -nw % kw each_v = nv / kv each_w = nw / kw m = Moebius(nv, nw) def round_wire(p, vec_surfacenormal, vec_acrosswire, sigma): r = (p + wire/nomsize * (vec_surfacenormal * sin(sigma) + vec_acrosswire * cos(sigma))) #print(' round_wire',p,vec_surfacenormal, vec_acrosswire, sigma, r, # file=sys.stderr) return r def make_moebius(objname): print('module %s(){' % objname) # wires: extents = [ ScadObject() for v in range(0,nv) ] # along extents travers = [ ScadObject() for w in range(0,nw) ] # along traverses for v in range(0, nv): for w in range(0, nw): for s in range(0, ns): print('VWS',v,w,s, file=sys.stderr) sigmas = [ (s + sx)/ns * tau for sx in 0,1 ] if not w % each_w: extents[w].quad([ round_wire(p, norm, trav, sigmas[sx]) for a in 0,1 for p, norm, extt, trav in (m.details(v+a, w),) for sx in 0,1 ]) if not v % each_v: travers[v].quad([ round_wire(p, norm, extt, sigmas[sx]) for b in 0,1 for p, norm, extt, trav in (m.details(v, w+b),) for sx in 0,1 ]) for v in range(0, nv): print('// extent v=', v) extents[v].writeout_core(nomsize) for w in range(0, nw): print('// travers w=', w) travers[w].writeout_core(nomsize) print('}') make_moebius('MoebiusMesh') print('moebiuscore_nomsize=%s;' % repr(nomsize))