Remove features that are too small to be printed
This commit is contained in:
parent
081f65852d
commit
c2a62891da
@ -304,4 +304,23 @@ sub merge_contiguous_surfaces {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub remove_small_features {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
# for each perimeter, try to get an inwards offset
|
||||||
|
# for a distance equal to half of the extrusion width;
|
||||||
|
# if no offset is possible, then feature is not printable
|
||||||
|
my @good_perimeters = ();
|
||||||
|
foreach my $loop (@{$self->perimeters}) {
|
||||||
|
my $p = $loop->p;
|
||||||
|
@$p = reverse @$p if !is_counter_clockwise($p);
|
||||||
|
my $offsets = offset([$p], -($Slic3r::flow_width / 2 / $Slic3r::resolution), 100, JT_MITER, 2);
|
||||||
|
push @good_perimeters, $loop if @$offsets;
|
||||||
|
}
|
||||||
|
Slic3r::debugf "removed %d unprintable perimeters\n", (@{$self->perimeters} - @good_perimeters)
|
||||||
|
if @good_perimeters != @{$self->perimeters};
|
||||||
|
|
||||||
|
@{$self->perimeters} = @good_perimeters;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -91,8 +91,7 @@ sub discover_horizontal_shells {
|
|||||||
$clipper->clear;
|
$clipper->clear;
|
||||||
|
|
||||||
# Note: due to floating point math we're going to get some very small
|
# Note: due to floating point math we're going to get some very small
|
||||||
# polygons as $internal_polygons; they should be discarded, but a reliable
|
# polygons as $internal_polygons; they will be removed by removed_small_features()
|
||||||
# way to detect them is needed, and they seem to be harmless so we keep them for now
|
|
||||||
|
|
||||||
# assign resulting inner surfaces to layer
|
# assign resulting inner surfaces to layer
|
||||||
$self->layers->[$n]->surfaces([]);
|
$self->layers->[$n]->surfaces([]);
|
||||||
@ -121,6 +120,13 @@ sub discover_horizontal_shells {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# remove perimeters and fill surfaces which are too small to be extruded
|
||||||
|
sub remove_small_features {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$_->remove_small_features for @{$self->layers};
|
||||||
|
}
|
||||||
|
|
||||||
sub extrude_perimeters {
|
sub extrude_perimeters {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ if ($action eq 'skein') {
|
|||||||
my $t0 = [gettimeofday];
|
my $t0 = [gettimeofday];
|
||||||
my $print = $stl_parser->parse_file($input_file);
|
my $print = $stl_parser->parse_file($input_file);
|
||||||
$print->extrude_perimeters;
|
$print->extrude_perimeters;
|
||||||
|
$print->remove_small_features;
|
||||||
$print->extrude_fills;
|
$print->extrude_fills;
|
||||||
|
|
||||||
my $output_file = $input_file;
|
my $output_file = $input_file;
|
||||||
|
Loading…
Reference in New Issue
Block a user