Various support improvements and bugfixes (#2202)

* Organic supports: Added check for variable layer height, with which
Organic supports are not compatible.
Fixes prusa3d/PrusaSlicer#9528 and similar.
Check the object max Z against build volume Z in Print::validate().

Cherry-picked from prusa3d/PrusaSlicer@5b94971

* Fix crash with default tree support

* Show "support_critical_regions_only" only when using auto normal tree supports (#2195)

* Fix organic tree check

---------

Co-authored-by: Vojtech Bubnik <bubnikv@gmail.com>
This commit is contained in:
Noisyfox 2023-09-24 22:58:04 +08:00 committed by GitHub
parent e93e517561
commit 7ef43f6849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 177 additions and 27 deletions

View file

@ -1,3 +1,7 @@
///|/ Copyright (c) Prusa Research 2016 - 2023 Vojtěch Bubník @bubnikv, Enrico Turri @enricoturri1966, David Kocík @kocikdav, Lukáš Matěna @lukasmatena, Oleksandra Iushchenko @YuSanka
///|/
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#include <limits>
#include "libslic3r.h"
@ -321,7 +325,7 @@ std::vector<double> layer_height_profile_adaptive(const SlicingParameters& slici
print_z += height;
}
double z_gap = slicing_params.object_print_z_height() - layer_height_profile[layer_height_profile.size() - 2];
double z_gap = slicing_params.object_print_z_height() - *(layer_height_profile.end() - 2);
if (z_gap > 0.0)
{
layer_height_profile.push_back(slicing_params.object_print_z_height());
@ -685,6 +689,40 @@ std::vector<coordf_t> generate_object_layers(
return out;
}
// Check whether the layer height profile describes a fixed layer height profile.
bool check_object_layers_fixed(
const SlicingParameters &slicing_params,
const std::vector<coordf_t> &layer_height_profile)
{
assert(layer_height_profile.size() >= 4);
assert(layer_height_profile.size() % 2 == 0);
assert(layer_height_profile[0] == 0);
if (layer_height_profile.size() != 4 && layer_height_profile.size() != 8)
return false;
bool fixed_step1 = is_approx(layer_height_profile[1], layer_height_profile[3]);
bool fixed_step2 = layer_height_profile.size() == 4 ||
(layer_height_profile[2] == layer_height_profile[4] && is_approx(layer_height_profile[5], layer_height_profile[7]));
if (! fixed_step1 || ! fixed_step2)
return false;
if (layer_height_profile[2] < 0.5 * slicing_params.first_object_layer_height + EPSILON ||
! is_approx(layer_height_profile[3], slicing_params.first_object_layer_height))
return false;
double z_max = layer_height_profile[layer_height_profile.size() - 2];
double z_2nd = slicing_params.first_object_layer_height + 0.5 * slicing_params.layer_height;
if (z_2nd > z_max)
return true;
if (z_2nd < *(layer_height_profile.end() - 4) + EPSILON ||
! is_approx(layer_height_profile.back(), slicing_params.layer_height))
return false;
return true;
}
int generate_layer_height_texture(
const SlicingParameters &slicing_params,
const std::vector<coordf_t> &layers,