Fix of G-code invalidation on "wipe_into_object" "wipe_into_infill"

changes.

WIP: Fix of "levitating objects cannot be sliced".
This commit is contained in:
bubnikv 2018-12-14 17:17:51 +01:00
parent 2be23c8b14
commit 506cbcb4a7
3 changed files with 27 additions and 10 deletions

View file

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

View file

@ -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 <class T> bool any_internal_region_slice_contains(const T &item) const {

View file

@ -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::vector<t_config_
|| opt_key == "perimeter_speed"
|| opt_key == "small_perimeter_speed"
|| opt_key == "solid_infill_speed"
|| opt_key == "top_solid_infill_speed"
|| opt_key == "wipe_into_infill" // when these these two are changed, we only need to invalidate the wipe tower,
|| opt_key == "wipe_into_objects" // which we already did at the very beginning - nothing more to be done
) {
// these options only affect G-code export, so nothing to invalidate
|| opt_key == "top_solid_infill_speed") {
invalidated |= m_print->invalidate_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())