diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index cbb5e181b..a6fb6cf2e 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1174,6 +1174,9 @@ sub make_thumbnail { ); # Note: the call to simplify() was removed here because it used Clipper # simplification which needs integerization. + # TODO: remove polygons with area <= 1 pixel + + $thumbnail->scale(&Slic3r::SCALING_FACTOR); $self->thumbnail($thumbnail); # ignored in multi-threaded environments $self->free_model_object; diff --git a/lib/Slic3r/TriangleMesh.pm b/lib/Slic3r/TriangleMesh.pm index bebce7716..c2e543467 100644 --- a/lib/Slic3r/TriangleMesh.pm +++ b/lib/Slic3r/TriangleMesh.pm @@ -3,7 +3,7 @@ use Moo; use List::Util qw(reduce min max first); use Slic3r::Geometry qw(X Y Z A B unscale same_point); -use Slic3r::Geometry::Clipper qw(union_ex); +use Slic3r::Geometry::Clipper qw(union_ex offset); use Storable; # public @@ -550,19 +550,20 @@ sub split_mesh { return @meshes; } +# this will return *scaled* expolygons, so it is expected to be run +# on unscaled meshes sub horizontal_projection { my $self = shift; my @f = (); foreach my $facet (@{$self->facets}) { - push @f, Slic3r::Polygon->new(map [ @{$self->vertices->[$_]}[X,Y] ], @$facet); + push @f, Slic3r::Polygon->new( + map [ map $_ / &Slic3r::SCALING_FACTOR, @{$self->vertices->[$_]}[X,Y] ], @$facet + ); } - my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f); $_->make_counter_clockwise for @f; # do this after scaling, as winding order might change while doing that - my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 10000) ]); - Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union; - return $union; + return union_ex(\@f, 1); } 1;