X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=reprap-play.git;a=blobdiff_plain;f=poster-tube-lid-parametric.scad.pl;h=64d4d00ebe9f5b472789f5411155e6457b95d8ec;hp=c4d105cb415f53bc9e0db9cf390e8a0eed6e464b;hb=c827170d69910df04bc8b620f2ed53ed5164e633;hpb=06123bfe46174b100cfedf21df117e77ab4ab9ae diff --git a/poster-tube-lid-parametric.scad.pl b/poster-tube-lid-parametric.scad.pl index c4d105c..64d4d00 100755 --- a/poster-tube-lid-parametric.scad.pl +++ b/poster-tube-lid-parametric.scad.pl @@ -169,20 +169,29 @@ our @points; 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); - return if grep { $pix eq $_ } @pixs; + if (grep { $pix eq $_ } @pixs) { + print "// elide @{ $ipts[$qi] } @{ $jpts[$qj] }\n"; + return; + } push @pixs, $pix; } - push @triangles, \@pixs; + push @triangles, [ $qi,$qj, \@pixs ]; } 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 = (); @@ -191,9 +200,9 @@ sub make_sheet () { } 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; - 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]); @@ -211,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 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 <