update fix of SPE-1685 - make the closing raidus half the size, it was unnecesarily large

This commit is contained in:
Pavel Mikus 2023-06-02 16:20:13 +02:00
parent c16ee761b3
commit b20dfac403

View File

@ -171,7 +171,7 @@ Surfaces expand_bridges_detect_orientations(
Surfaces &surfaces, Surfaces &surfaces,
ExPolygons &shells, ExPolygons &shells,
const Algorithm::RegionExpansionParameters &expansion_params, const Algorithm::RegionExpansionParameters &expansion_params,
const float closing_diameter) const float closing_radius)
{ {
using namespace Slic3r::Algorithm; using namespace Slic3r::Algorithm;
@ -314,7 +314,7 @@ Surfaces expand_bridges_detect_orientations(
//NOTE: The current regularization of the shells can create small unasigned regions in the object (E.G. benchy) //NOTE: The current regularization of the shells can create small unasigned regions in the object (E.G. benchy)
// without the following closing operation, those regions will stay unfilled and cause small holes in the expanded surface. // without the following closing operation, those regions will stay unfilled and cause small holes in the expanded surface.
// look for narrow_ensure_vertical_wall_thickness_region_radius filter. // look for narrow_ensure_vertical_wall_thickness_region_radius filter.
ExPolygons final = closing_ex(acc, closing_diameter); ExPolygons final = closing_ex(acc, closing_radius);
// without safety offset, artifacts are generated (GH #2494) // without safety offset, artifacts are generated (GH #2494)
// union_safety_offset_ex(acc) // union_safety_offset_ex(acc)
for (ExPolygon &ex : final) for (ExPolygon &ex : final)
@ -334,7 +334,7 @@ static Surfaces expand_merge_surfaces(
SurfaceType surface_type, SurfaceType surface_type,
ExPolygons &shells, ExPolygons &shells,
const Algorithm::RegionExpansionParameters &params, const Algorithm::RegionExpansionParameters &params,
const float closing_diameter, const float closing_radius,
const double bridge_angle = -1.) const double bridge_angle = -1.)
{ {
double thickness; double thickness;
@ -346,7 +346,7 @@ static Surfaces expand_merge_surfaces(
//NOTE: The current regularization of the shells can create small unasigned regions in the object (E.G. benchy) //NOTE: The current regularization of the shells can create small unasigned regions in the object (E.G. benchy)
// without the following closing operation, those regions will stay unfilled and cause small holes in the expanded surface. // without the following closing operation, those regions will stay unfilled and cause small holes in the expanded surface.
// look for narrow_ensure_vertical_wall_thickness_region_radius filter. // look for narrow_ensure_vertical_wall_thickness_region_radius filter.
expanded = closing_ex(expanded, closing_diameter); expanded = closing_ex(expanded, closing_radius);
// Trim the shells by the expanded expolygons. // Trim the shells by the expanded expolygons.
shells = diff_ex(shells, expanded); shells = diff_ex(shells, expanded);
@ -385,7 +385,8 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
static constexpr const float expansion_step = scaled<float>(0.1); static constexpr const float expansion_step = scaled<float>(0.1);
// Don't take more than max_nr_steps for small expansion_step. // Don't take more than max_nr_steps for small expansion_step.
static constexpr const size_t max_nr_expansion_steps = 5; static constexpr const size_t max_nr_expansion_steps = 5;
const float closing_diameter = 0.65f * 1.05 * this->flow(frSolidInfill).scaled_spacing(); // Radius (with added epsilon) to absorb empty regions emering from regularization of ensuring, viz const float narrow_ensure_vertical_wall_thickness_region_radius = 0.5f * 0.65f * min_perimeter_infill_spacing;
const float closing_radius = 0.55f * 0.65f * 1.05f * this->flow(frSolidInfill).scaled_spacing();
// Expand the top / bottom / bridge surfaces into the shell thickness solid infills. // Expand the top / bottom / bridge surfaces into the shell thickness solid infills.
double layer_thickness; double layer_thickness;
@ -397,8 +398,8 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
const double custom_angle = this->region().config().bridge_angle.value; const double custom_angle = this->region().config().bridge_angle.value;
const auto params = Algorithm::RegionExpansionParameters::build(expansion_bottom_bridge, expansion_step, max_nr_expansion_steps); const auto params = Algorithm::RegionExpansionParameters::build(expansion_bottom_bridge, expansion_step, max_nr_expansion_steps);
bridges.surfaces = custom_angle > 0 ? bridges.surfaces = custom_angle > 0 ?
expand_merge_surfaces(m_fill_surfaces.surfaces, stBottomBridge, shells, params, closing_diameter, Geometry::deg2rad(custom_angle)) : expand_merge_surfaces(m_fill_surfaces.surfaces, stBottomBridge, shells, params, closing_radius, Geometry::deg2rad(custom_angle)) :
expand_bridges_detect_orientations(m_fill_surfaces.surfaces, shells, params, closing_diameter); expand_bridges_detect_orientations(m_fill_surfaces.surfaces, shells, params, closing_radius);
BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges - done"; BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges - done";
#if 0 #if 0
{ {
@ -409,9 +410,9 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
} }
Surfaces bottoms = expand_merge_surfaces(m_fill_surfaces.surfaces, stBottom, shells, Surfaces bottoms = expand_merge_surfaces(m_fill_surfaces.surfaces, stBottom, shells,
Algorithm::RegionExpansionParameters::build(expansion_bottom, expansion_step, max_nr_expansion_steps), closing_diameter); Algorithm::RegionExpansionParameters::build(expansion_bottom, expansion_step, max_nr_expansion_steps), closing_radius);
Surfaces tops = expand_merge_surfaces(m_fill_surfaces.surfaces, stTop, shells, Surfaces tops = expand_merge_surfaces(m_fill_surfaces.surfaces, stTop, shells,
Algorithm::RegionExpansionParameters::build(expansion_top, expansion_step, max_nr_expansion_steps), closing_diameter); Algorithm::RegionExpansionParameters::build(expansion_top, expansion_step, max_nr_expansion_steps), closing_radius);
m_fill_surfaces.remove_types({ stBottomBridge, stBottom, stTop, stInternalSolid }); m_fill_surfaces.remove_types({ stBottomBridge, stBottom, stTop, stInternalSolid });
reserve_more(m_fill_surfaces.surfaces, shells.size() + bridges.size() + bottoms.size() + tops.size()); reserve_more(m_fill_surfaces.surfaces, shells.size() + bridges.size() + bottoms.size() + tops.size());