1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 08:39:33 +02:00

sl2/slicer.pl: add command-line options

This commit is contained in:
Werner Almesberger 2015-09-29 12:27:20 -03:00
parent 73c3a776a3
commit 8af4f45573
2 changed files with 62 additions and 6 deletions

View File

@ -6,3 +6,7 @@ were then falsely closed and yielded bogus toolpaths.
This slicer uses very strict conditions for horizontality: all the This slicer uses very strict conditions for horizontality: all the
points of a horizontal facet must have identical Z coordinates. It points of a horizontal facet must have identical Z coordinates. It
also implicitly ensures that all paths are closed. also implicitly ensures that all paths are closed.
sl2/slicer.pl supports the same command-line options as sfc/slicer.py
and can be used as drop-in replacement, provided that the toolpaths
are re-aligned afterwards.

View File

@ -13,12 +13,62 @@
$epsilon = 0.0001; # cutting offset $epsilon = 0.0001; # cutting offset
$height = 10; # height of workpiece $height = undef; # height of workpiece
$margin = 5; # margin of workpiece box $margin = undef; # margin of workpiece box
$end = 0; # offset to add at the last layer $end = 0; # offset to add at the last layer
$flip = 1; # flip piece $flip = 0; # flip piece
$z0 = -35; # reference tool position $z_step = undef; # maximum increase of milling depth
$z_step = 1;
#----- Command-line processing ------------------------------------------------
sub usage
{
print STDERR <<"EOF";
usage: $0 [-a (top|bottom)(+|-)offset] [-f] [-h height]
[-m tolerance] [-p piece_distance] [-o z_offset] [-s max_step] [file.stl]
-a alignment TO DO
-f flip the model around the Y axis
-h height workpiece height (default: use model dimensions)
-m tolerance compatibility with sfc/slicer.py, has no meaning here
-p piece_distance
draw a rectangular workpiece at the specified xy distance
around the model (default: none)
-o z_offset Z adjustment of final layer
-s max_step maximum Z step (default: unlimited)
EOF
exit(1);
}
while ($ARGV[0] =~ /^-/) {
my $opt = shift @ARGV;
if ($opt eq "-a") {
# @@@ implement later
shift @ARGV;
} elsif ($opt eq "-f") {
$flip = 1;
} elsif ($opt eq "-h") {
$height = shift @ARGV;
&usage unless defined $height;
} elsif ($opt eq "-m") {
# @@@ not used - support for compatibility
shift @ARGV;
} elsif ($opt eq "-o") {
$end = shift @ARGV;
&usage unless defined $end;
} elsif ($opt eq "-p") {
$margin = shift @ARGV;
&usage unless defined $margin;
} elsif ($opt eq "-s") {
$z_step = shift @ARGV;
&usage unless defined $z_step;
} else {
&usage;
}
}
#----- Read the STL mesh ------------------------------------------------------ #----- Read the STL mesh ------------------------------------------------------
@ -63,9 +113,11 @@ print STDERR "bbox\t($xmin, $ymin, $zmin)\n\t($xmax, $ymax, $zmax)\n";
#----- Calculate Z offset ----------------------------------------------------- #----- Calculate Z offset -----------------------------------------------------
$height = $zmax - $zmin unless defined $height;
# align with bottom (zmin == 0), z_pos = height - zoff # align with bottom (zmin == 0), z_pos = height - zoff
$z_off = $z0 - $zmin - $height; $z_off = -$zmin - $height;
$z_pos = $height + $zmin; $z_pos = $height + $zmin;