mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-20 03:24:24 +08:00
Merge branch 'master' into wipe
This commit is contained in:
commit
96f1b7ab57
@ -15,7 +15,7 @@ use Slic3r::Geometry qw(PI X Y epsilon deg2rad rotate_points);
|
|||||||
has 'polyline' => (
|
has 'polyline' => (
|
||||||
is => 'rw',
|
is => 'rw',
|
||||||
required => 1,
|
required => 1,
|
||||||
handles => [qw(merge_continuous_lines lines length reverse clip_end simplify)],
|
handles => [qw(merge_continuous_lines lines length reverse clip_end)],
|
||||||
);
|
);
|
||||||
|
|
||||||
# height is the vertical thickness of the extrusion expressed in mm
|
# height is the vertical thickness of the extrusion expressed in mm
|
||||||
|
@ -13,7 +13,7 @@ use Slic3r::Fill::PlanePath;
|
|||||||
use Slic3r::Fill::Rectilinear;
|
use Slic3r::Fill::Rectilinear;
|
||||||
use Slic3r::ExtrusionPath ':roles';
|
use Slic3r::ExtrusionPath ':roles';
|
||||||
use Slic3r::Geometry qw(X Y PI scale chained_path);
|
use Slic3r::Geometry qw(X Y PI scale chained_path);
|
||||||
use Slic3r::Geometry::Clipper qw(union_ex diff_ex);
|
use Slic3r::Geometry::Clipper qw(union_ex diff diff_ex intersection_ex offset);
|
||||||
use Slic3r::Surface ':types';
|
use Slic3r::Surface ':types';
|
||||||
|
|
||||||
|
|
||||||
@ -99,15 +99,46 @@ sub make_fill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# add spacing between surfaces
|
# we need to detect any narrow surfaces that might collapse
|
||||||
|
# when adding spacing below
|
||||||
|
# such narrow surfaces are often generated in sloping walls
|
||||||
|
# by bridge_over_infill() and combine_infill() as a result of the
|
||||||
|
# subtraction of the combinable area from the layer infill area,
|
||||||
|
# which leaves small areas near the perimeters
|
||||||
|
# we are going to grow such regions by overlapping them with the void (if any)
|
||||||
|
# TODO: detect and investigate whether there could be narrow regions without
|
||||||
|
# any void neighbors
|
||||||
|
my $distance_between_surfaces = $layerm->solid_infill_flow->scaled_spacing;
|
||||||
{
|
{
|
||||||
my $distance = $layerm->solid_infill_flow->scaled_spacing / 2;
|
my $collapsed = diff(
|
||||||
@surfaces = map $_->offset(-$distance * &Slic3r::INFILL_OVERLAP_OVER_SPACING), @surfaces;
|
[ map @{$_->expolygon}, @surfaces ],
|
||||||
|
[ offset(
|
||||||
|
[ offset([ map @{$_->expolygon}, @surfaces ], -$distance_between_surfaces/2) ],
|
||||||
|
+$distance_between_surfaces/2
|
||||||
|
) ],
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
push @surfaces, map Slic3r::Surface->new(
|
||||||
|
expolygon => $_,
|
||||||
|
surface_type => S_TYPE_INTERNALSOLID,
|
||||||
|
), @{intersection_ex(
|
||||||
|
[ offset($collapsed, $distance_between_surfaces) ],
|
||||||
|
[
|
||||||
|
(map @{$_->expolygon}, grep $_->surface_type == S_TYPE_INTERNALVOID, @surfaces),
|
||||||
|
(@$collapsed),
|
||||||
|
],
|
||||||
|
undef,
|
||||||
|
1,
|
||||||
|
)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# add spacing between surfaces
|
||||||
|
@surfaces = map $_->offset(-$distance_between_surfaces / 2 * &Slic3r::INFILL_OVERLAP_OVER_SPACING), @surfaces;
|
||||||
|
|
||||||
my @fills = ();
|
my @fills = ();
|
||||||
my @fills_ordering_points = ();
|
my @fills_ordering_points = ();
|
||||||
SURFACE: foreach my $surface (@surfaces) {
|
SURFACE: foreach my $surface (@surfaces) {
|
||||||
|
next if $surface->surface_type == S_TYPE_INTERNALVOID;
|
||||||
my $filler = $Slic3r::Config->fill_pattern;
|
my $filler = $Slic3r::Config->fill_pattern;
|
||||||
my $density = $Slic3r::Config->fill_density;
|
my $density = $Slic3r::Config->fill_density;
|
||||||
my $flow = ($surface->surface_type == S_TYPE_TOP)
|
my $flow = ($surface->surface_type == S_TYPE_TOP)
|
||||||
@ -124,9 +155,7 @@ sub make_fill {
|
|||||||
$density = 1;
|
$density = 1;
|
||||||
$filler = $Slic3r::Config->solid_fill_pattern;
|
$filler = $Slic3r::Config->solid_fill_pattern;
|
||||||
if ($is_bridge) {
|
if ($is_bridge) {
|
||||||
$filler = $surface->surface_type == S_TYPE_INTERNALBRIDGE
|
$filler = 'rectilinear';
|
||||||
? 'concentric'
|
|
||||||
: 'rectilinear';
|
|
||||||
$flow_spacing = $layerm->extruders->{infill}->bridge_flow->spacing;
|
$flow_spacing = $layerm->extruders->{infill}->bridge_flow->spacing;
|
||||||
} elsif ($surface->surface_type == S_TYPE_INTERNALSOLID) {
|
} elsif ($surface->surface_type == S_TYPE_INTERNALSOLID) {
|
||||||
$filler = 'rectilinear';
|
$filler = 'rectilinear';
|
||||||
|
@ -45,7 +45,15 @@ sub diff_ex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub diff {
|
sub diff {
|
||||||
return [ map @$_, diff_ex(@_) ];
|
my ($subject, $clip, $safety_offset) = @_;
|
||||||
|
|
||||||
|
$clipper->clear;
|
||||||
|
$clipper->add_subject_polygons($subject);
|
||||||
|
$clipper->add_clip_polygons($safety_offset ? safety_offset($clip) : $clip);
|
||||||
|
return [
|
||||||
|
map Slic3r::Polygon->new($_),
|
||||||
|
@{ $clipper->execute(CT_DIFFERENCE, PFT_NONZERO, PFT_NONZERO) },
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub union_ex {
|
sub union_ex {
|
||||||
|
@ -509,7 +509,8 @@ sub bridge_over_infill {
|
|||||||
|
|
||||||
# exclude infill from the layers below if needed
|
# exclude infill from the layers below if needed
|
||||||
# see discussion at https://github.com/alexrj/Slic3r/issues/240
|
# see discussion at https://github.com/alexrj/Slic3r/issues/240
|
||||||
{
|
# Update: do not exclude any infill. Sparse infill is able to absorb the excess material.
|
||||||
|
if (0) {
|
||||||
my $excess = $layerm->extruders->{infill}->bridge_flow->width - $layerm->height;
|
my $excess = $layerm->extruders->{infill}->bridge_flow->width - $layerm->height;
|
||||||
for (my $i = $layer_id-1; $excess >= $self->layers->[$i]->height; $i--) {
|
for (my $i = $layer_id-1; $excess >= $self->layers->[$i]->height; $i--) {
|
||||||
Slic3r::debugf " skipping infill below those areas at layer %d\n", $i;
|
Slic3r::debugf " skipping infill below those areas at layer %d\n", $i;
|
||||||
@ -524,6 +525,13 @@ sub bridge_over_infill {
|
|||||||
[ map $_->p, @$group ],
|
[ map $_->p, @$group ],
|
||||||
[ map @$_, @$to_bridge ],
|
[ map @$_, @$to_bridge ],
|
||||||
)};
|
)};
|
||||||
|
push @new_surfaces, map Slic3r::Surface->new(
|
||||||
|
expolygon => $_,
|
||||||
|
surface_type => S_TYPE_INTERNALVOID,
|
||||||
|
), @{intersection_ex(
|
||||||
|
[ map $_->p, @$group ],
|
||||||
|
[ map @$_, @$to_bridge ],
|
||||||
|
)};
|
||||||
}
|
}
|
||||||
@{$lower_layerm->fill_surfaces} = @new_surfaces;
|
@{$lower_layerm->fill_surfaces} = @new_surfaces;
|
||||||
}
|
}
|
||||||
@ -585,6 +593,7 @@ sub discover_horizontal_shells {
|
|||||||
my $too_narrow = diff_ex(
|
my $too_narrow = diff_ex(
|
||||||
[ map @$_, @$new_internal_solid ],
|
[ map @$_, @$new_internal_solid ],
|
||||||
[ offset([ offset([ map @$_, @$new_internal_solid ], -$margin) ], +$margin) ],
|
[ offset([ offset([ map @$_, @$new_internal_solid ], -$margin) ], +$margin) ],
|
||||||
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
# if some parts are going to collapse, let's grow them and add the extra area to the neighbor layer
|
# if some parts are going to collapse, let's grow them and add the extra area to the neighbor layer
|
||||||
@ -722,7 +731,7 @@ sub combine_infill {
|
|||||||
my @this_type = grep $_->surface_type == $type, @{$layerm->fill_surfaces};
|
my @this_type = grep $_->surface_type == $type, @{$layerm->fill_surfaces};
|
||||||
my @other_types = grep $_->surface_type != $type, @{$layerm->fill_surfaces};
|
my @other_types = grep $_->surface_type != $type, @{$layerm->fill_surfaces};
|
||||||
|
|
||||||
@this_type = map Slic3r::Surface->new(expolygon => $_, surface_type => $type),
|
my @new_this_type = map Slic3r::Surface->new(expolygon => $_, surface_type => $type),
|
||||||
@{diff_ex(
|
@{diff_ex(
|
||||||
[ map @{$_->expolygon}, @this_type ],
|
[ map @{$_->expolygon}, @this_type ],
|
||||||
[ @intersection_with_clearance ],
|
[ @intersection_with_clearance ],
|
||||||
@ -730,7 +739,7 @@ sub combine_infill {
|
|||||||
|
|
||||||
# apply surfaces back with adjusted depth to the uppermost layer
|
# apply surfaces back with adjusted depth to the uppermost layer
|
||||||
if ($layerm->id == $layer_id) {
|
if ($layerm->id == $layer_id) {
|
||||||
push @this_type,
|
push @new_this_type,
|
||||||
map Slic3r::Surface->new(
|
map Slic3r::Surface->new(
|
||||||
expolygon => $_,
|
expolygon => $_,
|
||||||
surface_type => $type,
|
surface_type => $type,
|
||||||
@ -738,9 +747,17 @@ sub combine_infill {
|
|||||||
thickness_layers => scalar(@layerms),
|
thickness_layers => scalar(@layerms),
|
||||||
),
|
),
|
||||||
@$intersection;
|
@$intersection;
|
||||||
|
} else {
|
||||||
|
# save void surfaces
|
||||||
|
push @this_type,
|
||||||
|
map Slic3r::Surface->new(expolygon => $_, surface_type => S_TYPE_INTERNALVOID),
|
||||||
|
@{intersection_ex(
|
||||||
|
[ map @{$_->expolygon}, @this_type ],
|
||||||
|
[ @intersection_with_clearance ],
|
||||||
|
)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@{$layerm->fill_surfaces} = (@this_type, @other_types);
|
@{$layerm->fill_surfaces} = (@new_this_type, @other_types);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use warnings;
|
|||||||
|
|
||||||
require Exporter;
|
require Exporter;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT_OK = qw(S_TYPE_TOP S_TYPE_BOTTOM S_TYPE_INTERNAL S_TYPE_INTERNALSOLID S_TYPE_INTERNALBRIDGE);
|
our @EXPORT_OK = qw(S_TYPE_TOP S_TYPE_BOTTOM S_TYPE_INTERNAL S_TYPE_INTERNALSOLID S_TYPE_INTERNALBRIDGE S_TYPE_INTERNALVOID);
|
||||||
our %EXPORT_TAGS = (types => \@EXPORT_OK);
|
our %EXPORT_TAGS = (types => \@EXPORT_OK);
|
||||||
|
|
||||||
use constant S_EXPOLYGON => 0;
|
use constant S_EXPOLYGON => 0;
|
||||||
@ -19,6 +19,7 @@ use constant S_TYPE_BOTTOM => 1;
|
|||||||
use constant S_TYPE_INTERNAL => 2;
|
use constant S_TYPE_INTERNAL => 2;
|
||||||
use constant S_TYPE_INTERNALSOLID => 3;
|
use constant S_TYPE_INTERNALSOLID => 3;
|
||||||
use constant S_TYPE_INTERNALBRIDGE => 4;
|
use constant S_TYPE_INTERNALBRIDGE => 4;
|
||||||
|
use constant S_TYPE_INTERNALVOID => 5;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
@ -27,7 +28,7 @@ sub new {
|
|||||||
my $self = [
|
my $self = [
|
||||||
map delete $args{$_}, qw(expolygon surface_type thickness thickness_layers bridge_angle extra_perimeters),
|
map delete $args{$_}, qw(expolygon surface_type thickness thickness_layers bridge_angle extra_perimeters),
|
||||||
];
|
];
|
||||||
$self->[$_] //= 1 for S_THICKNESS, S_THICKNESS_LAYERS;
|
$self->[S_THICKNESS_LAYERS] = 1;
|
||||||
|
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
$self;
|
$self;
|
||||||
@ -72,8 +73,8 @@ sub group {
|
|||||||
foreach my $surface (@surfaces) {
|
foreach my $surface (@surfaces) {
|
||||||
my $type = join '_',
|
my $type = join '_',
|
||||||
($params->{merge_solid} && $surface->is_solid) ? 'solid' : $surface->surface_type,
|
($params->{merge_solid} && $surface->is_solid) ? 'solid' : $surface->surface_type,
|
||||||
($surface->bridge_angle // ''),
|
$surface->bridge_angle // '',
|
||||||
$surface->thickness,
|
$surface->thickness // '',
|
||||||
$surface->thickness_layers;
|
$surface->thickness_layers;
|
||||||
$unique_types{$type} ||= [];
|
$unique_types{$type} ||= [];
|
||||||
push @{ $unique_types{$type} }, $surface;
|
push @{ $unique_types{$type} }, $surface;
|
||||||
@ -102,17 +103,6 @@ sub _inflate_expolygon {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub clipper_polygon {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
return {
|
|
||||||
outer => $self->contour->p,
|
|
||||||
holes => [
|
|
||||||
map $_->p, @{$self->holes}
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub p {
|
sub p {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return @{$self->expolygon};
|
return @{$self->expolygon};
|
||||||
@ -127,14 +117,6 @@ sub is_solid {
|
|||||||
|| $type == S_TYPE_INTERNALSOLID;
|
|| $type == S_TYPE_INTERNALSOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub is_internal {
|
|
||||||
my $self = shift;
|
|
||||||
my $type = $self->surface_type;
|
|
||||||
return $type == S_TYPE_INTERNAL
|
|
||||||
|| $type == S_TYPE_INTERNALSOLID
|
|
||||||
|| $type == S_TYPE_INTERNALBRIDGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub is_bridge {
|
sub is_bridge {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $type = $self->surface_type;
|
my $type = $self->surface_type;
|
||||||
|
@ -119,9 +119,11 @@ sub parse {
|
|||||||
}
|
}
|
||||||
$info{dist_XY} = Slic3r::Line->new([0,0], [@info{qw(dist_X dist_Y)}])->length;
|
$info{dist_XY} = Slic3r::Line->new([0,0], [@info{qw(dist_X dist_Y)}])->length;
|
||||||
if (exists $args{E}) {
|
if (exists $args{E}) {
|
||||||
($info{dist_E} > 0)
|
if ($info{dist_E} > 0) {
|
||||||
? ($info{extruding} = 1)
|
$info{extruding} = 1;
|
||||||
: ($info{retracting} = 1);
|
} elsif ($info{dist_E} < 0) {
|
||||||
|
$info{retracting} = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,8 +585,8 @@ sub horizontal_projection {
|
|||||||
push @f, Slic3r::Polygon->new([ map [ @{$self->vertices->[$_]}[X,Y] ], @$facet ]);
|
push @f, Slic3r::Polygon->new([ map [ @{$self->vertices->[$_]}[X,Y] ], @$facet ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_->make_counter_clockwise for @f;
|
|
||||||
my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f);
|
my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f);
|
||||||
|
$_->make_counter_clockwise for @f; # do this after scaling, as winding order might change while doing that
|
||||||
my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 10000) ]);
|
my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 10000) ]);
|
||||||
Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union;
|
Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union;
|
||||||
return $union;
|
return $union;
|
||||||
|
@ -88,6 +88,7 @@ my $test = sub {
|
|||||||
1;
|
1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$config->set('first_layer_height', $config->layer_height);
|
||||||
$config->set('start_gcode', ''); # to avoid dealing with the nozzle lift in start G-code
|
$config->set('start_gcode', ''); # to avoid dealing with the nozzle lift in start G-code
|
||||||
$config->set('retract_length', [1.5]);
|
$config->set('retract_length', [1.5]);
|
||||||
$config->set('retract_before_travel', [3]);
|
$config->set('retract_before_travel', [3]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user