From 3d4e37ceb64ae1a147ad52c5a81722b22b49138b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 13 Nov 2018 08:36:10 +0100 Subject: [PATCH] Center volumes after split to parts --- src/libslic3r/Model.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 335e034c4..d0590f994 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1244,16 +1244,22 @@ size_t ModelVolume::split(unsigned int max_extruders) std::string name = this->name; Model::reset_auto_extruder_id(); +#if ENABLE_MODELVOLUME_TRANSFORM + Vec3d offset = this->get_offset(); +#endif // ENABLE_MODELVOLUME_TRANSFORM for (TriangleMesh *mesh : meshptrs) { mesh->repair(); if (idx == 0) this->mesh = std::move(*mesh); else - this->object->volumes.insert(this->object->volumes.begin() + (++ ivolume), new ModelVolume(object, *this, std::move(*mesh))); - char str_idx[64]; - sprintf(str_idx, "_%d", idx + 1); - this->object->volumes[ivolume]->name = name + str_idx; + this->object->volumes.insert(this->object->volumes.begin() + (++ivolume), new ModelVolume(object, *this, std::move(*mesh))); + +#if ENABLE_MODELVOLUME_TRANSFORM + this->object->volumes[ivolume]->center_geometry(); + this->object->volumes[ivolume]->translate(offset); +#endif // ENABLE_MODELVOLUME_TRANSFORM + this->object->volumes[ivolume]->name = name + "_" + std::to_string(idx + 1); this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string(max_extruders)); delete mesh; ++ idx;