Skip to content

Commit

Permalink
Fix remove empty layers when layers do not equal layer height.
Browse files Browse the repository at this point in the history
This shouldn't happen, but neither should the hot-end ram into the build-plate (in fact, you want that even less).

part of CURA-11537
  • Loading branch information
rburema committed Feb 29, 2024
1 parent a3a8da5 commit 24d0c31
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/FffPolygonGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,12 +769,25 @@ bool FffPolygonGenerator::isEmptyLayer(SliceDataStorage& storage, const LayerInd

void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, size_t& total_layers)
{
const auto get_highest_z = [&storage](const LayerIndex& layer_idx)
{
coord_t highest_z = 0;
for (std::shared_ptr<SliceMeshStorage>& mesh_ptr : storage.meshes)
{
auto& mesh = *mesh_ptr;
highest_z = layer_idx >= mesh.layers.size() ? highest_z : std::max(highest_z, mesh.layers[layer_idx].printZ);
}
return highest_z;
};

size_t n_empty_first_layers = 0;
coord_t hightest_empty_layer = 0;
for (size_t layer_idx = 0; layer_idx < total_layers; layer_idx++)
{
if (isEmptyLayer(storage, layer_idx))
{
n_empty_first_layers++;
hightest_empty_layer = get_highest_z(layer_idx);
}
else
{
Expand All @@ -798,7 +811,7 @@ void FffPolygonGenerator::removeEmptyFirstLayers(SliceDataStorage& storage, size
layers.erase(layers.begin(), layers.begin() + n_empty_first_layers);
for (SliceLayer& layer : layers)
{
layer.printZ -= n_empty_first_layers * layer_height;
layer.printZ -= hightest_empty_layer;
}
mesh.layer_nr_max_filled_layer -= n_empty_first_layers;
}
Expand Down

0 comments on commit 24d0c31

Please sign in to comment.