Organic supports: Added check for variable layer height, with which
Organic supports are not compatible. Fixes #9528 and similar. Moved the object max Z against build volume Z to Print::validate(). Updated layer_height_profile_from_ranges() to compress the resulting ranges.
This commit is contained in:
parent
79d5a38928
commit
5b94971fce
6 changed files with 135 additions and 58 deletions
|
@ -491,6 +491,47 @@ std::string Print::validate(std::string* warning) const
|
|||
return L("The Spiral Vase option can only be used when printing single material objects.");
|
||||
}
|
||||
|
||||
// Cache of layer height profiles for checking:
|
||||
// 1) Whether all layers are synchronized if printing with wipe tower and / or unsynchronized supports.
|
||||
// 2) Whether layer height is constant for Organic supports.
|
||||
// 3) Whether build volume Z is not violated.
|
||||
std::vector<std::vector<coordf_t>> layer_height_profiles;
|
||||
auto layer_height_profile = [this, &layer_height_profiles](const size_t print_object_idx) -> const std::vector<coordf_t>& {
|
||||
const PrintObject &print_object = *m_objects[print_object_idx];
|
||||
if (layer_height_profiles.empty())
|
||||
layer_height_profiles.assign(m_objects.size(), std::vector<coordf_t>());
|
||||
std::vector<coordf_t> &profile = layer_height_profiles[print_object_idx];
|
||||
if (profile.empty())
|
||||
PrintObject::update_layer_height_profile(*print_object.model_object(), print_object.slicing_parameters(), profile);
|
||||
return profile;
|
||||
};
|
||||
|
||||
// Checks that the print does not exceed the max print height
|
||||
for (size_t print_object_idx = 0; print_object_idx < m_objects.size(); ++ print_object_idx) {
|
||||
const PrintObject &print_object = *m_objects[print_object_idx];
|
||||
//FIXME It is quite expensive to generate object layers just to get the print height!
|
||||
if (auto layers = generate_object_layers(print_object.slicing_parameters(), layer_height_profile(print_object_idx));
|
||||
! layers.empty() && layers.back() > this->config().max_print_height) {
|
||||
return L("The print is taller than the maximum allowed height. You might want to reduce the size of your model"
|
||||
" or change current print settings and retry.");
|
||||
}
|
||||
}
|
||||
|
||||
// Some of the objects has variable layer height applied by painting or by a table.
|
||||
bool has_custom_layering = std::find_if(m_objects.begin(), m_objects.end(),
|
||||
[](const PrintObject *object) { return object->model_object()->has_custom_layering(); })
|
||||
!= m_objects.end();
|
||||
|
||||
// Custom layering is not allowed for tree supports as of now.
|
||||
for (size_t print_object_idx = 0; print_object_idx < m_objects.size(); ++ print_object_idx)
|
||||
if (const PrintObject &print_object = *m_objects[print_object_idx];
|
||||
print_object.has_support_material() && print_object.config().support_material_style.value == smsOrganic &&
|
||||
print_object.model_object()->has_custom_layering()) {
|
||||
if (const std::vector<coordf_t> &layers = layer_height_profile(print_object_idx); ! layers.empty())
|
||||
if (! check_object_layers_fixed(print_object.slicing_parameters(), layers))
|
||||
return L("Variable layer height is not supported with Organic supports.");
|
||||
}
|
||||
|
||||
if (this->has_wipe_tower() && ! m_objects.empty()) {
|
||||
// Make sure all extruders use same diameter filament and have the same nozzle diameter
|
||||
// EPSILON comparison is used for nozzles and 10 % tolerance is used for filaments
|
||||
|
@ -518,19 +559,8 @@ std::string Print::validate(std::string* warning) const
|
|||
return L("The Wipe Tower is currently not supported for multimaterial sequential prints.");
|
||||
|
||||
if (m_objects.size() > 1) {
|
||||
bool has_custom_layering = false;
|
||||
std::vector<std::vector<coordf_t>> layer_height_profiles;
|
||||
for (const PrintObject *object : m_objects) {
|
||||
has_custom_layering = ! object->model_object()->layer_config_ranges.empty() || ! object->model_object()->layer_height_profile.empty();
|
||||
if (has_custom_layering) {
|
||||
layer_height_profiles.assign(m_objects.size(), std::vector<coordf_t>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
const SlicingParameters &slicing_params0 = m_objects.front()->slicing_parameters();
|
||||
size_t tallest_object_idx = 0;
|
||||
if (has_custom_layering)
|
||||
PrintObject::update_layer_height_profile(*m_objects.front()->model_object(), slicing_params0, layer_height_profiles.front());
|
||||
const SlicingParameters &slicing_params0 = m_objects.front()->slicing_parameters();
|
||||
size_t tallest_object_idx = 0;
|
||||
for (size_t i = 1; i < m_objects.size(); ++ i) {
|
||||
const PrintObject *object = m_objects[i];
|
||||
const SlicingParameters &slicing_params = object->slicing_parameters();
|
||||
|
@ -545,8 +575,9 @@ std::string Print::validate(std::string* warning) const
|
|||
if (! equal_layering(slicing_params, slicing_params0))
|
||||
return L("The Wipe Tower is only supported for multiple objects if they are sliced equally.");
|
||||
if (has_custom_layering) {
|
||||
PrintObject::update_layer_height_profile(*object->model_object(), slicing_params, layer_height_profiles[i]);
|
||||
if (*(layer_height_profiles[i].end()-2) > *(layer_height_profiles[tallest_object_idx].end()-2))
|
||||
auto &lh = layer_height_profile(i);
|
||||
auto &lh_tallest = layer_height_profile(tallest_object_idx);
|
||||
if (*(lh.end()-2) > *(lh_tallest.end()-2))
|
||||
tallest_object_idx = i;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue