From 21364b7cd10fa503bde4b53c53f97c2e76b75203 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 14 Dec 2015 00:15:04 +0100 Subject: [PATCH] Fix one regression in arrange --- xs/src/libslic3r/Geometry.cpp | 9 +++++---- xs/src/libslic3r/Model.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xs/src/libslic3r/Geometry.cpp b/xs/src/libslic3r/Geometry.cpp index a43aa814a..dcac40ad4 100644 --- a/xs/src/libslic3r/Geometry.cpp +++ b/xs/src/libslic3r/Geometry.cpp @@ -186,7 +186,7 @@ arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb) // this is how many cells we have available into which to put parts size_t cellw = floor((area.x + dist) / part.x); - size_t cellh = floor((area.x + dist) / part.x); + size_t cellh = floor((area.y + dist) / part.y); if (total_parts > (cellw * cellh)) CONFESS("%zu parts won't fit in your print area!\n", total_parts); @@ -200,8 +200,8 @@ arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb) // center bounding box to area cells_bb.translate( - -(area.x - cells.x) / 2, - -(area.y - cells.y) / 2 + (area.x - cells.x) / 2, + (area.y - cells.y) / 2 ); // list of cells, sorted by distance from center @@ -211,7 +211,7 @@ arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb) for (size_t i = 0; i <= cellw-1; ++i) { for (size_t j = 0; j <= cellh-1; ++j) { coordf_t cx = linint(i + 0.5, 0, cellw, cells_bb.min.x, cells_bb.max.x); - coordf_t cy = linint(j + 0.5, 0, cellh, cells_bb.max.y, cells_bb.min.y); + coordf_t cy = linint(j + 0.5, 0, cellh, cells_bb.min.y, cells_bb.max.y); coordf_t xd = fabs((area.x / 2) - cx); coordf_t yd = fabs((area.y / 2) - cy); @@ -285,6 +285,7 @@ arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb) p->y += bb->min.y; } } + return positions; } diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 36001b9b2..6a678f4b6 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -165,14 +165,13 @@ Model::center_instances_around_point(const Pointf &point) BoundingBoxf3 bb = this->bounding_box(); Sizef3 size = bb.size(); - double shift_x = -bb.min.x + point.x - size.x/2; - double shift_y = -bb.min.y + point.y - size.y/2; - + coordf_t shift_x = -bb.min.x + point.x - size.x/2; + coordf_t shift_y = -bb.min.y + point.y - size.y/2; for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) { for (ModelInstancePtrs::const_iterator i = (*o)->instances.begin(); i != (*o)->instances.end(); ++i) { (*i)->offset.translate(shift_x, shift_y); } - (*o)->update_bounding_box(); + (*o)->invalidate_bounding_box(); } } @@ -249,6 +248,7 @@ Model::arrange_objects(coordf_t dist, const BoundingBoxf* bb) (*i)->offset = positions.back(); positions.pop_back(); } + (*o)->invalidate_bounding_box(); } } @@ -270,7 +270,7 @@ Model::duplicate(size_t copies_num, coordf_t dist, const BoundingBoxf* bb) instance->offset.translate(*pos); } } - (*o)->update_bounding_box(); + (*o)->invalidate_bounding_box(); } } @@ -549,7 +549,7 @@ ModelObject::center_around_origin() v.scale((*i)->scaling_factor); (*i)->offset.translate(v.x, v.y); } - this->update_bounding_box(); + this->invalidate_bounding_box(); } }