diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 9c5479f2..fca2e95f 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -164,6 +164,11 @@ sub slice { $self->layers->[$i]->id($i); } } + + # remove empty layers from top + while (@{$self->layers} && !@{$self->layers->[-1]->slices} && !map @{$_->thin_walls}, @{$self->layers->[-1]->regions}) { + pop @{$self->layers}; + } warn "No layers were detected. You might want to repair your STL file and retry.\n" if !@{$self->layers}; diff --git a/lib/Slic3r/TriangleMesh.pm b/lib/Slic3r/TriangleMesh.pm index a2a416b5..c1b4c11a 100644 --- a/lib/Slic3r/TriangleMesh.pm +++ b/lib/Slic3r/TriangleMesh.pm @@ -296,11 +296,16 @@ sub make_loops { next CYCLE; } - push @points, $next_line->[I_B]; + push @points, $next_line->[I_B] if !same_point($line->[I_B], $next_line->[I_B]); $visited_lines{$next_line} = 1; $line = $next_line; } while ($first_facet_index != $line->[I_FACET_INDEX]); + if (@points <= 2) { + Slic3r::debugf " polygon reduced to %d points\n", scalar(@points); + next CYCLE; + } + push @polygons, Slic3r::Polygon->new(@points); Slic3r::debugf " Discovered %s polygon of %d points\n", ($polygons[-1]->is_counter_clockwise ? 'ccw' : 'cw'), scalar(@points)