Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-06-15 17:50:02 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-06-15 17:50:02 +0400
commit7bf308c08fec43d45649f0a20787372ba046e9a6 (patch)
tree59d61439475b60db4de462e93c704707e735bc79
parenta8981b8b359eedc2294404f72aa9b70182d62d97 (diff)
Fix one more centering problem caused by wrong bounding box implementation0.9.10
-rw-r--r--lib/Slic3r/GUI/Plater.pm11
-rw-r--r--lib/Slic3r/Geometry/BoundingBox.pm15
-rw-r--r--lib/Slic3r/Polyline.pm7
3 files changed, 14 insertions, 19 deletions
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index 999a18680..b34efa82e 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -1067,7 +1067,7 @@ sub OnDropFiles {
package Slic3r::GUI::Plater::Object;
use Moo;
-use Math::ConvexHull::MonotoneChain qw(convex_hull);
+use Math::ConvexHull::MonotoneChain qw();
use Slic3r::Geometry qw(X Y Z MIN MAX deg2rad);
has 'name' => (is => 'rw', required => 1);
@@ -1075,6 +1075,7 @@ has 'input_file' => (is => 'rw', required => 1);
has 'input_file_object_id' => (is => 'rw'); # undef means keep model object
has 'model_object' => (is => 'rw', required => 1, trigger => 1);
has 'bounding_box' => (is => 'rw'); # 3D bb of original object (aligned to origin) with no rotation or scaling
+has 'convex_hull' => (is => 'rw'); # 2D convex hull of original object (aligned to origin) with no rotation or scaling
has 'scale' => (is => 'rw', default => sub { 1 }, trigger => \&_transform_thumbnail);
has 'rotate' => (is => 'rw', default => sub { 0 }, trigger => \&_transform_thumbnail); # around object center point
has 'instances' => (is => 'rw', default => sub { [] }); # upward Y axis
@@ -1138,10 +1139,11 @@ sub make_thumbnail {
my $self = shift;
my $mesh = $self->model_object->mesh; # $self->model_object is already aligned to origin
+ $self->convex_hull(Slic3r::Polygon->new(Math::ConvexHull::MonotoneChain::convex_hull($mesh->vertices)));
my $thumbnail = Slic3r::ExPolygon::Collection->new(
expolygons => (@{$mesh->facets} <= 5000)
? $mesh->horizontal_projection
- : [ Slic3r::ExPolygon->new(convex_hull($mesh->vertices)) ],
+ : [ Slic3r::ExPolygon->new($self->convex_hull) ],
);
# only simplify expolygons larger than the threshold
@@ -1168,7 +1170,10 @@ sub _transform_thumbnail {
# bounding box with applied rotation and scaling
sub transformed_bounding_box {
my $self = shift;
- return $self->_apply_transform($self->bounding_box);
+
+ my $bb = Slic3r::Geometry::BoundingBox->new_from_points($self->_apply_transform($self->convex_hull));
+ $bb->extents->[Z] = $self->bounding_box->clone->extents->[Z];
+ return $bb;
}
sub _apply_transform {
diff --git a/lib/Slic3r/Geometry/BoundingBox.pm b/lib/Slic3r/Geometry/BoundingBox.pm
index 3cd019f0c..c2d27a1fe 100644
--- a/lib/Slic3r/Geometry/BoundingBox.pm
+++ b/lib/Slic3r/Geometry/BoundingBox.pm
@@ -39,20 +39,9 @@ sub polygon {
return Slic3r::Polygon->new_from_bounding_box($self->bb);
}
+# note to $self
sub rotate {
- my $self = shift;
- my ($angle, $center) = @_;
-
- # rotate the 2D bounding box polygon and leave Z unaltered
- my $bb_p = $self->polygon;
- $bb_p->rotate($angle, $center);
- my @bb = $bb_p->bounding_box;
- $self->extents->[X][MIN] = $bb[X1];
- $self->extents->[Y][MIN] = $bb[Y1];
- $self->extents->[X][MAX] = $bb[X2];
- $self->extents->[Y][MAX] = $bb[Y2];
-
- $self;
+ die "Rotating an axis-aligned bounding box doesn't make any sense";
}
sub scale {
diff --git a/lib/Slic3r/Polyline.pm b/lib/Slic3r/Polyline.pm
index 6646d1aae..2de79893a 100644
--- a/lib/Slic3r/Polyline.pm
+++ b/lib/Slic3r/Polyline.pm
@@ -156,11 +156,12 @@ sub translate {
sub scale {
my $self = shift;
my ($factor) = @_;
- return if $factor == 1;
# transform point coordinates
- foreach my $point (@$self) {
- $point->[$_] *= $factor for X,Y;
+ if ($factor != 1) {
+ foreach my $point (@$self) {
+ $point->[$_] *= $factor for X,Y;
+ }
}
return $self;
}