Ability to scale input object

This commit is contained in:
Alessandro Ranellucci 2011-09-26 12:07:29 +02:00
parent c2a62891da
commit bfad101c8c
4 changed files with 22 additions and 2 deletions

View File

@ -35,6 +35,7 @@ Slic3r current features are:
* use relative or absolute extrusion commands; * use relative or absolute extrusion commands;
* center print around bed center point; * center print around bed center point;
* multiple solid layers near horizontal external surfaces; * multiple solid layers near horizontal external surfaces;
* ability to scale input object;
* use different speed for bottom layer. * use different speed for bottom layer.
Roadmap includes the following goals: Roadmap includes the following goals:
@ -43,7 +44,7 @@ Roadmap includes the following goals:
* allow the user to customize initial and final GCODE commands; * allow the user to customize initial and final GCODE commands;
* support material for internal perimeters; * support material for internal perimeters;
* ability to infill in the direction of bridges; * ability to infill in the direction of bridges;
* input object transform (scale, rotate, multiply); * input object transform (rotate, multiply);
* cool; * cool;
* nice packaging for cross-platform deployment. * nice packaging for cross-platform deployment.

View File

@ -59,4 +59,7 @@ our $retract_speed = 40; # mm/sec
our $skirts = 1; our $skirts = 1;
our $skirt_distance = 6; # mm our $skirt_distance = 6; # mm
# transform options
our $scale = 1;
1; 1;

View File

@ -30,6 +30,12 @@ sub parse_file {
} }
} }
# scale extents
for (X,Y,Z) {
$extents[$_][MIN] *= $Slic3r::scale;
$extents[$_][MAX] *= $Slic3r::scale;
}
# initialize print job # initialize print job
my $print = Slic3r::Print->new( my $print = Slic3r::Print->new(
x_length => ($extents[X][MAX] - $extents[X][MIN]) / $Slic3r::resolution, x_length => ($extents[X][MAX] - $extents[X][MIN]) / $Slic3r::resolution,
@ -46,7 +52,7 @@ sub parse_file {
# transform vertex coordinates # transform vertex coordinates
my ($normal, @vertices) = @$facet; my ($normal, @vertices) = @$facet;
foreach my $vertex (@vertices) { foreach my $vertex (@vertices) {
$vertex->[$_] = sprintf('%.0f', ($vertex->[$_] + $shift[$_]) / $Slic3r::resolution) $vertex->[$_] = sprintf('%.0f', ($Slic3r::scale * $vertex->[$_] + $shift[$_]) / $Slic3r::resolution)
for X,Y,Z; for X,Y,Z;
} }

View File

@ -50,6 +50,9 @@ GetOptions(
# skirt options # skirt options
'skirts=i' => \$Slic3r::skirts, 'skirts=i' => \$Slic3r::skirts,
'skirt-distance=i' => \$Slic3r::skirt_distance, 'skirt-distance=i' => \$Slic3r::skirt_distance,
# transform options
'scale=i' => \$Slic3r::scale,
); );
# validate configuration # validate configuration
@ -90,6 +93,10 @@ GetOptions(
# --fill-density # --fill-density
die "Invalid value for --fill-density\n" die "Invalid value for --fill-density\n"
if $Slic3r::fill_density < 0 || $Slic3r::fill_density > 1; if $Slic3r::fill_density < 0 || $Slic3r::fill_density > 1;
# --scale
die "Invalid value for --scale\n"
if $Slic3r::scale <= 0;
} }
my $stl_parser = Slic3r::STL->new; my $stl_parser = Slic3r::STL->new;
@ -167,6 +174,9 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
(default: $Slic3r::skirt_distance) (default: $Slic3r::skirt_distance)
-o, --output File to output gcode to (default: <inputfile>.gcode) -o, --output File to output gcode to (default: <inputfile>.gcode)
Transform options:
--scale Factor for scaling input object (default: $Slic3r::scale)
EOF EOF
exit $exit_code || 0; exit $exit_code || 0;
} }