1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 13:16:47 +02:00

cameo/fped2stl.pl: sort layers by Z position

This way, the ordering of the layer stack doesn't matter.
This commit is contained in:
Werner Almesberger 2013-11-02 13:26:04 -03:00
parent e62da4e2bb
commit 4fa9e129ee

View File

@ -23,10 +23,11 @@ sub usage
sub flush sub flush
{ {
local ($z1) = sprintf("%e", $_[0]); local ($name, $z, $z1, $s) = @_;
$z = sprintf("%e", $z);
return unless defined $s; return unless defined $s;
$z = sprintf("%e", $z);
$z1 = sprintf("%e", $z1);
print STDERR "$name $z ...\n"; print STDERR "$name $z ...\n";
$^F = 20; $^F = 20;
pipe SR, SW; pipe SR, SW;
@ -66,16 +67,21 @@ $pfx = shift @ARGV;
$skip = 1; $skip = 1;
while (<>) { while (<>) {
if (/^# $pfx(.*?)-(\d+(\.\d*)?)\s*$/) { if (/^# $pfx(.*?)-(\d+(\.\d*)?)\s*$/) {
&flush($2);
$name = $1;
$z = $2; $z = $2;
undef $s; $name{$z} = $1;
undef $s{$z};
$skip = 0; $skip = 0;
} elsif (/^# /) { } elsif (/^# /) {
$skip = 1; $skip = 1;
} }
next if $skip; next if $skip;
next if /^#/; next if /^#/;
$s .= $_; $s{$z} .= $_;
} }
&flush(0);
undef $last;
for $z (sort { $b <=> $a } keys %s) {
&flush($name{$last}, $last, $z, $s{$last}) if defined $last;
$last = $z;
}
&flush($name{$last}, $last, 0, $s{$last});