Allow value -1 for skirt_height with the meaning of: as tall as the object. This might fix an overflow on 32-bit systems when ooze_prevention is enabled

This commit is contained in:
Alessandro Ranellucci 2013-12-24 15:15:53 +01:00
parent bd133d9434
commit f9d38f6655
3 changed files with 16 additions and 12 deletions

View file

@ -271,7 +271,7 @@ sub validate {
# --skirt-height # --skirt-height
die "Invalid value for --skirt-height\n" die "Invalid value for --skirt-height\n"
if $self->skirt_height < 0; if $self->skirt_height < -1; # -1 means as tall as the object
# --bridge-flow-ratio # --bridge-flow-ratio
die "Invalid value for --bridge-flow-ratio\n" die "Invalid value for --bridge-flow-ratio\n"

View file

@ -48,7 +48,7 @@ sub process_layer {
# check whether we're going to apply spiralvase logic # check whether we're going to apply spiralvase logic
my $spiralvase = defined $self->spiralvase my $spiralvase = defined $self->spiralvase
&& ($layer->id > 0 || $self->gcodegen->config->brim_width == 0) && ($layer->id > 0 || $self->gcodegen->config->brim_width == 0)
&& ($layer->id >= $self->gcodegen->config->skirt_height) && ($layer->id >= $self->gcodegen->config->skirt_height && $self->gcodegen->config->skirt_height != -1)
&& ($layer->id >= $self->gcodegen->config->bottom_solid_layers); && ($layer->id >= $self->gcodegen->config->bottom_solid_layers);
# if we're going to apply spiralvase to this layer, disable loop clipping # if we're going to apply spiralvase to this layer, disable loop clipping
@ -71,11 +71,12 @@ sub process_layer {
}) . "\n" if $self->gcodegen->config->layer_gcode; }) . "\n" if $self->gcodegen->config->layer_gcode;
# extrude skirt # extrude skirt
if ((values %{$self->skirt_done}) < $self->gcodegen->config->skirt_height && !$self->skirt_done->{$layer->print_z}) { if (((values %{$self->skirt_done}) < $self->gcodegen->config->skirt_height || $self->gcodegen->config->skirt_height == -1)
&& !$self->skirt_done->{$layer->print_z}) {
$self->gcodegen->set_shift(@{$self->shift}); $self->gcodegen->set_shift(@{$self->shift});
$gcode .= $self->gcodegen->set_extruder($self->extruders->[0]); $gcode .= $self->gcodegen->set_extruder($self->extruders->[0]);
# skip skirt if we have a large brim # skip skirt if we have a large brim
if ($layer->id < $self->gcodegen->config->skirt_height) { if ($layer->id < $self->gcodegen->config->skirt_height || $self->gcodegen->config->skirt_height == -1) {
# distribute skirt loops across all extruders # distribute skirt loops across all extruders
my @skirt_loops = @{$self->print->skirt}; my @skirt_loops = @{$self->print->skirt};
for my $i (0 .. $#skirt_loops) { for my $i (0 .. $#skirt_loops) {

View file

@ -292,7 +292,7 @@ sub init_extruders {
# enforce tall skirt if using ooze_prevention # enforce tall skirt if using ooze_prevention
# NOTE: this is not idempotent (i.e. switching ooze_prevention off will not revert skirt settings) # NOTE: this is not idempotent (i.e. switching ooze_prevention off will not revert skirt settings)
if ($self->config->ooze_prevention && @{$self->extruders} > 1) { if ($self->config->ooze_prevention && @{$self->extruders} > 1) {
$self->config->set('skirt_height', 9999999999); $self->config->set('skirt_height', -1);
$self->config->set('skirts', 1) if $self->config->skirts == 0; $self->config->set('skirts', 1) if $self->config->skirts == 0;
} }
} }
@ -823,14 +823,17 @@ sub write_gcode {
# calculate wiping points if needed # calculate wiping points if needed
if ($self->config->ooze_prevention) { if ($self->config->ooze_prevention) {
my $outer_skirt = convex_hull([ map @$_, @{$self->skirt} ]); my @skirt_points = map @$_, @{$self->skirt};
my @skirts = (); if (@skirt_points) {
foreach my $extruder (@{$self->extruders}) { my $outer_skirt = convex_hull(\@skirt_points);
push @skirts, my $s = $outer_skirt->clone; my @skirts = ();
$s->translate(map scale($_), @{$extruder->extruder_offset}); foreach my $extruder (@{$self->extruders}) {
push @skirts, my $s = $outer_skirt->clone;
$s->translate(map scale($_), @{$extruder->extruder_offset});
}
my $convex_hull = convex_hull([ map @$_, @skirts ]);
$gcodegen->standby_points([ map $_->clone, map @$_, map $_->subdivide(scale 10), @{offset([$convex_hull], scale 3)} ]);
} }
my $convex_hull = convex_hull([ map @$_, @skirts ]);
$gcodegen->standby_points([ map $_->clone, map @$_, map $_->subdivide(scale 10), @{offset([$convex_hull], scale 3)} ]);
} }
# prepare the layer processor # prepare the layer processor