mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 23:04:16 +02:00
cameo/zstack.pl: convert 2.5D paths into a stack with limited Z steps
This commit is contained in:
parent
489ca9c24d
commit
085754f931
64
cameo/zstack.pl
Executable file
64
cameo/zstack.pl
Executable file
@ -0,0 +1,64 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# zstack.pl - Convert 2.5D paths into a stack with limited Z steps
|
||||
#
|
||||
# Written 2012 by Werner Almesberger
|
||||
# Copyright 2012 Werner Almesberger
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
print STDERR "usage: $0 z-start z-maxstep [file ...]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
sub issue
|
||||
{
|
||||
local ($z) = @_;
|
||||
my $t;
|
||||
|
||||
#
|
||||
# The order here is a bit arbitrary. We sort to make the outcome
|
||||
# more predictable but it shouldn't really matter.
|
||||
#
|
||||
for my $c (sort { $b <=> $a } grep { $_ <= $z } keys %z) {
|
||||
($t = $z{$c}) =~ s/\s+-?\d+(\.\d*)?$/ $z/mg;
|
||||
print $t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$z0 = shift @ARGV;
|
||||
$zs = shift @ARGV;
|
||||
|
||||
$z0 =~ s/mm$//;
|
||||
$zs =~ s/mm$//;
|
||||
|
||||
&usage unless $zs > 0;
|
||||
|
||||
while (<>) {
|
||||
if (/^\s*$/) {
|
||||
$z{$z} .= "$s\n";
|
||||
undef $s;
|
||||
}
|
||||
$z = $3 if /^-?\d+(\.\d*)?\s+-?\d+(\.\d*)?\s+(-?\d+(\.\d*)?)/;
|
||||
$s .= $_;
|
||||
}
|
||||
$z{$z} .= "$s\n";
|
||||
|
||||
$z = $z0;
|
||||
for $c (sort { $b <=> $a } keys %z) {
|
||||
while ($z > $c+$zs) {
|
||||
$z -= $zs;
|
||||
&issue($z);
|
||||
}
|
||||
$z = $c;
|
||||
&issue($z);
|
||||
}
|
Loading…
Reference in New Issue
Block a user