From c8a9ffc96b6fa0fd5ecd7a77d336a476b6a4b4c6 Mon Sep 17 00:00:00 2001 From: Michael Kirsch Date: Mon, 8 Jul 2019 22:09:52 +0200 Subject: [PATCH] cleanup commented / deleted code Part 1 --- lib/Slic3r/GUI/Plater.pm | 6 ++---- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 19 +++++++++---------- lib/Slic3r/Model.pm | 8 -------- src/GUI/Plater/PlaterObject.cpp | 3 +++ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 52d3de697e..aa0df0862f 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -3398,10 +3398,8 @@ sub make_thumbnail { my $mesh = $model->objects->[$obj_idx]->raw_mesh; # Apply x, y rotations and scaling vector in case of reading a 3MF model object. - #my $model_instance = $model->objects->[$obj_idx]->instances->[0]; - #$mesh->rotate_x($model_instance->x_rotation); - #$mesh->rotate_y($model_instance->y_rotation); - #$mesh->scale_xyz($model_instance->scaling_vector); + my $model_instance = $model->objects->[$obj_idx]->instances->[0]; + $mesh->transform($model_instance->additional_trafo); if ($mesh->facets_count <= 5000) { # remove polygons with area <= 1mm diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index ed4f2135b3..48288f14a6 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -405,27 +405,26 @@ sub on_btn_lambda { $params->{"slab_h"}, ); # box sets the base coordinate at 0,0, move to center of plate - #$mesh->translate( - # -$size->x*1.5/2.0, - # -$size->y*1.5/2.0, #** - # 0, - #); + my $trafo = Slic3r::TransformationMatrix->new; + $trafo->set_translation_xyz(-$size->x*1.5/2.0,-$size->y*1.5/2.0,0); + $mesh->transform($trafo); } else { return; } my $center = $self->{model_object}->bounding_box->center; - if (!$Slic3r::GUI::Settings->{_}{autocenter}) { - #TODO what we really want to do here is just align the - # center of the modifier to the center of the part. - #$mesh->translate($center->x, $center->y, 0); - } $mesh->repair; my $new_volume = $self->{model_object}->add_volume(mesh => $mesh); $new_volume->set_modifier($is_modifier); $new_volume->set_name($name); + if (!$Slic3r::GUI::Settings->{_}{autocenter}) { + #TODO what we really want to do here is just align the + # center of the modifier to the center of the part. + $new_volume->translate($center->x, $center->y,0); + } + # set a default extruder value, since user can't add it manually $new_volume->config->set_ifndef('extruder', 0); diff --git a/lib/Slic3r/Model.pm b/lib/Slic3r/Model.pm index 8cd34a08d1..cba64323a4 100644 --- a/lib/Slic3r/Model.pm +++ b/lib/Slic3r/Model.pm @@ -128,18 +128,10 @@ sub add_instance { $new_instance->set_rotation($args{rotation}) if defined $args{rotation}; -# $new_instance->set_x_rotation($args{x_rotation}) -# if defined $args{x_rotation}; -# $new_instance->set_y_rotation($args{y_rotation}) -# if defined $args{y_rotation}; $new_instance->set_scaling_factor($args{scaling_factor}) if defined $args{scaling_factor}; -# $new_instance->set_scaling_vector($args{scaling_vector}) -# if defined $args{scaling_vector}; $new_instance->set_offset($args{offset}) if defined $args{offset}; -# $new_instance->set_z_translation($args{z_translation}) -# if defined $args{z_translation}; return $new_instance; } diff --git a/src/GUI/Plater/PlaterObject.cpp b/src/GUI/Plater/PlaterObject.cpp index e1ca68b6f1..8718c3b456 100644 --- a/src/GUI/Plater/PlaterObject.cpp +++ b/src/GUI/Plater/PlaterObject.cpp @@ -16,6 +16,9 @@ Slic3r::ExPolygonCollection& PlaterObject::make_thumbnail(std::shared_ptrobjects[obj_idx]->raw_mesh()}; auto model_instance {model->objects[obj_idx]->instances[0]}; + // Apply any x/y rotations and scaling vector if this came from a 3MF object. + mesh.transform(model_instance->additional_trafo); + if (mesh.facets_count() <= 5000) { auto area_threshold {scale_(1.0)}; ExPolygons tmp {};