Skip to content

Commit

Permalink
FIX: tree support didn't work with enforcer
Browse files Browse the repository at this point in the history
Enforcers should also subtract the lower polygons to get overhang areas.

Jira: STUDIO-3692
Github: #2045
Change-Id: I70f4aaae13826efc624e9bc942d2d11e9b1df1a1
(cherry picked from commit fc3d9b24ac1eb14e259488c94fca3469f319b368)
  • Loading branch information
ArthurBambulab authored and lanewei120 committed Jul 31, 2023
1 parent 44fdfe8 commit 9d96731
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/libslic3r/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,16 +1127,24 @@ void TreeSupport::detect_overhangs(bool detect_first_sharp_tail_only)
for (auto &area : ts_layer->overhang_areas) {
ts_layer->overhang_types.emplace(&area, SupportLayer::Detected);
}
// enforcers
if (layer_nr < enforcers.size()) {
// enforcers now follow same logic as normal support. See STUDIO-3692
if (layer_nr < enforcers.size() && lower_layer) {
float no_interface_offset = std::accumulate(layer->regions().begin(), layer->regions().end(), FLT_MAX,
[](float acc, const LayerRegion* layerm) { return std::min(acc, float(layerm->flow(frExternalPerimeter).scaled_width())); });
Polygons lower_layer_polygons = (layer_nr == 0) ? Polygons() : to_polygons(lower_layer->lslices);
Polygons& enforcer = enforcers[layer_nr];
// coconut: enforcer can't do offset2_ex, otherwise faces with angle near 90 degrees can't have enforcers, which
// is not good. For example: tails of animals needs extra support except the lowest tip.
//enforcer = std::move(offset2_ex(enforcer, -0.1 * extrusion_width_scaled, 0.1 * extrusion_width_scaled));
enforcer = offset(enforcer, 0.1 * extrusion_width_scaled);
for (const Polygon& poly : enforcer) {
ts_layer->overhang_areas.emplace_back(poly);
ts_layer->overhang_types.emplace(&ts_layer->overhang_areas.back(), SupportLayer::Enforced);
if (!enforcer.empty()) {
Polygons enforcer_polygons = diff(intersection(layer->lslices, enforcer),
// Inflate just a tiny bit to avoid intersection of the overhang areas with the object.
expand(lower_layer_polygons, 0.05f * no_interface_offset, SUPPORT_SURFACES_OFFSET_PARAMETERS));
// coconut: enforcer can't do offset2_ex, otherwise faces with angle near 90 degrees can't have enforcers, which
// is not good. For example: tails of animals needs extra support except the lowest tip.
//enforcer = std::move(offset2_ex(enforcer, -0.1 * extrusion_width_scaled, 0.1 * extrusion_width_scaled));
enforcer_polygons = offset(enforcer_polygons, 0.1 * extrusion_width_scaled);
for (const Polygon& poly : enforcer_polygons) {
ts_layer->overhang_areas.emplace_back(poly);
ts_layer->overhang_types.emplace(&ts_layer->overhang_areas.back(), SupportLayer::Enforced);
}
}
}

Expand Down

0 comments on commit 9d96731

Please sign in to comment.