chiark / gitweb /
sleepphone-cable-box: reinforce keeper
[reprap-play.git] / poster-tube-lid-parametric.scad.pl
index 019523ad1c73e2b482f8764f4ccbc3c27f01d25a..64d4d00ebe9f5b472789f5411155e6457b95d8ec 100755 (executable)
@@ -26,12 +26,10 @@ my $skew_slope = 0.7;
 
 my @i_sections = qw(ball0  -6
                    sine0  -10
 
 my @i_sections = qw(ball0  -6
                    sine0  -10
-                   -
-                   lin0    2
+                   lin0    -2
                    circle 40
                    lin1    2
                    sine1  10
                    circle 40
                    lin1    2
                    sine1  10
-                   -
                    ball2   6
                    -
                    );
                    ball2   6
                    -
                    );
@@ -171,20 +169,29 @@ our @points;
 our %point_indices;
 our @triangles;
 
 our %point_indices;
 our @triangles;
 
+my @ipts;
+my @jpts;
+
+my $qi;
+my $qj;
+
 sub triangle {
     my @pixs;
     foreach my $pval (@_) {
        my $pix = $point_indices{$pval}
            //= ((push @points, $pval), $#points);
 sub triangle {
     my @pixs;
     foreach my $pval (@_) {
        my $pix = $point_indices{$pval}
            //= ((push @points, $pval), $#points);
-       return if grep { $pix eq $_ } @pixs;
+       if (grep { $pix eq $_ } @pixs) {
+           print "// elide @{ $ipts[$qi] } @{ $jpts[$qj] }\n";
+           return;
+       }
        push @pixs, $pix;
     }
        push @pixs, $pix;
     }
-    push @triangles, \@pixs;
+    push @triangles, [ $qi,$qj, \@pixs ];
 }
 
 sub make_sheet () {
 }
 
 sub make_sheet () {
-    my @ipts = get_sections_ptvals(@i_sections);
-    my @jpts = get_sections_ptvals(@j_sections);
+    @ipts = get_sections_ptvals(@i_sections);
+    @jpts = get_sections_ptvals(@j_sections);
     my @sheet;
     foreach my $ipt (@ipts) {
        my @row = ();
     my @sheet;
     foreach my $ipt (@ipts) {
        my @row = ();
@@ -193,9 +200,9 @@ sub make_sheet () {
        }
        push @sheet, \@row;
     }
        }
        push @sheet, \@row;
     }
-    foreach (my $qi=0; $qi<$#ipts; $qi++) { # i direction does not wrap
+    foreach ($qi=0; $qi<$#ipts; $qi++) { # i direction does not wrap
        my $qi2 = $qi+1;
        my $qi2 = $qi+1;
-       foreach (my $qj=0; $qj<@jpts; $qj++) { # j direction does wrap
+       foreach ($qj=0; $qj<@jpts; $qj++) { # j direction does wrap
            my $qj2 = ($qj+1) % @jpts;
            my $p0 = $sheet[$qi][$qj];
            triangle($p0, $sheet[$qi2][$qj], $sheet[$qi2][$qj2]);
            my $qj2 = ($qj+1) % @jpts;
            my $p0 = $sheet[$qi][$qj];
            triangle($p0, $sheet[$qi2][$qj], $sheet[$qi2][$qj2]);
@@ -213,7 +220,9 @@ sub write_out () {
     print "module ImplHeadCup(){ polyhedron(points=[\n" or die $!;
     print pv($_),",\n" or die $! foreach @points;
     print "],faces=[\n" or die $!;
     print "module ImplHeadCup(){ polyhedron(points=[\n" or die $!;
     print pv($_),",\n" or die $! foreach @points;
     print "],faces=[\n" or die $!;
-    print pv($_),",\n" or die $! foreach @triangles;
+    foreach (@triangles) {
+       print pv($_->[2]),", // @{ $ipts[$_->[0]] } @{ $jpts[$_->[1]] }\n" or die $!;
+    }
     print "],convexity=10); }\n" or die $!;
     print <<END or die $!;
 implheadcup_large_dia = $large_dia;
     print "],convexity=10); }\n" or die $!;
     print <<END or die $!;
 implheadcup_large_dia = $large_dia;