chiark / gitweb /
knifeblock: wip, template reorg
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Dec 2014 21:25:57 +0000 (21:25 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Dec 2014 21:25:57 +0000 (21:25 +0000)
Makefile
knifeblock-knives-filter
knifeblock.scad

index c5118f8..055b0d4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -56,9 +56,12 @@ stls:                $(addsuffix .auto.stl, $(AUTO_TOPLEVELS))
 
 dovecliptest.stl: doveclip.scad $(AUTO_INCS)
 
-KNIFEBLOCK_TEMPLATES=$(foreach k, 0 1 2, h$k a$k)
-KNIFEBLOCK_TEMPLATE_FILES=$(foreach t,$(KNIFEBLOCK_TEMPLATES), \
-       knifeblock-knives-t$t.dxf)
+KNIFEBLOCK_KNIVES= 0 1 2
+KNIFEBLOCK_TEMPLATES= b h
+KNIFEBLOCK_TEMPLATE_FILES=\
+       $(foreach k,$(KNIFEBLOCK_KNIVES), \
+       $(foreach t,$(KNIFEBLOCK_TEMPLATES), \
+       knifeblock-knives-t$k$t.dxf))
 
 knifeblock-knives-templates: $(KNIFEBLOCK_TEMPLATE_FILES)
 
index 6dfce66..2b74cac 100755 (executable)
@@ -1,25 +1,33 @@
-#!/usr/bin/perl -wn
+#!/usr/bin/perl -w
 
 use strict;
+use POSIX;
 
 our %want;
 
-BEGIN {
-      my $want = shift @ARGV;
-      my ($part,$knife) = $want =~ m/^([ha])(\d)$/ or die;
+our @part_order = qw(h b);
 
-      $want{ $knife+1 } = $part =~ m/[h]/;
-      $want{ $knife+4 } = $part =~ m/[ha]/;
+my $want = shift @ARGV;
+my ($wknife,$wparts) = $want =~ m/^(\d)([a-z]+)$/ or die;
+
+sub want ($) {
+    my ($colournum) = @_;
+    my $knife = ($colournum-1) % 3;
+    return 0 unless $knife == $wknife;
+    my $part = $part_order[ floor(($colournum-1) / 3) ];
+    die "huh colour $colournum?" unless defined $part;
+    return 0 unless $part =~ m/[$wparts]/o;
+    return 1;
 }
 
 our $drop;
-
-if (m/^\S/) {
-    $drop = 
-       m/^2 / ||
-       (m/^3 \d+ \d+ \d+ (\d+) / && !$want{$1});
+while (<>) {
+    if (m/^\S/) {
+       $drop = 
+           m/^2 5 / ||
+           (m/^(?:3 1|2 3) \d+ \d+ (\d+) / && !want($1));
+    }
+    next if $drop;
+
+    print or die $!;
 }
-
-next if $drop;
-
-print or die $!;
index 1339ded..efe3b3b 100644 (file)
@@ -1,18 +1,19 @@
 // -*- C -*-
 //import(file="t.dxf");
 
-module ImportTemplate(l) {
-  import(file=str("knifeblock-knives-l",l,".dxf"), convexity=3);
+module ImportTemplate(k,t) {
+  import(file=str("knifeblock-knives-t",k,t,".dxf"), convexity=3);
 }
 
-module Knife(ix){
-  translate([0,50*ix,0]){
-    ImportTemplate(ix+1);
+module Knife(k){
+  translate([0,50*k,0]){
+    ImportTemplate(k,"b");
     translate([0,0,10])
-      ImportTemplate(ix+4);
+      ImportTemplate(k,"h");
   }
 }
 
 Knife(0);
 Knife(1);
 Knife(2);
+//import(file="t.dxf",convexity=4);