/* arrange objects preserving their instance count but altering their instance positions */ bool Model::arrange_objects(coordf_t dist, const BoundingBoxf* bb) { // get the (transformed) size of each instance so that we take // into account their different transformations when packing Pointfs instance_sizes; for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) { for (size_t i = 0; i < (*o)->instances.size(); ++i) { instance_sizes.push_back((*o)->instance_bounding_box(i).size()); } } Pointfs positions; if (! this->_arrange(instance_sizes, dist, bb, positions)) return false; 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 = positions.back(); positions.pop_back(); } (*o)->invalidate_bounding_box(); } return true; }