1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 04:13:20 +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
{
local ($z1) = sprintf("%e", $_[0]);
local ($name, $z, $z1, $s) = @_;
$z = sprintf("%e", $z);
return unless defined $s;
$z = sprintf("%e", $z);
$z1 = sprintf("%e", $z1);
print STDERR "$name $z ...\n";
$^F = 20;
pipe SR, SW;
@ -66,16 +67,21 @@ $pfx = shift @ARGV;
$skip = 1;
while (<>) {
if (/^# $pfx(.*?)-(\d+(\.\d*)?)\s*$/) {
&flush($2);
$name = $1;
$z = $2;
undef $s;
$name{$z} = $1;
undef $s{$z};
$skip = 0;
} elsif (/^# /) {
$skip = 1;
}
next if $skip;
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});