diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index 7878bffabb..fa5d296924 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -17,6 +17,16 @@ Layer::~Layer() m_regions.clear(); } +// Test whether whether there are any slices assigned to this layer. +bool Layer::empty() const +{ + for (const LayerRegion *layerm : m_regions) + if (layerm != nullptr && ! layerm->slices.empty()) + // Non empty layer. + return false; + return true; +} + LayerRegion* Layer::add_region(PrintRegion* print_region) { m_regions.emplace_back(new LayerRegion(this, print_region)); diff --git a/src/libslic3r/Layer.hpp b/src/libslic3r/Layer.hpp index 8dbe850ccc..78897a2dbb 100644 --- a/src/libslic3r/Layer.hpp +++ b/src/libslic3r/Layer.hpp @@ -114,7 +114,8 @@ public: LayerRegion* get_region(int idx) { return m_regions[idx]; } LayerRegion* add_region(PrintRegion* print_region); const LayerRegionPtrs& regions() const { return m_regions; } - + // Test whether whether there are any slices assigned to this layer. + bool empty() const; void make_slices(); void merge_slices(); template bool any_internal_region_slice_contains(const T &item) const { diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 4b7a8906f0..772d930aa6 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -384,6 +384,12 @@ void PrintObject::generate_support_material() m_print->set_status(85, "Generating support material"); this->_generate_support_material(); m_print->throw_if_canceled(); + } else { + // Printing without supports. Empty layer means some objects or object parts are levitating, + // therefore they cannot be printed without supports. + for (const Layer *layer : m_layers) + if (layer->empty()) + throw std::runtime_error("Levitating objects cannot be printed without supports."); } this->set_done(posSupportMaterial); } @@ -522,11 +528,13 @@ bool PrintObject::invalidate_state_by_config_options(const std::vectorinvalidate_step(psGCodeExport); + } else if ( + opt_key == "wipe_into_infill" + || opt_key == "wipe_into_objects") { + invalidated |= m_print->invalidate_step(psWipeTower); + invalidated |= m_print->invalidate_step(psGCodeExport); } else { // for legacy, if we can't handle this option let's invalidate all steps this->invalidate_all_steps(); @@ -1463,10 +1471,8 @@ void PrintObject::_slice() BOOST_LOG_TRIVIAL(debug) << "Slicing objects - removing top empty layers"; while (! m_layers.empty()) { const Layer *layer = m_layers.back(); - for (size_t region_id = 0; region_id < this->region_volumes.size(); ++ region_id) - if (layer->m_regions[region_id] != nullptr && ! layer->m_regions[region_id]->slices.empty()) - // Non empty layer. - goto end; + if (! layer->empty()) + goto end; delete layer; m_layers.pop_back(); if (! m_layers.empty())