Skip to content

Commit

Permalink
New option to rotate input object
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed Sep 26, 2011
1 parent 8d13d4b commit 404c76a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Slic3r current features are:
* use relative or absolute extrusion commands;
* center print around bed center point;
* multiple solid layers near horizontal external surfaces;
* ability to scale input object;
* ability to scale and rotate input object;
* use different speed for bottom layer.

Roadmap includes the following goals:
Expand All @@ -46,7 +46,7 @@ Roadmap includes the following goals:
* allow the user to customize initial and final GCODE commands;
* support material for internal perimeters;
* ability to infill in the direction of bridges;
* input object transform (rotate, multiply);
* multiply input object;
* cool;
* nice packaging for cross-platform deployment.

Expand Down
1 change: 1 addition & 0 deletions lib/Slic3r.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ our $skirt_distance = 6; # mm

# transform options
our $scale = 1;
our $rotate = 0;

1;
10 changes: 10 additions & 0 deletions lib/Slic3r/STL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ sub parse_file {
# open STL file
my $stl = CAD::Format::STL->new->load($file);

if ($Slic3r::rotate > 0) {
my $deg = Slic3r::Geometry::deg2rad($Slic3r::rotate);
foreach my $facet ($stl->part->facets) {
my ($normal, @vertices) = @$facet;
foreach my $vertex (@vertices) {
@$vertex = (@{ +(Slic3r::Geometry::rotate_points($deg, undef, [ $vertex->[X], $vertex->[Y] ]))[0] }, $vertex->[Z]);
}
}
}

# we only want to work with positive coordinates, so let's
# find our object extents to calculate coordinate displacements
my @extents = (map [99999999, -99999999], X,Y,Z);
Expand Down
4 changes: 3 additions & 1 deletion slic3r.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ BEGIN

# transform options
'scale=i' => \$Slic3r::scale,
'rotate=i' => \$Slic3r::rotate,
);

# validate configuration
Expand Down Expand Up @@ -163,7 +164,7 @@ sub usage {
--solid-layers Number of solid layers to do for top/bottom surfaces
(range: 1+, default: $Slic3r::solid_layers)
--fill-density Infill density (range: 0-1, default: $Slic3r::fill_density)
--fill-angle Infill angle (range: 0-90, default: $Slic3r::fill_angle)
--fill-angle Infill angle in degrees (range: 0-90, default: $Slic3r::fill_angle)
--temperature Extrusion temperature (default: $Slic3r::temperature)
Retraction options:
Expand All @@ -181,6 +182,7 @@ sub usage {
Transform options:
--scale Factor for scaling input object (default: $Slic3r::scale)
--rotate Rotation angle in degrees (0-360, default: $Slic3r::rotate)
EOF
exit ($exit_code || 0);
Expand Down

0 comments on commit 404c76a

Please sign in to comment.