mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 23:59:34 +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:
parent
e62da4e2bb
commit
4fa9e129ee
@ -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});
|
||||
|
Loading…
Reference in New Issue
Block a user