Fix one regression in arrange

This commit is contained in:
Alessandro Ranellucci 2015-12-14 00:15:04 +01:00
parent 7ecfe195f7
commit 21364b7cd1
2 changed files with 11 additions and 10 deletions

View file

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

View file

@ -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();
}
}