Empty layers detection added to GCode.cpp

Added detection of empty layers so the wipe tower doesn't trip on them (it is not printable anyway).
This should improve wipe tower reliability with supports, objects standing on edges, etc.
I also turned an assert into exception throw to prevent hard crashes and nonsense output.
This commit is contained in:
Lukas Matena 2019-08-02 16:49:22 +02:00
parent 3b24565411
commit 6ab1cec48c
2 changed files with 25 additions and 3 deletions

View file

@ -78,8 +78,13 @@ ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool
zs.emplace_back(layer->print_z);
for (auto layer : object->support_layers())
zs.emplace_back(layer->print_z);
if (! object->layers().empty())
object_bottom_z = object->layers().front()->print_z - object->layers().front()->height;
// Find first object layer that is not empty and save its print_z
for (const Layer* layer : object->layers())
if (layer->has_extrusions()) {
object_bottom_z = layer->print_z - layer->height;
break;
}
}
this->initialize_layers(zs);
}
@ -324,6 +329,7 @@ void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_
m_layer_tools[j].has_wipe_tower = true;
} else {
LayerTools &lt_extra = *m_layer_tools.insert(m_layer_tools.begin() + j, lt_new);
//LayerTools &lt_prev = m_layer_tools[j];
LayerTools &lt_next = m_layer_tools[j + 1];
assert(! m_layer_tools[j - 1].extruders.empty() && ! lt_next.extruders.empty());
// FIXME: Following assert tripped when running combine_infill.t. I decided to comment it out for now.