Skip to content

Commit

Permalink
Revert "Remove thumbnail simplification because it caused loss of ver…
Browse files Browse the repository at this point in the history
…y thin parts. slic3r#1327"

This reverts commit 1210b89.

Conflicts:

	lib/Slic3r/GUI/Plater.pm
  • Loading branch information
alranel committed Aug 5, 2013
1 parent 0ce7ebc commit 4438aec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions lib/Slic3r/ExPolygon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ use Slic3r::Geometry qw(X1 Y1);

has 'expolygons' => (is => 'ro', default => sub { [] });

sub append {
my $self = shift;
push @{$self->expolygons}, @_;
}

sub clone {
my $self = shift;
return (ref $self)->new(
Expand Down
24 changes: 15 additions & 9 deletions lib/Slic3r/GUI/Plater.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1167,17 +1167,23 @@ sub make_thumbnail {
my $self = shift;

my $mesh = $self->model_object->mesh; # $self->model_object is already aligned to origin
my $thumbnail = Slic3r::ExPolygon::Collection->new(
expolygons => (@{$mesh->facets} <= 5000)
? $mesh->horizontal_projection
: [ Slic3r::ExPolygon->new($self->convex_hull) ],
);
# Note: the call to simplify() was removed here because it used Clipper
# simplification which needs integerization.
# TODO: remove polygons with area <= 1 pixel
my $thumbnail = Slic3r::ExPolygon::Collection->new;
if (@{$mesh->facets} <= 5000) {
$thumbnail->append(@{ $mesh->horizontal_projection });
} else {
my $convex_hull = Slic3r::ExPolygon->new($self->convex_hull)->clone;
$convex_hull->scale(1/&Slic3r::SCALING_FACTOR);
$thumbnail->append($convex_hull);
}

$thumbnail->scale(&Slic3r::SCALING_FACTOR);
# remove polygons with area <= 1mm
my $area_threshold = Slic3r::Geometry::scale 1;
@{$thumbnail->expolygons} =
map $_->simplify(0.5),
grep $_->area >= $area_threshold,
@{$thumbnail->expolygons};

$thumbnail->scale(&Slic3r::SCALING_FACTOR);
$self->thumbnail($thumbnail); # ignored in multi-threaded environments
$self->free_model_object;

Expand Down

0 comments on commit 4438aec

Please sign in to comment.