mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 21:58:03 -06:00
Code refactored to allow for multiple infill types
This commit is contained in:
parent
bfd1d0e1dd
commit
33d7b8c7cf
5 changed files with 230 additions and 157 deletions
56
lib/Slic3r/Fill/Base.pm
Normal file
56
lib/Slic3r/Fill/Base.pm
Normal file
|
@ -0,0 +1,56 @@
|
|||
package Slic3r::Fill::Base;
|
||||
use Moo;
|
||||
|
||||
use XXX;
|
||||
|
||||
has 'layer' => (is => 'rw');
|
||||
has 'max_print_dimension' => (is => 'rw');
|
||||
|
||||
use constant PI => 4 * atan2(1, 1);
|
||||
|
||||
sub infill_direction {
|
||||
my $self = shift;
|
||||
my ($polygons) = @_;
|
||||
|
||||
# set infill angle
|
||||
my (@rotate, @shift);
|
||||
$rotate[0] = Slic3r::Geometry::deg2rad($Slic3r::fill_angle);
|
||||
$rotate[1] = [ $self->max_print_dimension / 2, $self->max_print_dimension / 2 ];
|
||||
@shift = @{$rotate[1]};
|
||||
|
||||
# alternate fill direction
|
||||
if ($self->layer->id % 2) {
|
||||
$rotate[0] = Slic3r::Geometry::deg2rad($Slic3r::fill_angle) + PI/2;
|
||||
}
|
||||
|
||||
# TODO: here we should implement an "infill in direction of bridges" option
|
||||
|
||||
@shift = @{ +(Slic3r::Geometry::rotate_points(@rotate, \@shift))[0] };
|
||||
return [\@rotate, \@shift];
|
||||
}
|
||||
|
||||
sub rotate_points {
|
||||
my $self = shift;
|
||||
my ($polygons, $rotate_vector) = @_;
|
||||
my @rotate = @{$rotate_vector->[0]};
|
||||
my @shift = @{$rotate_vector->[1]};
|
||||
|
||||
# rotate surface as needed
|
||||
@$polygons = map [ Slic3r::Geometry::move_points(\@shift, @$_) ],
|
||||
map [ Slic3r::Geometry::rotate_points(@rotate, @$_) ], @$polygons if $rotate[0];
|
||||
|
||||
}
|
||||
|
||||
sub rotate_points_back {
|
||||
my $self = shift;
|
||||
my ($paths, $rotate_vector) = @_;
|
||||
my @rotate = @{$rotate_vector->[0]};
|
||||
my @shift = @{$rotate_vector->[1]};
|
||||
|
||||
if ($rotate[0]) {
|
||||
@$paths = map [ Slic3r::Geometry::rotate_points(-$rotate[0], $rotate[1], @$_) ],
|
||||
map [ Slic3r::Geometry::move_points([map -$_, @shift], @$_) ], @$paths;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
Loading…
Add table
Add a link
Reference in a new issue