sl2/slicer.pl |
13 | 13 | |
14 | 14 | |
15 | 15 | $epsilon = 0.0001; # cutting offset |
16 | | $height = 10; # height of workpiece |
17 | | $margin = 5; # margin of workpiece box |
| 16 | $height = undef; # height of workpiece |
| 17 | $margin = undef; # margin of workpiece box |
18 | 18 | $end = 0; # offset to add at the last layer |
19 | | $flip = 1; # flip piece |
20 | | $z0 = -35; # reference tool position |
21 | | $z_step = 1; |
| 19 | $flip = 0; # flip piece |
| 20 | $z_step = undef; # maximum increase of milling depth |
| 21 | |
| 22 | |
| 23 | #----- Command-line processing ------------------------------------------------ |
| 24 | |
| 25 | |
| 26 | sub usage |
| 27 | { |
| 28 | print STDERR <<"EOF"; |
| 29 | usage: $0 [-a (top|bottom)(+|-)offset] [-f] [-h height] |
| 30 | [-m tolerance] [-p piece_distance] [-o z_offset] [-s max_step] [file.stl] |
| 31 | |
| 32 | -a alignment TO DO |
| 33 | -f flip the model around the Y axis |
| 34 | -h height workpiece height (default: use model dimensions) |
| 35 | -m tolerance compatibility with sfc/slicer.py, has no meaning here |
| 36 | -p piece_distance |
| 37 | draw a rectangular workpiece at the specified xy distance |
| 38 | around the model (default: none) |
| 39 | -o z_offset Z adjustment of final layer |
| 40 | -s max_step maximum Z step (default: unlimited) |
| 41 | EOF |
| 42 | exit(1); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | while ($ARGV[0] =~ /^-/) { |
| 47 | my $opt = shift @ARGV; |
| 48 | if ($opt eq "-a") { |
| 49 | # @@@ implement later |
| 50 | shift @ARGV; |
| 51 | } elsif ($opt eq "-f") { |
| 52 | $flip = 1; |
| 53 | } elsif ($opt eq "-h") { |
| 54 | $height = shift @ARGV; |
| 55 | &usage unless defined $height; |
| 56 | } elsif ($opt eq "-m") { |
| 57 | # @@@ not used - support for compatibility |
| 58 | shift @ARGV; |
| 59 | } elsif ($opt eq "-o") { |
| 60 | $end = shift @ARGV; |
| 61 | &usage unless defined $end; |
| 62 | } elsif ($opt eq "-p") { |
| 63 | $margin = shift @ARGV; |
| 64 | &usage unless defined $margin; |
| 65 | } elsif ($opt eq "-s") { |
| 66 | $z_step = shift @ARGV; |
| 67 | &usage unless defined $z_step; |
| 68 | } else { |
| 69 | &usage; |
| 70 | } |
| 71 | } |
22 | 72 | |
23 | 73 | |
24 | 74 | #----- Read the STL mesh ------------------------------------------------------ |
... | ... | |
63 | 113 | |
64 | 114 | #----- Calculate Z offset ----------------------------------------------------- |
65 | 115 | |
| 116 | $height = $zmax - $zmin unless defined $height; |
| 117 | |
66 | 118 | # align with bottom (zmin == 0), z_pos = height - zoff |
67 | 119 | |
68 | | $z_off = $z0 - $zmin - $height; |
| 120 | $z_off = -$zmin - $height; |
69 | 121 | $z_pos = $height + $zmin; |
70 | 122 | |
71 | 123 | |