Increased line shortening near steep walls.

This commit is contained in:
PavelMikus 2023-04-20 17:26:54 +02:00 committed by Pavel Mikuš
parent 1279b4d22a
commit 2c12a7f164

View File

@ -100,7 +100,7 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
} }
double candidate_dist = (point.first - closest_higher->first).cast<double>().squaredNorm(); double candidate_dist = (point.first - closest_higher->first).cast<double>().squaredNorm();
if (closest_higher != sorted_intersections.begin()) { if (closest_higher != sorted_intersections.begin()) {
double closest_lower_dist = (point.first - (closest_higher--)->first).cast<double>().squaredNorm(); double closest_lower_dist = (point.first - (--closest_higher)->first).cast<double>().squaredNorm();
candidate_dist = std::min(candidate_dist, closest_lower_dist); candidate_dist = std::min(candidate_dist, closest_lower_dist);
} }
return candidate_dist; return candidate_dist;
@ -109,22 +109,22 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
Point section_b = b.first; Point section_b = b.first;
double max_a_squared_dist = std::max(get_closest_intersection_squared_dist(a, left_intersections), double max_a_squared_dist = std::max(get_closest_intersection_squared_dist(a, left_intersections),
get_closest_intersection_squared_dist(a, right_intersections)); get_closest_intersection_squared_dist(a, right_intersections));
double max_b_squared_dist = std::max(get_closest_intersection_squared_dist(b, left_intersections), double max_b_squared_dist = std::max(get_closest_intersection_squared_dist(b, left_intersections),
get_closest_intersection_squared_dist(b, right_intersections)); get_closest_intersection_squared_dist(b, right_intersections));
if (max_a_squared_dist > 0.4 * squared_distance_limit_reconnection) { if (max_a_squared_dist > 0.3 * squared_distance_limit_reconnection) {
section_a.y() += std::min(2.0 * scaled_spacing, sqrt(max_a_squared_dist)); section_a.y() += 4.0 * scaled_spacing;
} }
if (max_b_squared_dist > 0.4 * squared_distance_limit_reconnection) { if (max_b_squared_dist > 0.3 * squared_distance_limit_reconnection) {
section_b.y() -= std::min(2.0 * scaled_spacing, sqrt(max_b_squared_dist)); section_b.y() -= 4.0 * scaled_spacing;
} }
section_a.y() = std::min(section_a.y(), section_b.y()); if (section_a.y() < section_b.y()) {
section_b.y() = std::max(section_a.y(), section_b.y()); polygon_sections[i].emplace_back(section_a, section_b);
polygon_sections[i].emplace_back(section_a, section_b); }
} }
} }
} }
@ -362,7 +362,7 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
if (this->overlap != 0) { if (this->overlap != 0) {
gaps_for_additional_filling = offset_ex(gaps_for_additional_filling, scaled<float>(this->overlap)); gaps_for_additional_filling = offset_ex(gaps_for_additional_filling, scaled<float>(this->overlap));
} }
gaps_for_additional_filling = opening_ex(gaps_for_additional_filling, 0.3 * scaled_spacing); // gaps_for_additional_filling = opening_ex(gaps_for_additional_filling, 0.3 * scaled_spacing);
BoundingBox bbox = get_extents(filled_area); BoundingBox bbox = get_extents(filled_area);
bbox.offset(scale_(1.)); bbox.offset(scale_(1.));
@ -430,6 +430,9 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
} }
} }
// reconnect ThickPolylines
rotate_thick_polylines(thick_polylines_out, cos(-aligning_angle), sin(-aligning_angle)); rotate_thick_polylines(thick_polylines_out, cos(-aligning_angle), sin(-aligning_angle));
return thick_polylines_out; return thick_polylines_out;