diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 9a6635f40..7f56b5f99 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2159,9 +2159,11 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou m_wipe.path = paths.front().polyline; // TODO: don't limit wipe to last path // make a little move inwards before leaving loop - if (paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.perimeters.value > 1) { + if (paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.perimeters.value > 1 && paths.front().size() >= 2 && paths.back().polyline.points.size() >= 3) { // detect angle between last and first segment // the side depends on the original winding order of the polygon (left for contours, right for holes) + //FIXME improve the algorithm in case the loop is tiny. + //FIXME improve the algorithm in case the loop is split into segments with a low number of points (see the Point b query). Point a = paths.front().polyline.points[1]; // second point Point b = *(paths.back().polyline.points.end()-3); // second to last point if (was_clockwise) { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 0a56217d3..fb6d90d60 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -400,7 +400,7 @@ void Print::add_model_object(ModelObject* model_object, int idx) m_model.objects.emplace_back(ModelObject::new_copy(*model_object)); m_model.objects.back()->set_model(&m_model); // Initialize a new print object and store it at the given position. - PrintObject *object = new PrintObject(this, model_object); + PrintObject *object = new PrintObject(this, model_object, true); if (idx != -1) { delete m_objects[idx]; m_objects[idx] = object; @@ -964,7 +964,7 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co if (old.empty()) { // Simple case, just generate new instances. for (const PrintInstances &print_instances : new_print_instances) { - PrintObject *print_object = new PrintObject(this, model_object); + PrintObject *print_object = new PrintObject(this, model_object, false); print_object->set_trafo(print_instances.trafo); print_object->set_copies(print_instances.copies); print_object->config_apply(config); @@ -983,7 +983,7 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co for (; it_old != old.end() && transform3d_lower((*it_old)->trafo, new_instances.trafo); ++ it_old); if (it_old == old.end() || ! transform3d_equal((*it_old)->trafo, new_instances.trafo)) { // This is a new instance (or a set of instances with the same trafo). Just add it. - PrintObject *print_object = new PrintObject(this, model_object); + PrintObject *print_object = new PrintObject(this, model_object, false); print_object->set_trafo(new_instances.trafo); print_object->set_copies(new_instances.copies); print_object->config_apply(config); diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 4175d4f22..872ce31db 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -159,7 +159,7 @@ protected: // to be called from Print only. friend class Print; - PrintObject(Print* print, ModelObject* model_object); + PrintObject(Print* print, ModelObject* model_object, bool add_instances = true); ~PrintObject() {} void config_apply(const ConfigBase &other, bool ignore_nonexistent = false) { this->m_config.apply(other, ignore_nonexistent); } diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 371e62ff9..10f5a1ac2 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -34,7 +34,7 @@ namespace Slic3r { -PrintObject::PrintObject(Print* print, ModelObject* model_object) : +PrintObject::PrintObject(Print* print, ModelObject* model_object, bool add_instances) : PrintObjectBaseWithState(print, model_object), typed_slices(false), size(Vec3crd::Zero()), @@ -54,7 +54,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object) : this->size = (modobj_bbox.size() * (1. / SCALING_FACTOR)).cast(); } - { + if (add_instances) { Points copies; copies.reserve(m_model_object->instances.size()); for (const ModelInstance *mi : m_model_object->instances) {