mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 21:35:54 +08:00
Remove $Slic3r::flow and $Slic3r::first_layer_flow
This commit is contained in:
parent
b9c84490b8
commit
91bcfc8a74
@ -69,12 +69,7 @@ use constant SMALL_PERIMETER_LENGTH => (6.5 / SCALING_FACTOR) * 2 * PI;
|
|||||||
use constant LOOP_CLIPPING_LENGTH_OVER_SPACING => 0.15;
|
use constant LOOP_CLIPPING_LENGTH_OVER_SPACING => 0.15;
|
||||||
use constant PERIMETER_INFILL_OVERLAP_OVER_SPACING => 0.45;
|
use constant PERIMETER_INFILL_OVERLAP_OVER_SPACING => 0.45;
|
||||||
|
|
||||||
# The following variables hold the objects used throughout the slicing
|
|
||||||
# process. They should belong to the Print object, but we are keeping
|
|
||||||
# them here because it makes accessing them slightly faster.
|
|
||||||
our $Config;
|
our $Config;
|
||||||
our $flow;
|
|
||||||
our $first_layer_flow;
|
|
||||||
|
|
||||||
sub parallelize {
|
sub parallelize {
|
||||||
my %params = @_;
|
my %params = @_;
|
||||||
|
@ -13,7 +13,6 @@ has 'slicing_errors' => (is => 'rw');
|
|||||||
has 'slice_z' => (is => 'lazy');
|
has 'slice_z' => (is => 'lazy');
|
||||||
has 'print_z' => (is => 'lazy');
|
has 'print_z' => (is => 'lazy');
|
||||||
has 'height' => (is => 'lazy');
|
has 'height' => (is => 'lazy');
|
||||||
has 'flow' => (is => 'lazy');
|
|
||||||
|
|
||||||
# collection of expolygons generated by slicing the original geometry;
|
# collection of expolygons generated by slicing the original geometry;
|
||||||
# also known as 'islands' (all regions are merged here)
|
# also known as 'islands' (all regions are merged here)
|
||||||
@ -57,8 +56,6 @@ sub _build_height {
|
|||||||
return $self->id == 0 ? $Slic3r::Config->get_value('first_layer_height') : $Slic3r::Config->layer_height;
|
return $self->id == 0 ? $Slic3r::Config->get_value('first_layer_height') : $Slic3r::Config->layer_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _build_flow { $Slic3r::flow }
|
|
||||||
|
|
||||||
# layer height of contact paths in unscaled coordinates
|
# layer height of contact paths in unscaled coordinates
|
||||||
sub support_material_contact_height {
|
sub support_material_contact_height {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
@ -69,7 +66,8 @@ sub support_material_contact_height {
|
|||||||
# - we should sum our height with the actual upper layers height (which might be different)
|
# - we should sum our height with the actual upper layers height (which might be different)
|
||||||
# - we should use the actual flow of the upper layer bridges, not the default one
|
# - we should use the actual flow of the upper layer bridges, not the default one
|
||||||
# ...but we're close enough for now
|
# ...but we're close enough for now
|
||||||
return 2*$self->height - $self->flow->nozzle_diameter;
|
my $upper_layer = $self->object->layers->[ $self->id + 1 ] // $self;
|
||||||
|
return 2*$self->height - $upper_layer->infill_flow->bridge_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Z used for printing support material contact in scaled coordinates
|
# Z used for printing support material contact in scaled coordinates
|
||||||
@ -115,6 +113,7 @@ sub make_perimeters {
|
|||||||
sub support_islands_enclose_line {
|
sub support_islands_enclose_line {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($line) = @_;
|
my ($line) = @_;
|
||||||
|
return 0 if !$self->support_islands; # why can we arrive here if there are no support islands?
|
||||||
return (first { $_->encloses_line($line) } @{$self->support_islands}) ? 1 : 0;
|
return (first { $_->encloses_line($line) } @{$self->support_islands}) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +57,11 @@ sub _update_flows {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
return if !$self->region;
|
return if !$self->region;
|
||||||
|
|
||||||
$self->perimeter_flow($self->id == 0
|
$self->perimeter_flow
|
||||||
? $self->region->first_layer_flows->{perimeter}
|
($self->region->first_layer_flows->{perimeter} || $self->region->flows->{perimeter});
|
||||||
: $self->region->flows->{perimeter});
|
|
||||||
|
|
||||||
$self->infill_flow($self->id == 0
|
$self->infill_flow
|
||||||
? $self->region->first_layer_flows->{infill}
|
($self->region->first_layer_flows->{infill} || $self->region->flows->{infill});
|
||||||
: $self->region->flows->{infill});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _build_overhang_width {
|
sub _build_overhang_width {
|
||||||
@ -471,7 +469,7 @@ sub process_bridges {
|
|||||||
# offset the contour and intersect it with the internal surfaces to discover
|
# offset the contour and intersect it with the internal surfaces to discover
|
||||||
# which of them has contact with our bridge
|
# which of them has contact with our bridge
|
||||||
my @supporting_surfaces = ();
|
my @supporting_surfaces = ();
|
||||||
my ($contour_offset) = $expolygon->contour->offset(scale $self->flow->spacing * sqrt(2));
|
my ($contour_offset) = $expolygon->contour->offset(scale $self->infill_flow->spacing * sqrt(2));
|
||||||
foreach my $internal_surface (@internal_surfaces) {
|
foreach my $internal_surface (@internal_surfaces) {
|
||||||
my $intersection = intersection_ex([$contour_offset], [$internal_surface->p]);
|
my $intersection = intersection_ex([$contour_offset], [$internal_surface->p]);
|
||||||
if (@$intersection) {
|
if (@$intersection) {
|
||||||
|
@ -195,15 +195,6 @@ sub init_extruders {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# calculate default flows
|
|
||||||
$Slic3r::flow = $self->extruders->[0]->make_flow(
|
|
||||||
width => $self->config->extrusion_width,
|
|
||||||
);
|
|
||||||
$Slic3r::first_layer_flow = $self->extruders->[0]->make_flow(
|
|
||||||
layer_height => $self->config->get_value('first_layer_height'),
|
|
||||||
width => $self->config->first_layer_extrusion_width,
|
|
||||||
);
|
|
||||||
|
|
||||||
# calculate regions' flows
|
# calculate regions' flows
|
||||||
for my $region_id (0 .. $#{$self->regions}) {
|
for my $region_id (0 .. $#{$self->regions}) {
|
||||||
my $region = $self->regions->[$region_id];
|
my $region = $self->regions->[$region_id];
|
||||||
@ -219,7 +210,7 @@ sub init_extruders {
|
|||||||
$region->first_layer_flows->{$_} = $region->extruders->{$_}->make_flow(
|
$region->first_layer_flows->{$_} = $region->extruders->{$_}->make_flow(
|
||||||
layer_height => $self->config->get_value('first_layer_height'),
|
layer_height => $self->config->get_value('first_layer_height'),
|
||||||
width => $self->config->first_layer_extrusion_width,
|
width => $self->config->first_layer_extrusion_width,
|
||||||
);
|
) if $self->config->first_layer_extrusion_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,9 +225,6 @@ sub init_extruders {
|
|||||||
width => $self->config->first_layer_extrusion_width,
|
width => $self->config->first_layer_extrusion_width,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Slic3r::debugf "Default flow width = %s (spacing = %s)\n",
|
|
||||||
$Slic3r::flow->width, $Slic3r::flow->spacing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub object_copies {
|
sub object_copies {
|
||||||
@ -573,7 +561,10 @@ sub make_skirt {
|
|||||||
my $convex_hull = convex_hull(\@points);
|
my $convex_hull = convex_hull(\@points);
|
||||||
|
|
||||||
my @extruded_length = (); # for each extruder
|
my @extruded_length = (); # for each extruder
|
||||||
my $spacing = $Slic3r::first_layer_flow->spacing;
|
|
||||||
|
# TODO: use each extruder's own flow
|
||||||
|
my $spacing = $self->objects->[0]->layers->[0]->regions->[0]->perimeter_flow->spacing;
|
||||||
|
|
||||||
my $first_layer_height = $Slic3r::Config->get_value('first_layer_height');
|
my $first_layer_height = $Slic3r::Config->get_value('first_layer_height');
|
||||||
my @extruders_e_per_mm = ();
|
my @extruders_e_per_mm = ();
|
||||||
my $extruder_idx = 0;
|
my $extruder_idx = 0;
|
||||||
@ -612,7 +603,9 @@ sub make_brim {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
return unless $Slic3r::Config->brim_width > 0;
|
return unless $Slic3r::Config->brim_width > 0;
|
||||||
|
|
||||||
my $grow_distance = $Slic3r::first_layer_flow->scaled_width / 2;
|
my $flow = $self->objects->[0]->layers->[0]->regions->[0]->perimeter_flow;
|
||||||
|
|
||||||
|
my $grow_distance = $flow->scaled_width / 2;
|
||||||
my @islands = (); # array of polygons
|
my @islands = (); # array of polygons
|
||||||
foreach my $obj_idx (0 .. $#{$self->objects}) {
|
foreach my $obj_idx (0 .. $#{$self->objects}) {
|
||||||
my $layer0 = $self->objects->[$obj_idx]->layers->[0];
|
my $layer0 = $self->objects->[$obj_idx]->layers->[0];
|
||||||
@ -627,18 +620,19 @@ sub make_brim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if brim touches skirt, make it around skirt too
|
# if brim touches skirt, make it around skirt too
|
||||||
if ($Slic3r::Config->skirt_distance + (($Slic3r::Config->skirts - 1) * $Slic3r::first_layer_flow->spacing) <= $Slic3r::Config->brim_width) {
|
# TODO: calculate actual skirt width (using each extruder's flow in multi-extruder setups)
|
||||||
|
if ($Slic3r::Config->skirt_distance + (($Slic3r::Config->skirts - 1) * $flow->spacing) <= $Slic3r::Config->brim_width) {
|
||||||
push @islands, map $_->unpack->split_at_first_point->polyline->grow($grow_distance), @{$self->skirt};
|
push @islands, map $_->unpack->split_at_first_point->polyline->grow($grow_distance), @{$self->skirt};
|
||||||
}
|
}
|
||||||
|
|
||||||
my $num_loops = sprintf "%.0f", $Slic3r::Config->brim_width / $Slic3r::first_layer_flow->width;
|
my $num_loops = sprintf "%.0f", $Slic3r::Config->brim_width / $flow->width;
|
||||||
for my $i (reverse 1 .. $num_loops) {
|
for my $i (reverse 1 .. $num_loops) {
|
||||||
# JT_SQUARE ensures no vertex is outside the given offset distance
|
# JT_SQUARE ensures no vertex is outside the given offset distance
|
||||||
push @{$self->brim}, Slic3r::ExtrusionLoop->pack(
|
push @{$self->brim}, Slic3r::ExtrusionLoop->pack(
|
||||||
polygon => Slic3r::Polygon->new($_),
|
polygon => Slic3r::Polygon->new($_),
|
||||||
role => EXTR_ROLE_SKIRT,
|
role => EXTR_ROLE_SKIRT,
|
||||||
flow_spacing => $Slic3r::first_layer_flow->spacing,
|
flow_spacing => $flow->spacing,
|
||||||
) for Slic3r::Geometry::Clipper::offset(\@islands, $i * $Slic3r::first_layer_flow->scaled_spacing, undef, JT_SQUARE);
|
) for Slic3r::Geometry::Clipper::offset(\@islands, $i * $flow->scaled_spacing, undef, JT_SQUARE);
|
||||||
# TODO: we need the offset inwards/offset outwards logic to avoid overlapping extrusions
|
# TODO: we need the offset inwards/offset outwards logic to avoid overlapping extrusions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,8 +668,8 @@ sub write_gcode {
|
|||||||
printf $fh "; infill extrusion width = %.2fmm\n", $self->regions->[0]->flows->{infill}->width;
|
printf $fh "; infill extrusion width = %.2fmm\n", $self->regions->[0]->flows->{infill}->width;
|
||||||
printf $fh "; support material extrusion width = %.2fmm\n", $self->support_material_flow->width
|
printf $fh "; support material extrusion width = %.2fmm\n", $self->support_material_flow->width
|
||||||
if $self->support_material_flow;
|
if $self->support_material_flow;
|
||||||
printf $fh "; first layer extrusion width = %.2fmm\n", $Slic3r::first_layer_flow->width
|
printf $fh "; first layer extrusion width = %.2fmm\n", $self->regions->[0]->first_layer_flows->{perimeter}->width
|
||||||
if $Slic3r::first_layer_flow;
|
if $self->regions->[0]->first_layer_flows->{perimeter};
|
||||||
print $fh "\n";
|
print $fh "\n";
|
||||||
|
|
||||||
# set up our extruder object
|
# set up our extruder object
|
||||||
|
@ -306,7 +306,7 @@ sub detect_surfaces_type {
|
|||||||
[ map { ref $_ eq 'ARRAY' ? $_ : ref $_ eq 'Slic3r::ExPolygon' ? @$_ : $_->p } @$clip_surfaces ],
|
[ map { ref $_ eq 'ARRAY' ? $_ : ref $_ eq 'Slic3r::ExPolygon' ? @$_ : $_->p } @$clip_surfaces ],
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
return grep $_->contour->is_printable($layerm->flow),
|
return grep $_->contour->is_printable($layerm->infill_flow),
|
||||||
map Slic3r::Surface->new(expolygon => $_, surface_type => $result_type),
|
map Slic3r::Surface->new(expolygon => $_, surface_type => $result_type),
|
||||||
@$expolygons;
|
@$expolygons;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user