chiark / gitweb /
mesh version, wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 7 Nov 2017 14:09:43 +0000 (14:09 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 7 Nov 2017 14:09:43 +0000 (14:09 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
mesh-demo.scad [new file with mode: 0644]
meshscad [new file with mode: 0755]

index f6c672a95954ae4066680bd77c2bd7a9bfe1b083..0cd2b897227cbc1a43e579a5a504c7ab16b3863f 100644 (file)
--- 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 (file)
index 0000000..a6b8e00
--- /dev/null
@@ -0,0 +1,7 @@
+// -*- C -*-
+
+include <moebius-core.scad>
+
+sz = moebiuscore_nomsize;
+
+MoebiusMesh();
diff --git a/meshscad b/meshscad
new file mode 100755 (executable)
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))