FIX: support wall count doesn't work

jira: STUDIO-7975
Change-Id: Ic580d298568fc6eab8b1a2c017fa182869b432bf
(cherry picked from commit 82bcb099e139065cc00c133f507e955d9955b2f4)
(cherry picked from commit 04756bf447f690a071eace1500b150f0b7b4ce02)
This commit is contained in:
Arthur 2024-08-30 15:13:29 +08:00 committed by Noisyfox
parent ae6fadda4d
commit f76683e90e
6 changed files with 95 additions and 84 deletions

View file

@ -4955,10 +4955,11 @@ void PrintConfigDef::init_fff_params()
def = this->add("tree_support_wall_count", coInt);
def->label = L("Support wall loops");
def->category = L("Support");
def->tooltip = L("This setting specify the count of walls around support");
def->tooltip = L("This setting specifies the min count of support walls in the range of [0,2]. Actual wall count may be larger than the specified value.");
def->min = 0;
def->max = 2;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionInt(0));
def->set_default_value(new ConfigOptionInt(1));
def = this->add("tree_support_with_infill", coBool);
def->label = L("Tree support with infill");

View file

@ -144,6 +144,7 @@ std::pair<SupportGeneratorLayersPtr, SupportGeneratorLayersPtr> generate_interfa
const bool smooth_supports = support_params.support_style != smsGrid;
SupportGeneratorLayersPtr &interface_layers = base_and_interface_layers.first;
SupportGeneratorLayersPtr &base_interface_layers = base_and_interface_layers.second;
interface_layers.assign(intermediate_layers.size(), nullptr);
if (support_params.has_base_interfaces())
base_interface_layers.assign(intermediate_layers.size(), nullptr);

View file

@ -50,6 +50,8 @@ SupportGeneratorLayersPtr generate_raft_base(
const SupportGeneratorLayersPtr &base_layers,
SupportGeneratorLayerStorage &layer_storage);
void tree_supports_generate_paths(ExtrusionEntitiesPtr &dst, const Polygons &polygons, const Flow &flow, const SupportParameters &support_params);
void fill_expolygons_with_sheath_generate_paths(
ExtrusionEntitiesPtr &dst, const Polygons &polygons, Fill *filler, float density, ExtrusionRole role, const Flow &flow, const SupportParameters& support_params, bool with_sheath, bool no_sort);

View file

@ -6,7 +6,7 @@
namespace Slic3r {
struct SupportParameters {
SupportParameters() = default;
SupportParameters() = delete;
SupportParameters(const PrintObject& object)
{
const PrintConfig& print_config = object.print()->config();
@ -23,23 +23,20 @@ struct SupportParameters {
(object_config.support_filament.value == 0 || ! print_config.filament_soluble.get_at(object_config.support_filament.value - 1));
{
int num_top_interface_layers = std::max(0, object_config.support_interface_top_layers.value);
int num_bottom_interface_layers = object_config.support_interface_bottom_layers < 0 ?
this->num_top_interface_layers = std::max(0, object_config.support_interface_top_layers.value);
this->num_bottom_interface_layers = object_config.support_interface_bottom_layers < 0 ?
num_top_interface_layers : object_config.support_interface_bottom_layers;
this->has_top_contacts = num_top_interface_layers > 0;
this->has_bottom_contacts = num_bottom_interface_layers > 0;
this->num_top_interface_layers = this->has_top_contacts ? size_t(num_top_interface_layers - 1) : 0;
this->num_bottom_interface_layers = this->has_bottom_contacts ? size_t(num_bottom_interface_layers - 1) : 0;
if (this->soluble_interface_non_soluble_base) {
// Try to support soluble dense interfaces with non-soluble dense interfaces.
this->num_top_base_interface_layers = size_t(std::min(num_top_interface_layers / 2, 2));
this->num_bottom_base_interface_layers = size_t(std::min(num_bottom_interface_layers / 2, 2));
this->num_top_base_interface_layers = size_t(std::min(int(num_top_interface_layers) / 2, 2));
this->num_bottom_base_interface_layers = size_t(std::min(int(num_bottom_interface_layers) / 2, 2));
} else {
this->num_top_base_interface_layers = 0;
this->num_bottom_base_interface_layers = 0;
}
}
this->first_layer_flow = Slic3r::support_material_1st_layer_flow(&object, float(slicing_params.first_print_layer_height));
this->support_material_flow = Slic3r::support_material_flow(&object, float(slicing_params.layer_height));
this->support_material_interface_flow = Slic3r::support_material_interface_flow(&object, float(slicing_params.layer_height));
@ -155,7 +152,8 @@ struct SupportParameters {
independent_layer_height = print_config.independent_support_layer_height;
tree_branch_diameter_double_wall_area_scaled = 0.25 * sqr(scaled<double>(object_config.tree_support_branch_diameter_double_wall.value)) * M_PI;
// force double walls everywhere if wall count is larger than 1
tree_branch_diameter_double_wall_area_scaled = object_config.tree_support_wall_count.value > 1 ? 0.1 : 0.25 * sqr(scaled<double>(5.0)) * M_PI;
support_style = object_config.support_style;
if (support_style == smsDefault) {
@ -236,7 +234,7 @@ struct SupportParameters {
// Shall the sparse (base) layers be printed with a single perimeter line (sheath) for robustness?
bool with_sheath;
// Branches of organic supports with area larger than this threshold will be extruded with double lines.
double tree_branch_diameter_double_wall_area_scaled = 0.25 * sqr(scaled<double>(3.0)) * M_PI;;
double tree_branch_diameter_double_wall_area_scaled = 0.25 * sqr(scaled<double>(5.0)) * M_PI;;
float raft_angle_1st_layer;
float raft_angle_base;

View file

@ -1541,12 +1541,16 @@ void TreeSupport::generate_toolpaths()
}
else {
size_t walls = wall_count;
if (area_group.need_extra_wall && walls < 2) walls += 1;
for (size_t i = 1; i < walls; i++) {
Polygons contour_new = offset(poly.contour, -(i - 0.5f) * flow.scaled_spacing(), jtSquare);
loops.insert(loops.end(), contour_new.begin(), contour_new.end());
}
fill_expolygons_with_sheath_generate_paths(ts_layer->support_fills.entities, loops, nullptr, 0, erSupportMaterial, flow, m_support_params, true, false);
//if (area_group.need_extra_wall && walls < 2) walls += 1;
//for (size_t i = 1; i < walls; i++) {
// Polygons contour_new = offset(poly.contour, -(i - 0.5f) * flow.scaled_spacing(), jtSquare);
// loops.insert(loops.end(), contour_new.begin(), contour_new.end());
//}
//fill_expolygons_with_sheath_generate_paths(ts_layer->support_fills.entities, loops, nullptr, 0, erSupportMaterial, flow, true, false);
SupportParameters support_params = m_support_params;
if(walls>1)
support_params.tree_branch_diameter_double_wall_area_scaled=0.1;
tree_supports_generate_paths(ts_layer->support_fills.entities, loops, flow, support_params);
}
}
}
@ -1606,10 +1610,14 @@ void TreeSupport::generate_toolpaths()
}
// sort extrusions to reduce travel, also make sure walls go before infills
if(ts_layer->support_fills.no_sort==false)
if (ts_layer->support_fills.no_sort == false) {
// chain_and_reorder_extrusion_entities crashes if there are empty elements in entities
auto &entities = ts_layer->support_fills.entities;
entities.erase(std::remove_if(entities.begin(), entities.end(), [](ExtrusionEntity* entity) { return static_cast<ExtrusionEntityCollection*>(entity)->empty(); }), entities.end());
chain_and_reorder_extrusion_entities(ts_layer->support_fills.entities);
}
}
}
);
}

View file

@ -3434,6 +3434,7 @@ static void generate_support_areas(Print &print, TreeSupport* tree_support, cons
// The trees will have the density zeroed in tree_supports_generate_paths()
// support_params.support_density = 0;
SupportGeneratorLayerStorage layer_storage;
SupportGeneratorLayersPtr top_contacts;
SupportGeneratorLayersPtr bottom_contacts;