mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
New algorithm for overhang detection
This commit is contained in:
parent
015580629b
commit
7e875393f5
3 changed files with 65 additions and 42 deletions
|
@ -5,11 +5,13 @@ use List::Util qw(min max first);
|
|||
use Slic3r::ExtrusionPath ':roles';
|
||||
use Slic3r::Geometry qw(scale unscale scaled_epsilon points_coincide PI X Y B);
|
||||
use Slic3r::Geometry::Clipper qw(union_ex);
|
||||
use Slic3r::Surface ':types';
|
||||
|
||||
has 'config' => (is => 'ro', required => 1);
|
||||
has 'multiple_extruders' => (is => 'ro', default => sub {0} );
|
||||
has 'layer_count' => (is => 'ro', required => 1 );
|
||||
has 'layer' => (is => 'rw');
|
||||
has '_layer_overhangs' => (is => 'rw');
|
||||
has 'move_z_callback' => (is => 'rw');
|
||||
has 'shift_x' => (is => 'rw', default => sub {0} );
|
||||
has 'shift_y' => (is => 'rw', default => sub {0} );
|
||||
|
@ -82,6 +84,11 @@ sub change_layer {
|
|||
my ($layer) = @_;
|
||||
|
||||
$self->layer($layer);
|
||||
$self->_layer_overhangs(
|
||||
$layer->id > 0
|
||||
? [ map $_->expolygon, grep $_->surface_type == S_TYPE_BOTTOM, map @{$_->slices}, @{$layer->regions} ]
|
||||
: []
|
||||
);
|
||||
if ($self->config->avoid_crossing_perimeters) {
|
||||
$self->layer_mp(Slic3r::GCode::MotionPlanner->new(
|
||||
islands => union_ex([ map @$_, @{$layer->slices} ], undef, 1),
|
||||
|
@ -152,8 +159,29 @@ sub extrude_loop {
|
|||
$extrusion_path->clip_end(scale $extrusion_path->flow_spacing * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING);
|
||||
return '' if !@{$extrusion_path->polyline};
|
||||
|
||||
my @paths = ();
|
||||
# detect overhanging/bridging perimeters
|
||||
if ($extrusion_path->is_perimeter && @{$self->_layer_overhangs}) {
|
||||
# get non-overhang paths by subtracting overhangs from the loop
|
||||
push @paths,
|
||||
$extrusion_path->subtract_expolygons($self->_layer_overhangs);
|
||||
|
||||
# get overhang paths by intersecting overhangs with the loop
|
||||
push @paths,
|
||||
map { $_->role(EXTR_ROLE_OVERHANG_PERIMETER); $_ }
|
||||
$extrusion_path->intersect_expolygons($self->_layer_overhangs);
|
||||
|
||||
# reapply the nearest point search for starting point
|
||||
# (TODO: choose the nearest point not on an overhang)
|
||||
@paths = Slic3r::ExtrusionPath::Collection
|
||||
->new(paths => [@paths])
|
||||
->chained_path($last_pos);
|
||||
} else {
|
||||
push @paths, $extrusion_path;
|
||||
}
|
||||
|
||||
# extrude along the path
|
||||
my $gcode = $self->extrude_path($extrusion_path, $description);
|
||||
my $gcode = join '', map $self->extrude_path($_, $description), @paths;
|
||||
$self->wipe_path($extrusion_path->polyline);
|
||||
|
||||
# make a little move inwards before leaving loop
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue