Integerize plater thumbnails

This commit is contained in:
Alessandro Ranellucci 2013-08-05 20:21:08 +02:00
parent d8e2cde962
commit 0ce7ebc4b8
2 changed files with 10 additions and 6 deletions

View file

@ -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;

View file

@ -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;