diff --git a/lib/Slic3r/Layer/PerimeterGenerator.pm b/lib/Slic3r/Layer/PerimeterGenerator.pm index 90893d535..371189d75 100644 --- a/lib/Slic3r/Layer/PerimeterGenerator.pm +++ b/lib/Slic3r/Layer/PerimeterGenerator.pm @@ -259,7 +259,8 @@ sub process { || ($self->layer_id == 0 && $self->print_config->brim_width > 0); # append perimeters for this slice as a collection - $self->loops->append(Slic3r::ExtrusionPath::Collection->new(@loops)); + $self->loops->append(Slic3r::ExtrusionPath::Collection->new(@loops)) + if @loops; } } diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index fa9c919ef..d3bff0f5d 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -425,6 +425,8 @@ sub process_layer { { my $extruder_id = $region->config->perimeter_extruder-1; foreach my $perimeter_coll (@{$layerm->perimeters}) { + next if $perimeter_coll->empty; # this shouldn't happen but first_point() would fail + # init by_extruder item only if we actually use the extruder $by_extruder{$extruder_id} //= []; @@ -447,6 +449,8 @@ sub process_layer { # throughout the code). We can redefine the order of such Collections but we have to # do each one completely at once. foreach my $fill (@{$layerm->fills}) { + next if $fill->empty; # this shouldn't happen but first_point() would fail + # init by_extruder item only if we actually use the extruder my $extruder_id = $fill->[0]->is_solid_infill ? $region->config->solid_infill_extruder-1 diff --git a/xs/xsp/ExtrusionEntityCollection.xsp b/xs/xsp/ExtrusionEntityCollection.xsp index fa1d26eed..a5214e939 100644 --- a/xs/xsp/ExtrusionEntityCollection.xsp +++ b/xs/xsp/ExtrusionEntityCollection.xsp @@ -24,6 +24,8 @@ Clone last_point(); int count() %code{% RETVAL = THIS->entities.size(); %}; + bool empty() + %code{% RETVAL = THIS->entities.empty(); %}; std::vector orig_indices() %code{% RETVAL = THIS->orig_indices; %}; %{