From 1c58b8c1d1d7baf8b1ac1aac494372650332e6d2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 7 Nov 2017 14:09:43 +0000 Subject: [PATCH] mesh version, wip Signed-off-by: Ian Jackson --- Makefile | 5 +++- mesh-demo.scad | 7 ++++++ meshscad | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 mesh-demo.scad create mode 100755 meshscad diff --git a/Makefile b/Makefile index f6c672a..0cd2b89 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -all: moebius-core.scad +all: moebius-core.scad moebius-mesh.scad PLAY = /home/reprap/play USING_AUTOS = moebius @@ -11,6 +11,9 @@ PYLIBS = $(shell echo *.py) moebius-core.scad: genscad $(PYLIBS) ./$< >$@.tmp && mv -f $@.tmp $@ +moebius-mesh.scad: meshscad $(PYLIBS) + ./$< >$@.tmp && mv -f $@.tmp $@ + AUTO_TOPLEVELS := $(foreach m,$(USING_AUTOS),$(shell $(PLAY)/toplevel-find $m)) autoincs: $(AUTO_INCS) diff --git a/mesh-demo.scad b/mesh-demo.scad new file mode 100644 index 0000000..a6b8e00 --- /dev/null +++ b/mesh-demo.scad @@ -0,0 +1,7 @@ +// -*- C -*- + +include + +sz = moebiuscore_nomsize; + +MoebiusMesh(); diff --git a/meshscad b/meshscad new file mode 100755 index 0000000..84cc314 --- /dev/null +++ b/meshscad @@ -0,0 +1,62 @@ +#!/usr/bin/python + +from __future__ import print_function + +import signal +signal.signal(signal.SIGINT, signal.SIG_DFL) + +from moebius import * +from scad import * + +nomsize = 30; +wire = 3.0; + +# number of wires +kv = 10 +kw = 10 + +# resolution +nv = 40 +nw = 40 +ns = 10 # around tube + +nv += -nv % kv +nw += -hw % kw + +each_v = nv / kv +each_w = nw / kw + +m = Moebius(nv, nw) + +def round_wire(p, vec_surfacenormal, vec_acrosswire, sigma): + return (p + + wire * (vec_surfacenormal * sin(sigma) + + vec_acrosswire * cos*(sigma))) + +def make_moebius(objname): + print('module %s(){' % objname) + extents = ScadObject() # wires along extents + travers = ScadObject(): # wires along traverses + for v in range(0, nv): + for w in range(0, nw): + for s in range(0, ns): + sigmas = [ (s + sx)/ns * tau for sigma in 0,1 ] + eq = [] + if not w % each_w: + extents[w].quad([ round_wire(p, norm, trav, sigmas[sx]) + for p, norm, extt, trav in m.details(v+a, w) + for sx in 0,1 + for a in 0,1 ]) + if not v % each_v: + travers[v].quad([ round_wire(p, norm, extt, sigmas[sx]) + for p, norm, extt, trav in m.details(v, w+b) + for sx in 0,1 + for b in 0,1 ]) + for v in range(0, nv): + travers[v].writeout_core() + for w in range(0, nw): + travers[w].writeout_core() + print '}' + +make_moebius('MoebiusMesh') +print('moebiuscore_nomsize=%s;' % repr(nomsize)) -- 2.30.2