mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
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:
parent
e93e517561
commit
7ef43f6849
9 changed files with 177 additions and 27 deletions
|
@ -1,3 +1,25 @@
|
|||
///|/ Copyright (c) Prusa Research 2016 - 2023 Lukáš Matěna @lukasmatena, Tomáš Mészáros @tamasmeszaros, Enrico Turri @enricoturri1966, Vojtěch Bubník @bubnikv, Pavel Mikuš @Godrak, Oleksandra Iushchenko @YuSanka, Lukáš Hejl @hejllukas, Filip Sykala @Jony01, Roman Beránek @zavorka, David Kocík @kocikdav
|
||||
///|/ Copyright (c) BambuStudio 2023 manch1n @manch1n
|
||||
///|/ Copyright (c) SuperSlicer 2023 Remi Durand @supermerill
|
||||
///|/ Copyright (c) 2021 Martin Budden
|
||||
///|/ Copyright (c) 2020 Paul Arden @ardenpm
|
||||
///|/ Copyright (c) 2019 Thomas Moore
|
||||
///|/ Copyright (c) 2019 Bryan Smith
|
||||
///|/ Copyright (c) Slic3r 2013 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/ Copyright (c) 2014 Petr Ledvina @ledvinap
|
||||
///|/
|
||||
///|/ ported from lib/Slic3r/Print.pm:
|
||||
///|/ Copyright (c) Prusa Research 2016 - 2018 Vojtěch Bubník @bubnikv, Tomáš Mészáros @tamasmeszaros
|
||||
///|/ Copyright (c) Slic3r 2011 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/ Copyright (c) 2012 - 2013 Mark Hindess
|
||||
///|/ Copyright (c) 2013 Devin Grady
|
||||
///|/ Copyright (c) 2012 - 2013 Mike Sheldrake @mesheldrake
|
||||
///|/ Copyright (c) 2012 Henrik Brix Andersen @henrikbrixandersen
|
||||
///|/ Copyright (c) 2012 Michael Moon
|
||||
///|/ Copyright (c) 2011 Richard Goodwin
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "Exception.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "BoundingBox.hpp"
|
||||
|
@ -1034,6 +1056,53 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
return {L("The spiral vase mode does not work when an object contains more than one materials."), nullptr, "spiral_mode"};
|
||||
}
|
||||
|
||||
// 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().printable_height + EPSILON) {
|
||||
return
|
||||
// Test whether the last slicing plane is below or above the print volume.
|
||||
{ 0.5 * (layers[layers.size() - 2] + layers.back()) > this->config().printable_height + EPSILON ?
|
||||
format(_u8L("The object %1% exceeds the maximum build volume height."), print_object.model_object()->name) :
|
||||
format(_u8L("While the object %1% itself fits the build volume, its last layer exceeds the maximum build volume height."), print_object.model_object()->name) +
|
||||
" " + _u8L("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() && is_tree(print_object.config().support_type.value) && (print_object.config().support_style.value == smsOrganic ||
|
||||
// Orca: use organic as default
|
||||
print_object.config().support_style.value == smsDefault) &&
|
||||
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 {_u8L("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
|
||||
|
@ -1081,19 +1150,8 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
#endif
|
||||
|
||||
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());
|
||||
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();
|
||||
|
@ -1111,8 +1169,9 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
if (!equal_layering(slicing_params, slicing_params0))
|
||||
return { L("The prime tower requires that all objects are sliced with the same layer heights."), object };
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1198,7 +1257,9 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
|
||||
// Prusa: Fixing crashes with invalid tip diameter or branch diameter
|
||||
// https://github.com/prusa3d/PrusaSlicer/commit/96b3ae85013ac363cd1c3e98ec6b7938aeacf46d
|
||||
if (object->config().support_style == smsOrganic) {
|
||||
if (is_tree(object->config().support_type.value) && (object->config().support_style == smsOrganic ||
|
||||
// Orca: use organic as default
|
||||
object->config().support_style == smsDefault)) {
|
||||
float extrusion_width = std::min(
|
||||
support_material_flow(object).width(),
|
||||
support_material_interface_flow(object).width());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue