ENH: tree support uses accurate lslices

For tree support, use lslices as tree support island when generating brim,
as this is faster and more accurate.
For normal support, still use "support_fills.polygons_covered_by_spacing()" as support island when generating brim;

Jira: studio 4332

Change-Id: Ibfadd3a166606f824e5780b57112fff221470aaf
(cherry picked from commit 64960b19818c7029eaaaf3d8a89804aeaa26f11d)
This commit is contained in:
Arthur 2023-09-14 17:20:58 +08:00 committed by Lane.Wei
parent bf23f6f023
commit 181b05c236
2 changed files with 23 additions and 12 deletions

View File

@ -939,12 +939,19 @@ static ExPolygons outer_inner_brim_area(const Print& print,
support_material_extruder = printExtruders.front() + 1; support_material_extruder = printExtruders.front() + 1;
} }
if (support_material_extruder == extruderNo && brimToWrite.at(object->id()).sup) { if (support_material_extruder == extruderNo && brimToWrite.at(object->id()).sup) {
if (!object->support_layers().empty()) {
if (!object->support_layers().empty() && object->support_layers().front()->support_type == stInnerNormal) {
for (const Polygon& support_contour : object->support_layers().front()->support_fills.polygons_covered_by_spacing()) { for (const Polygon& support_contour : object->support_layers().front()->support_fills.polygons_covered_by_spacing()) {
no_brim_area_support.emplace_back(support_contour); no_brim_area_support.emplace_back(support_contour);
} }
} }
if (!object->support_layers().empty() && object->support_layers().front()->support_type == stInnerTree) {
for (const ExPolygon& ex_poly : object->support_layers().front()->lslices) {
no_brim_area_support.emplace_back(ex_poly.contour);
}
}
brimToWrite.at(object->id()).sup = false; brimToWrite.at(object->id()).sup = false;
for (const PrintInstance& instance : object->instances()) { for (const PrintInstance& instance : object->instances()) {
if (!brim_area_support.empty()) if (!brim_area_support.empty())

View File

@ -2173,6 +2173,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
coordf_t max_layers_above_roof1 = 0; coordf_t max_layers_above_roof1 = 0;
bool has_polygon_node = false; bool has_polygon_node = false;
bool has_circle_node = false; bool has_circle_node = false;
bool need_extra_wall = false;
BOOST_LOG_TRIVIAL(debug) << "circles at layer " << layer_nr << " contact nodes size=" << contact_nodes[layer_nr].size(); BOOST_LOG_TRIVIAL(debug) << "circles at layer " << layer_nr << " contact nodes size=" << contact_nodes[layer_nr].size();
//Draw the support areas and add the roofs appropriately to the support roof instead of normal areas. //Draw the support areas and add the roofs appropriately to the support roof instead of normal areas.
@ -2238,6 +2239,8 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
append(area, overhang_expanded); append(area, overhang_expanded);
} }
has_circle_node = true; has_circle_node = true;
if(node.is_merged || (node.movement.x()> line_width_scaled /2 || node.movement.y()> line_width_scaled /2))
need_extra_wall = true;
} }
if (node.distance_to_top < 0) if (node.distance_to_top < 0)
@ -2258,19 +2261,8 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
max_layers_above_base = std::max(max_layers_above_base, node.dist_mm_to_top); max_layers_above_base = std::max(max_layers_above_base, node.dist_mm_to_top);
} }
if (layer_nr < brim_skirt_layers)
append(ts_layer->lslices, area);
} }
ts_layer->lslices = std::move(union_ex(ts_layer->lslices));
//Must update bounding box which is used in avoid crossing perimeter
ts_layer->lslices_bboxes.clear();
ts_layer->lslices_bboxes.reserve(ts_layer->lslices.size());
for (const ExPolygon &expoly : ts_layer->lslices)
ts_layer->lslices_bboxes.emplace_back(get_extents(expoly));
ts_layer->backup_untyped_slices();
m_object->print()->set_status(65, (boost::format( _L("Support: generate polygons at layer %d")) % layer_nr).str()); m_object->print()->set_status(65, (boost::format( _L("Support: generate polygons at layer %d")) % layer_nr).str());
// join roof segments // join roof segments
@ -2345,6 +2337,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
for (auto& area : ts_layer->base_areas) { for (auto& area : ts_layer->base_areas) {
area_groups.emplace_back(&area, SupportLayer::BaseType, max_layers_above_base); area_groups.emplace_back(&area, SupportLayer::BaseType, max_layers_above_base);
area_groups.back().need_infill = has_polygon_node; area_groups.back().need_infill = has_polygon_node;
// area_groups.back().need_extra_wall = need_extra_wall;
} }
for (auto &area : ts_layer->roof_areas) area_groups.emplace_back(&area, SupportLayer::RoofType, max_layers_above_roof); for (auto &area : ts_layer->roof_areas) area_groups.emplace_back(&area, SupportLayer::RoofType, max_layers_above_roof);
for (auto &area : ts_layer->floor_areas) area_groups.emplace_back(&area, SupportLayer::FloorType, 10000); for (auto &area : ts_layer->floor_areas) area_groups.emplace_back(&area, SupportLayer::FloorType, 10000);
@ -2358,8 +2351,19 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
return bbox_size[0] < scale_(2) && bbox_size[1] < scale_(2); return bbox_size[0] < scale_(2) && bbox_size[1] < scale_(2);
}), }),
expoly->holes.end()); expoly->holes.end());
if (layer_nr < brim_skirt_layers)
ts_layer->lslices.emplace_back(*expoly);
} }
ts_layer->lslices = std::move(union_ex(ts_layer->lslices));
//Must update bounding box which is used in avoid crossing perimeter
ts_layer->lslices_bboxes.clear();
ts_layer->lslices_bboxes.reserve(ts_layer->lslices.size());
for (const ExPolygon& expoly : ts_layer->lslices)
ts_layer->lslices_bboxes.emplace_back(get_extents(expoly));
ts_layer->backup_untyped_slices();
} }
}); });